Move to vanilla jmDNS 3.4.2 which fixes a bunch of mDNS issues and doesn't require a patch to work

This commit is contained in:
Cameron Gutman 2015-08-17 19:13:38 -07:00
parent 63964ba6a7
commit 64aa01b2cf
5 changed files with 18 additions and 56 deletions

View File

@ -3,9 +3,9 @@
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="libs/tinyrtsp.jar"/> <classpathentry kind="lib" path="libs/tinyrtsp.jar"/>
<classpathentry kind="lib" path="libs/jmdns-fixed.jar"/>
<classpathentry kind="lib" path="libs/xpp3-1.1.6.jar"/> <classpathentry kind="lib" path="libs/xpp3-1.1.6.jar"/>
<classpathentry kind="lib" path="libs/okhttp-2.4.0.jar"/> <classpathentry kind="lib" path="libs/okhttp-2.4.0.jar"/>
<classpathentry kind="lib" path="libs/okio-1.5.0.jar"/> <classpathentry kind="lib" path="libs/okio-1.5.0.jar"/>
<classpathentry kind="lib" path="libs/jmdns-3.4.2.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

View File

@ -1,31 +0,0 @@
Index: build.xml
===================================================================
--- build.xml (revision 353)
+++ build.xml (working copy)
@@ -58,7 +58,7 @@
</javac>
</target>
- <target name="jar" depends="build,tools" description="Jar the files">
+ <target name="jar" depends="build" description="Jar the files">
<mkdir dir="${buildlib}" />
<jar destfile="${buildlib}/jmdns.jar" manifest="${lib}/jmdns.manifest" basedir="${dest}">
<fileset dir="${dest}" defaultexcludes="yes">
Index: src/main/java/javax/jmdns/impl/tasks/resolver/ServiceInfoResolver.java
===================================================================
--- src/main/java/javax/jmdns/impl/tasks/resolver/ServiceInfoResolver.java (revision 353)
+++ src/main/java/javax/jmdns/impl/tasks/resolver/ServiceInfoResolver.java (working copy)
@@ -80,12 +80,7 @@
protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
if (!_info.hasData()) {
- newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
- newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
- if (_info.getServer().length() > 0) {
- newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
- newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
- }
+ newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
}
return newOut;
}

View File

@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -12,16 +11,16 @@ import java.util.List;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import com.jmdns.JmDNS; import javax.jmdns.JmmDNS;
import com.jmdns.ServiceEvent; import javax.jmdns.ServiceEvent;
import com.jmdns.ServiceListener; import javax.jmdns.ServiceListener;
import com.limelight.LimeLog; import com.limelight.LimeLog;
public class MdnsDiscoveryAgent { public class MdnsDiscoveryAgent {
public static final String SERVICE_TYPE = "_nvstream._tcp.local."; public static final String SERVICE_TYPE = "_nvstream._tcp.local.";
private JmDNS resolver; private JmmDNS resolver;
private HashMap<InetAddress, MdnsComputer> computers; private HashMap<InetAddress, MdnsComputer> computers;
private MdnsDiscoveryListener listener; private MdnsDiscoveryListener listener;
private HashSet<String> pendingResolution; private HashSet<String> pendingResolution;
@ -34,7 +33,7 @@ public class MdnsDiscoveryAgent {
pendingResolution.add(event.getInfo().getName()); pendingResolution.add(event.getInfo().getName());
// We call this to kick the resolver // We call this to kick the resolver
resolver.getServiceInfo(SERVICE_TYPE, event.getInfo().getName()); resolver.requestServiceInfo(SERVICE_TYPE, event.getInfo().getName());
} }
public void serviceRemoved(ServiceEvent event) { public void serviceRemoved(ServiceEvent event) {
@ -101,43 +100,37 @@ public class MdnsDiscoveryAgent {
public void startDiscovery(final int discoveryIntervalMs) { public void startDiscovery(final int discoveryIntervalMs) {
stop = false; stop = false;
resolver = JmmDNS.Factory.getInstance();
resolver.addServiceListener(SERVICE_TYPE, nvstreamListener);
final Timer t = new Timer(); final Timer t = new Timer();
t.schedule(new TimerTask() { t.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
synchronized (MdnsDiscoveryAgent.this) { synchronized (MdnsDiscoveryAgent.this) {
// Close the old resolver
if (resolver != null) {
try {
resolver.close();
} catch (IOException e) {}
resolver = null;
}
// Stop if requested // Stop if requested
if (stop) { if (stop) {
// There will be no further timer invocations now // There will be no further timer invocations now
t.cancel(); t.cancel();
return;
}
// Create a new resolver // Close the resolver
try { if (resolver != null) {
resolver = JmDNS.create(new InetSocketAddress(0).getAddress()); try {
} catch (IOException e) { resolver.close();
// This is fine; the network is probably not up } catch (IOException e) {}
resolver = null;
}
return; return;
} }
// Send another mDNS query // Send another mDNS query
resolver.addServiceListener(SERVICE_TYPE, nvstreamListener);
resolver.requestServiceInfo(SERVICE_TYPE, null, discoveryIntervalMs); resolver.requestServiceInfo(SERVICE_TYPE, null, discoveryIntervalMs);
// Run service resolution again for pending machines // Run service resolution again for pending machines
ArrayList<String> pendingNames = new ArrayList<String>(pendingResolution); ArrayList<String> pendingNames = new ArrayList<String>(pendingResolution);
for (String name : pendingNames) { for (String name : pendingNames) {
LimeLog.info("mDNS: Retrying service resolution for machine: "+name); LimeLog.info("mDNS: Retrying service resolution for machine: "+name);
resolver.getServiceInfo(SERVICE_TYPE, name); resolver.requestServiceInfo(SERVICE_TYPE, name);
} }
} }
} }