~ubuntu-branches/ubuntu/saucy/jenkins/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/build/use-stock-jmdns.patch/core/src/main/java/hudson/DNSMultiCast.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-13 12:35:19 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130813123519-tizgfxcr70trl7r0
Tags: 1.509.2+dfsg-1
* New upstream release (Closes: #706725):
  - d/control: Update versioned BD's:
    * jenkins-executable-war >= 1.28.
    * jenkins-instance-identity >= 1.3.
    * libjenkins-remoting-java >= 2.23.
    * libjenkins-winstone-java >= 0.9.10-jenkins-44.
    * libstapler-java >= 1.207.
    * libjenkins-json-java >= 2.4-jenkins-1.
    * libstapler-adjunct-timeline-java >= 1.4.
    * libstapler-adjunct-codemirror-java >= 1.2.
    * libmaven-hpi-plugin-java >= 1.93.
    * libjenkins-xstream-java >= 1.4.4-jenkins-3.
  - d/maven.rules: Map to older version of animal-sniffer-maven-plugin.
  - Add patch for compatibility with guava >= 0.14.
  - Add patch to exclude asm4 dependency via jnr-posix.
  - Fixes the following security vulnerabilities:
    CVE-2013-2034, CVE-2013-2033, CVE-2013-2034, CVE-2013-1808
* d/patches/*: Switch to using git patch-queue for managing patches.
* De-duplicate jars between libjenkins-java and jenkins-external-job-monitor
  (Closes: #701163):
  - d/control: Add dependency between jenkins-external-job-monitor ->
    libjenkins-java.
  - d/rules: 
    Drop installation of jenkins-core in jenkins-external-job-monitor.
  - d/jenkins-external-job-monitor.{links,install}: Link to jenkins-core
    in /usr/share/java instead of included version.
* Wait longer for jenkins to stop during restarts (Closes: #704848):
  - d/jenkins.init: Re-sync init script from upstream codebase.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package hudson;
2
 
 
3
 
import jenkins.model.Jenkins;
4
 
 
5
 
import javax.jmdns.JmDNS;
6
 
import javax.jmdns.ServiceInfo;
7
 
import java.io.Closeable;
8
 
import java.io.IOException;
9
 
import java.net.URL;
10
 
import java.util.HashMap;
11
 
import java.util.Map;
12
 
import java.util.logging.Level;
13
 
import java.util.logging.Logger;
14
 
 
15
 
/**
16
 
 * Registers a DNS multi-cast service-discovery support.
17
 
 *
18
 
 * @author Kohsuke Kawaguchi
19
 
 */
20
 
public class DNSMultiCast implements Closeable {
21
 
    private JmDNS jmdns;
22
 
 
23
 
    public DNSMultiCast(Jenkins hudson) {
24
 
        if (disabled)   return; // escape hatch
25
 
        
26
 
        try {
27
 
            this.jmdns = JmDNS.create();
28
 
 
29
 
            Map<String,String> props = new HashMap<String, String>();
30
 
            String rootURL = hudson.getRootUrl();
31
 
            if (rootURL==null)  return;
32
 
 
33
 
            try {
34
 
                props.put("version",String.valueOf(Jenkins.getVersion()));
35
 
            } catch (IllegalArgumentException e) {
36
 
                // failed to parse the version number
37
 
            }
38
 
 
39
 
            TcpSlaveAgentListener tal = hudson.getTcpSlaveAgentListener();
40
 
            if (tal!=null)
41
 
                props.put("slave-port",String.valueOf(tal.getPort()));
42
 
 
43
 
            props.put("server-id", hudson.getLegacyInstanceId());
44
 
 
45
 
            URL jenkins_url = new URL(rootURL);
46
 
            int jenkins_port = jenkins_url.getPort();
47
 
            if (jenkins_port == -1) {
48
 
                jenkins_port = 80;
49
 
            }
50
 
            if (jenkins_url.getPath().length() > 0) {
51
 
                props.put("path", jenkins_url.getPath());
52
 
            }
53
 
 
54
 
            jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","hudson",
55
 
                    jenkins_port,0,0,props));   // for backward compatibility
56
 
            jmdns.registerService(ServiceInfo.create("_jenkins._tcp.local.","jenkins",
57
 
                    jenkins_port,0,0,props));
58
 
            
59
 
            // Make Jenkins appear in Safari's Bonjour bookmarks
60
 
            jmdns.registerService(ServiceInfo.create("_http._tcp.local.","Jenkins",
61
 
                    jenkins_port,0,0,props));
62
 
        } catch (IOException e) {
63
 
            LOGGER.log(Level.WARNING,"Failed to advertise the service to DNS multi-cast",e);
64
 
        }
65
 
    }
66
 
 
67
 
    public void close() {
68
 
        if (jmdns!=null) {
69
 
//            try {
70
 
                jmdns.abort();
71
 
                jmdns = null;
72
 
//            } catch (final IOException e) {
73
 
//                LOGGER.log(Level.WARNING,"Failed to close down JmDNS instance!",e);
74
 
//            }
75
 
        }
76
 
    }
77
 
 
78
 
    private static final Logger LOGGER = Logger.getLogger(DNSMultiCast.class.getName());
79
 
 
80
 
    public static boolean disabled = Boolean.getBoolean(DNSMultiCast.class.getName()+".disabled");
81
 
}