正在查看: FanCode v7.24.0 应用的 l.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: FanCode v7.24.0 应用的 l.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package jl;
import il.a;
import il.d;
import java.io.IOException;
import java.io.Serializable;
import java.net.DatagramPacket;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import jl.h;
import jl.j;
import jl.m;
import okhttp3.HttpUrl;
import org.apache.http.HttpStatus;
public class l extends il.a implements jl.i, jl.j {
private volatile InetAddress a;
private volatile MulticastSocket b;
private final List<jl.d> c;
private final ConcurrentMap<String, List<m.a>> d;
private final Set<m.b> e;
private final jl.a i;
private final ConcurrentMap<String, il.d> k;
private final ConcurrentMap<String, j> n;
protected Thread o;
private k p;
private Thread q;
private int r;
private long s;
private jl.c v;
private final ConcurrentMap<String, i> w;
private final String x;
private static Logger z = Logger.getLogger(l.class.getName());
private static final Random A = new Random();
private final ExecutorService t = Executors.newSingleThreadExecutor();
private final ReentrantLock u = new ReentrantLock();
private final Object y = new Object();
class a implements Runnable {
final m.a a;
final il.c b;
a(m.a aVar, il.c cVar) {
this.a = aVar;
this.b = cVar;
}
@Override
public void run() {
this.a.f(this.b);
}
}
class b implements Runnable {
final m.b a;
final il.c b;
b(m.b bVar, il.c cVar) {
this.a = bVar;
this.b = cVar;
}
@Override
public void run() {
this.a.c(this.b);
}
}
class c implements Runnable {
final m.b a;
final il.c b;
c(m.b bVar, il.c cVar) {
this.a = bVar;
this.b = cVar;
}
@Override
public void run() {
this.a.d(this.b);
}
}
class d implements Runnable {
final m.a a;
final il.c b;
d(m.a aVar, il.c cVar) {
this.a = aVar;
this.b = cVar;
}
@Override
public void run() {
this.a.d(this.b);
}
}
class e implements Runnable {
final m.a a;
final il.c b;
e(m.a aVar, il.c cVar) {
this.a = aVar;
this.b = cVar;
}
@Override
public void run() {
this.a.e(this.b);
}
}
class f extends Thread {
f(String str) {
super(str);
}
@Override
public void run() {
l.this.U();
}
}
static class g {
static final int[] a;
static {
int[] iArr = new int[h.values().length];
a = iArr;
try {
iArr[h.Add.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[h.Remove.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public enum h {
Remove,
Update,
Add,
RegisterServiceType,
Noop
}
private static class i implements il.e {
private final String c;
private final ConcurrentMap<String, il.d> a = new ConcurrentHashMap();
private final ConcurrentMap<String, il.c> b = new ConcurrentHashMap();
private volatile boolean d = true;
public i(String str) {
this.c = str;
}
@Override
public void serviceAdded(il.c cVar) {
synchronized (this) {
il.d c = cVar.c();
if (c == null || !c.u()) {
p k1 = ((l) cVar.b()).k1(cVar.e(), cVar.d(), c != null ? c.p() : HttpUrl.FRAGMENT_ENCODE_SET, true);
if (k1 != null) {
this.a.put(cVar.d(), k1);
} else {
this.b.put(cVar.d(), cVar);
}
} else {
this.a.put(cVar.d(), c);
}
}
}
@Override
public void serviceRemoved(il.c cVar) {
synchronized (this) {
this.a.remove(cVar.d());
this.b.remove(cVar.d());
}
}
@Override
public void serviceResolved(il.c cVar) {
synchronized (this) {
this.a.put(cVar.d(), cVar.c());
this.b.remove(cVar.d());
}
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("\n\tType: ");
stringBuffer.append(this.c);
if (this.a.isEmpty()) {
stringBuffer.append("\n\tNo services collected.");
} else {
stringBuffer.append("\n\tServices");
for (String str : this.a.keySet()) {
stringBuffer.append("\n\t\tService: ");
stringBuffer.append(str);
stringBuffer.append(": ");
stringBuffer.append(this.a.get(str));
}
}
if (this.b.isEmpty()) {
stringBuffer.append("\n\tNo event queued.");
} else {
stringBuffer.append("\n\tEvents");
for (String str2 : this.b.keySet()) {
stringBuffer.append("\n\t\tEvent: ");
stringBuffer.append(str2);
stringBuffer.append(": ");
stringBuffer.append(this.b.get(str2));
}
}
return stringBuffer.toString();
}
}
public static class j extends AbstractMap<String, String> implements Cloneable {
private final Set<Map.Entry<String, String>> a = new HashSet();
private final String b;
private static class a implements Map.Entry<String, String>, Serializable, Cloneable {
private static final long serialVersionUID = 9188503522395855322L;
private final String a;
private final String b;
public a(String str) {
str = str == null ? HttpUrl.FRAGMENT_ENCODE_SET : str;
this.b = str;
this.a = str.toLowerCase();
}
public a clone() {
return this;
}
@Override
public String getKey() {
return this.a;
}
@Override
public String getValue() {
return this.b;
}
@Override
public String setValue(String str) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
return getKey().equals(entry.getKey()) && getValue().equals(entry.getValue());
}
@Override
public int hashCode() {
String str = this.a;
int hashCode = str == null ? 0 : str.hashCode();
String str2 = this.b;
return hashCode ^ (str2 != null ? str2.hashCode() : 0);
}
public String toString() {
return this.a + "=" + this.b;
}
}
public j(String str) {
this.b = str;
}
public boolean a(String str) {
if (str == null || c(str)) {
return false;
}
this.a.add(new a(str));
return true;
}
@Override
public j clone() {
j jVar = new j(d());
Iterator<Map.Entry<String, String>> it = entrySet().iterator();
while (it.hasNext()) {
jVar.a(it.next().getValue());
}
return jVar;
}
public boolean c(String str) {
return str != null && containsKey(str.toLowerCase());
}
public String d() {
return this.b;
}
@Override
public Set<Map.Entry<String, String>> entrySet() {
return this.a;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(HttpStatus.SC_OK);
if (isEmpty()) {
sb.append("empty");
} else {
Iterator<String> it = values().iterator();
while (it.hasNext()) {
sb.append(it.next());
sb.append(", ");
}
sb.setLength(sb.length() - 2);
}
return sb.toString();
}
}
public l(InetAddress inetAddress, String str) throws IOException {
if (z.isLoggable(Level.FINER)) {
z.finer("JmDNS instance created");
}
this.i = new jl.a(100);
this.c = Collections.synchronizedList(new ArrayList());
this.d = new ConcurrentHashMap();
this.e = Collections.synchronizedSet(new HashSet());
this.w = new ConcurrentHashMap();
this.k = new ConcurrentHashMap(20);
this.n = new ConcurrentHashMap(20);
k A2 = k.A(inetAddress, this, str);
this.p = A2;
this.x = str == null ? A2.q() : str;
b1(F0());
q1(K0().values());
I();
}
public static Random H0() {
return A;
}
private void W(String str, il.e eVar, boolean z2) {
m.a aVar = new m.a(eVar, z2);
String lowerCase = str.toLowerCase();
List<m.a> list = this.d.get(lowerCase);
if (list == null) {
if (this.d.putIfAbsent(lowerCase, new LinkedList()) == null && this.w.putIfAbsent(lowerCase, new i(str)) == null) {
W(lowerCase, this.w.get(lowerCase), true);
}
list = this.d.get(lowerCase);
}
if (list != null) {
synchronized (list) {
if (!list.contains(eVar)) {
list.add(aVar);
}
}
}
ArrayList arrayList = new ArrayList();
Iterator<jl.b> it = s0().c().iterator();
while (it.hasNext()) {
jl.h hVar = (jl.h) it.next();
if (hVar.f() == kl.e.TYPE_SRV && hVar.b().endsWith(lowerCase)) {
arrayList.add(new o(this, hVar.h(), r1(hVar.h(), hVar.c()), hVar.A()));
}
}
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
aVar.d((il.c) it2.next());
}
d(str);
}
private boolean a1(p pVar) {
boolean z2;
il.d dVar;
String L = pVar.L();
long currentTimeMillis = System.currentTimeMillis();
do {
for (jl.b bVar : s0().f(pVar.L())) {
if (kl.e.TYPE_SRV.equals(bVar.f()) && !bVar.j(currentTimeMillis)) {
h.f fVar = (h.f) bVar;
if (fVar.P() != pVar.j() || !fVar.R().equals(this.p.q())) {
if (z.isLoggable(Level.FINER)) {
z.finer("makeServiceNameUnique() JmDNS.makeServiceNameUnique srv collision:" + bVar + " s.server=" + fVar.R() + " " + this.p.q() + " equals:" + fVar.R().equals(this.p.q()));
}
pVar.c0(R0(pVar.i()));
z2 = true;
dVar = this.k.get(pVar.L());
if (dVar != null && dVar != pVar) {
pVar.c0(R0(pVar.i()));
z2 = true;
}
}
}
}
z2 = false;
dVar = this.k.get(pVar.L());
if (dVar != null) {
pVar.c0(R0(pVar.i()));
z2 = true;
}
} while (z2);
return !L.equals(pVar.L());
}
private void b1(k kVar) throws IOException {
if (this.a == null) {
if (kVar.n() instanceof Inet6Address) {
this.a = InetAddress.getByName("FF02::FB");
} else {
this.a = InetAddress.getByName("224.0.0.251");
}
}
if (this.b != null) {
h0();
}
this.b = new MulticastSocket(kl.a.a);
if (kVar != null && kVar.p() != null) {
try {
this.b.setNetworkInterface(kVar.p());
} catch (SocketException e2) {
if (z.isLoggable(Level.FINE)) {
z.fine("openMulticastSocket() Set network interface exception: " + e2.getMessage());
}
}
}
this.b.setTimeToLive(255);
this.b.joinGroup(this.a);
}
private void h0() {
if (z.isLoggable(Level.FINER)) {
z.finer("closeMulticastSocket()");
}
if (this.b != null) {
try {
try {
this.b.leaveGroup(this.a);
} catch (Exception e2) {
z.log(Level.WARNING, "closeMulticastSocket() Close socket exception ", (Throwable) e2);
}
} catch (SocketException unused) {
}
this.b.close();
while (true) {
Thread thread = this.q;
if (thread == null || !thread.isAlive()) {
break;
}
synchronized (this) {
try {
Thread thread2 = this.q;
if (thread2 != null && thread2.isAlive()) {
if (z.isLoggable(Level.FINER)) {
z.finer("closeMulticastSocket(): waiting for jmDNS monitor");
}
wait(1000L);
}
} catch (InterruptedException unused2) {
}
}
}
this.q = null;
this.b = null;
}
}
private void n0() {
if (z.isLoggable(Level.FINER)) {
z.finer("disposeServiceCollectors()");
}
for (String str : this.w.keySet()) {
i iVar = this.w.get(str);
if (iVar != null) {
S(str, iVar);
this.w.remove(str, iVar);
}
}
}
private void q1(Collection<? extends il.d> collection) {
if (this.q == null) {
q qVar = new q(this);
this.q = qVar;
qVar.start();
}
j();
Iterator<? extends il.d> it = collection.iterator();
while (it.hasNext()) {
try {
e1(new p(it.next()));
} catch (Exception e2) {
z.log(Level.WARNING, "start() Registration exception ", (Throwable) e2);
}
}
}
static String r1(String str, String str2) {
String lowerCase = str.toLowerCase();
String lowerCase2 = str2.toLowerCase();
return (!lowerCase2.endsWith(lowerCase) || lowerCase2.equals(lowerCase)) ? str2 : str2.substring(0, (str2.length() - str.length()) - 1);
}
private void w1(il.d dVar, long j2) {
synchronized (dVar) {
long j3 = j2 / 200;
if (j3 < 1) {
j3 = 1;
}
for (int i2 = 0; i2 < j3 && !dVar.u(); i2++) {
try {
dVar.wait(200L);
} catch (InterruptedException unused) {
}
}
}
}
public l B0() {
return this;
}
public InetAddress C0() {
return this.a;
}
@Override
public void D() {
j.b.a().b(B0()).D();
}
public InetAddress D0() throws IOException {
return this.b.getInterface();
}
public long E0() {
return this.s;
}
public k F0() {
return this.p;
}
public String G0() {
return this.x;
}
@Override
public void I() {
j.b.a().b(B0()).I();
}
p I0(String str, String str2, String str3, boolean z2) {
p pVar;
byte[] bArr;
String str4;
il.d B;
il.d B2;
il.d B3;
il.d B4;
p pVar2 = new p(str, str2, str3, 0, 0, 0, z2, null);
jl.a s0 = s0();
kl.d dVar = kl.d.CLASS_ANY;
jl.b e2 = s0.e(new h.e(str, dVar, false, 0, pVar2.m()));
if (!(e2 instanceof jl.h) || (pVar = (p) ((jl.h) e2).B(z2)) == null) {
return pVar2;
}
Map<d.a, String> N = pVar.N();
jl.b d2 = s0().d(pVar2.m(), kl.e.TYPE_SRV, dVar);
if (!(d2 instanceof jl.h) || (B4 = ((jl.h) d2).B(z2)) == null) {
bArr = null;
str4 = HttpUrl.FRAGMENT_ENCODE_SET;
} else {
p pVar3 = new p(N, B4.j(), B4.s(), B4.k(), z2, (byte[]) null);
byte[] q = B4.q();
str4 = B4.n();
bArr = q;
pVar = pVar3;
}
jl.b d3 = s0().d(str4, kl.e.TYPE_A, dVar);
if ((d3 instanceof jl.h) && (B3 = ((jl.h) d3).B(z2)) != null) {
for (Inet4Address inet4Address : B3.g()) {
pVar.x(inet4Address);
}
pVar.w(B3.q());
}
jl.b d4 = s0().d(str4, kl.e.TYPE_AAAA, kl.d.CLASS_ANY);
if ((d4 instanceof jl.h) && (B2 = ((jl.h) d4).B(z2)) != null) {
for (Inet6Address inet6Address : B2.h()) {
pVar.y(inet6Address);
}
pVar.w(B2.q());
}
jl.b d5 = s0().d(pVar.m(), kl.e.TYPE_TXT, kl.d.CLASS_ANY);
if ((d5 instanceof jl.h) && (B = ((jl.h) d5).B(z2)) != null) {
pVar.w(B.q());
}
if (pVar.q().length == 0) {
pVar.w(bArr);
}
return pVar.u() ? pVar : pVar2;
}
public Map<String, j> J0() {
return this.n;
}
public Map<String, il.d> K0() {
return this.k;
}
public MulticastSocket L0() {
return this.b;
}
public int M0() {
return this.r;
}
void N0(jl.c cVar, InetAddress inetAddress, int i2) throws IOException {
if (z.isLoggable(Level.FINE)) {
z.fine(G0() + ".handle query: " + cVar);
}
long currentTimeMillis = System.currentTimeMillis() + 120;
Iterator<? extends jl.h> it = cVar.b().iterator();
boolean z2 = false;
while (it.hasNext()) {
z2 |= it.next().D(this, currentTimeMillis);
}
S0();
try {
jl.c cVar2 = this.v;
if (cVar2 != null) {
cVar2.u(cVar);
} else {
jl.c clone = cVar.clone();
if (cVar.o()) {
this.v = clone;
}
z(clone, i2);
}
T0();
long currentTimeMillis2 = System.currentTimeMillis();
Iterator<? extends jl.h> it2 = cVar.c().iterator();
while (it2.hasNext()) {
O0(it2.next(), currentTimeMillis2);
}
if (z2) {
j();
}
} catch (Throwable th) {
T0();
throw th;
}
}
@Override
public void O() {
j.b.a().b(B0()).O();
}
void O0(jl.h hVar, long j2) {
h hVar2 = h.Noop;
boolean j3 = hVar.j(j2);
Logger logger = z;
Level level = Level.FINE;
if (logger.isLoggable(level)) {
z.fine(G0() + " handle response: " + hVar);
}
if (!hVar.o() && !hVar.i()) {
boolean p = hVar.p();
jl.h hVar3 = (jl.h) s0().e(hVar);
if (z.isLoggable(level)) {
z.fine(G0() + " handle response cached record: " + hVar3);
}
if (p) {
for (jl.b bVar : s0().f(hVar.b())) {
if (hVar.f().equals(bVar.f()) && hVar.e().equals(bVar.e()) && bVar != hVar3) {
((jl.h) bVar).L(j2);
}
}
}
if (hVar3 != null) {
if (j3) {
if (hVar.C() == 0) {
hVar2 = h.Noop;
hVar3.L(j2);
} else {
hVar2 = h.Remove;
s0().l(hVar3);
}
} else if (hVar.J(hVar3) && (hVar.s(hVar3) || hVar.g().length() <= 0)) {
hVar3.H(hVar);
hVar = hVar3;
} else if (hVar.F()) {
hVar2 = h.Update;
s0().m(hVar, hVar3);
} else {
hVar2 = h.Add;
s0().b(hVar);
}
} else if (!j3) {
hVar2 = h.Add;
s0().b(hVar);
}
}
if (hVar.f() == kl.e.TYPE_PTR) {
if (hVar.o()) {
if (j3) {
return;
}
f1(((h.e) hVar).P());
return;
} else if ((f1(hVar.c()) | false) && hVar2 == h.Noop) {
hVar2 = h.RegisterServiceType;
}
}
if (hVar2 != h.Noop) {
t1(j2, hVar, hVar2);
}
}
@Override
public void P() {
j.b.a().b(B0()).P();
}
void P0(jl.c cVar) throws IOException {
long currentTimeMillis = System.currentTimeMillis();
boolean z2 = false;
boolean z3 = false;
for (jl.h hVar : cVar.b()) {
O0(hVar, currentTimeMillis);
if (kl.e.TYPE_A.equals(hVar.f()) || kl.e.TYPE_AAAA.equals(hVar.f())) {
z2 |= hVar.E(this);
} else {
z3 |= hVar.E(this);
}
}
if (z2 || z3) {
j();
}
}
@Override
public void Q(String str, il.e eVar) {
W(str, eVar, false);
}
void Q0(il.c cVar) {
ArrayList arrayList;
List<m.a> list = this.d.get(cVar.e().toLowerCase());
if (list == null || list.isEmpty() || cVar.c() == null || !cVar.c().u()) {
return;
}
synchronized (list) {
arrayList = new ArrayList(list);
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
this.t.submit(new a((m.a) it.next(), cVar));
}
}
String R0(String str) {
try {
int lastIndexOf = str.lastIndexOf(40);
int lastIndexOf2 = str.lastIndexOf(41);
if (lastIndexOf < 0 || lastIndexOf >= lastIndexOf2) {
str = str + " (2)";
} else {
str = str.substring(0, lastIndexOf) + "(" + (Integer.parseInt(str.substring(lastIndexOf + 1, lastIndexOf2)) + 1) + ")";
}
return str;
} catch (NumberFormatException unused) {
return str + " (2)";
}
}
@Override
public void S(String str, il.e eVar) {
String lowerCase = str.toLowerCase();
List<m.a> list = this.d.get(lowerCase);
if (list != null) {
synchronized (list) {
list.remove(new m.a(eVar, false));
if (list.isEmpty()) {
this.d.remove(lowerCase, list);
}
}
}
}
public void S0() {
this.u.lock();
}
@Override
public void T(String str, String str2, long j2) {
j1(str, str2, false, 6000L);
}
public void T0() {
this.u.unlock();
}
void U() {
Logger logger = z;
Level level = Level.FINER;
if (logger.isLoggable(level)) {
z.finer(G0() + "recover() Cleanning up");
}
z.warning("RECOVERING");
t();
ArrayList arrayList = new ArrayList(K0().values());
s1();
n0();
v1(5000L);
P();
h0();
s0().clear();
if (z.isLoggable(level)) {
z.finer(G0() + "recover() All is clean");
}
if (!W0()) {
z.log(Level.WARNING, G0() + "recover() Could not recover we are Down!");
x0();
return;
}
Iterator<? extends il.d> it = arrayList.iterator();
while (it.hasNext()) {
((p) it.next()).X();
}
d1();
try {
b1(F0());
q1(arrayList);
} catch (Exception e2) {
z.log(Level.WARNING, G0() + "recover() Start services exception ", (Throwable) e2);
}
z.log(Level.WARNING, G0() + "recover() We are back!");
}
public boolean U0() {
return this.p.s();
}
public void V(jl.d dVar, jl.g gVar) {
long currentTimeMillis = System.currentTimeMillis();
this.c.add(dVar);
if (gVar != null) {
for (jl.b bVar : s0().f(gVar.c().toLowerCase())) {
if (gVar.y(bVar) && !bVar.j(currentTimeMillis)) {
dVar.a(s0(), currentTimeMillis, bVar);
}
}
}
}
public boolean V0(ll.a aVar, kl.g gVar) {
return this.p.t(aVar, gVar);
}
public boolean W0() {
return this.p.u();
}
public boolean X0() {
return this.p.v();
}
public boolean Y0() {
return this.p.x();
}
public void Z(ll.a aVar, kl.g gVar) {
this.p.b(aVar, gVar);
}
public boolean Z0() {
return this.p.y();
}
@Override
public void a() {
j.b.a().b(B0()).a();
}
@Override
public void c(p pVar) {
j.b.a().b(B0()).c(pVar);
}
public boolean c0() {
return this.p.c();
}
public void c1() {
z.finer(G0() + "recover()");
if (Y0() || isClosed() || X0() || W0()) {
return;
}
synchronized (this.y) {
if (c0()) {
z.finer(G0() + "recover() thread " + Thread.currentThread().getName());
StringBuilder sb = new StringBuilder();
sb.append(G0());
sb.append(".recover()");
new f(sb.toString()).start();
}
}
}
@Override
public void close() {
if (Y0()) {
return;
}
Logger logger = z;
Level level = Level.FINER;
if (logger.isLoggable(level)) {
z.finer("Cancelling JmDNS: " + this);
}
if (m0()) {
z.finer("Canceling the timer");
f();
s1();
n0();
if (z.isLoggable(level)) {
z.finer("Wait for JmDNS cancel: " + this);
}
v1(5000L);
z.finer("Canceling the state timer");
a();
this.t.shutdown();
h0();
if (this.o != null) {
Runtime.getRuntime().removeShutdownHook(this.o);
}
if (z.isLoggable(level)) {
z.finer("JmDNS closed.");
}
}
o(null);
}
@Override
public void d(String str) {
j.b.a().b(B0()).d(str);
}
public boolean d1() {
return this.p.B();
}
public void e1(il.d dVar) throws IOException {
if (Y0() || isClosed()) {
throw new IllegalStateException("This DNS is closed.");
}
p pVar = (p) dVar;
if (pVar.H() != null) {
if (pVar.H() != this) {
throw new IllegalStateException("A service information can only be registered with a single instamce of JmDNS.");
}
if (this.k.get(pVar.L()) != null) {
throw new IllegalStateException("A service information can only be registered once.");
}
}
pVar.b0(this);
f1(pVar.P());
pVar.X();
pVar.e0(this.p.q());
pVar.x(this.p.l());
pVar.y(this.p.m());
u1(6000L);
a1(pVar);
while (this.k.putIfAbsent(pVar.L(), pVar) != null) {
a1(pVar);
}
j();
pVar.g0(6000L);
if (z.isLoggable(Level.FINE)) {
z.fine("registerService() JmDNS registered service as " + pVar);
}
}
@Override
public void f() {
j.b.a().b(B0()).f();
}
public boolean f1(String str) {
boolean z2;
j jVar;
Map<d.a, String> G = p.G(str);
String str2 = G.get(d.a.Domain);
String str3 = G.get(d.a.Protocol);
String str4 = G.get(d.a.Application);
String str5 = G.get(d.a.Subtype);
StringBuilder sb = new StringBuilder();
sb.append(str4.length() > 0 ? "_" + str4 + "." : HttpUrl.FRAGMENT_ENCODE_SET);
sb.append(str3.length() > 0 ? "_" + str3 + "." : HttpUrl.FRAGMENT_ENCODE_SET);
sb.append(str2);
sb.append(".");
String sb2 = sb.toString();
String lowerCase = sb2.toLowerCase();
if (z.isLoggable(Level.FINE)) {
Logger logger = z;
StringBuilder sb3 = new StringBuilder();
sb3.append(G0());
sb3.append(".registering service type: ");
sb3.append(str);
sb3.append(" as: ");
sb3.append(sb2);
sb3.append(str5.length() > 0 ? " subtype: " + str5 : HttpUrl.FRAGMENT_ENCODE_SET);
logger.fine(sb3.toString());
}
boolean z3 = true;
if (this.n.containsKey(lowerCase) || str4.toLowerCase().equals("dns-sd") || str2.toLowerCase().endsWith("in-addr.arpa") || str2.toLowerCase().endsWith("ip6.arpa")) {
z2 = false;
} else {
z2 = this.n.putIfAbsent(lowerCase, new j(sb2)) == null;
if (z2) {
Set<m.b> set = this.e;
m.b[] bVarArr = (m.b[]) set.toArray(new m.b[set.size()]);
o oVar = new o(this, sb2, HttpUrl.FRAGMENT_ENCODE_SET, null);
for (m.b bVar : bVarArr) {
this.t.submit(new b(bVar, oVar));
}
}
}
if (str5.length() <= 0 || (jVar = this.n.get(lowerCase)) == null || jVar.c(str5)) {
return z2;
}
synchronized (jVar) {
if (jVar.c(str5)) {
z3 = z2;
} else {
jVar.a(str5);
Set<m.b> set2 = this.e;
m.b[] bVarArr2 = (m.b[]) set2.toArray(new m.b[set2.size()]);
o oVar2 = new o(this, "_" + str5 + "._sub." + sb2, HttpUrl.FRAGMENT_ENCODE_SET, null);
for (m.b bVar2 : bVarArr2) {
this.t.submit(new c(bVar2, oVar2));
}
}
}
return z3;
}
public void g0() {
long currentTimeMillis = System.currentTimeMillis();
for (jl.b bVar : s0().c()) {
try {
jl.h hVar = (jl.h) bVar;
if (hVar.j(currentTimeMillis)) {
t1(currentTimeMillis, hVar, h.Remove);
s0().l(hVar);
} else if (hVar.G(currentTimeMillis)) {
i1(hVar);
}
} catch (Exception e2) {
z.log(Level.SEVERE, G0() + ".Error while reaping records: " + bVar, (Throwable) e2);
z.severe(toString());
}
}
}
public void g1(ll.a aVar) {
this.p.C(aVar);
}
public void h1(jl.d dVar) {
this.c.remove(dVar);
}
public void i1(jl.h hVar) {
il.d A2 = hVar.A();
if (this.w.containsKey(A2.r().toLowerCase())) {
d(A2.r());
}
}
public boolean isClosed() {
return this.p.w();
}
@Override
public void j() {
j.b.a().b(B0()).j();
}
public void j1(String str, String str2, boolean z2, long j2) {
w1(k1(str, str2, HttpUrl.FRAGMENT_ENCODE_SET, z2), j2);
}
p k1(String str, String str2, String str3, boolean z2) {
g0();
String lowerCase = str.toLowerCase();
f1(str);
if (this.w.putIfAbsent(lowerCase, new i(str)) == null) {
W(lowerCase, this.w.get(lowerCase), true);
}
p I0 = I0(str, str2, str3, z2);
c(I0);
return I0;
}
public void l1(jl.c cVar) {
S0();
try {
if (this.v == cVar) {
this.v = null;
}
} finally {
T0();
}
}
public boolean m0() {
return this.p.d();
}
public boolean m1() {
return this.p.D();
}
@Override
public void n() {
j.b.a().b(B0()).n();
}
public void n1(jl.f fVar) throws IOException {
if (fVar.l()) {
return;
}
byte[] y = fVar.y();
DatagramPacket datagramPacket = new DatagramPacket(y, y.length, this.a, kl.a.a);
Logger logger = z;
Level level = Level.FINEST;
if (logger.isLoggable(level)) {
try {
jl.c cVar = new jl.c(datagramPacket);
if (z.isLoggable(level)) {
z.finest("send(" + G0() + ") JmDNS out:" + cVar.y(true));
}
} catch (IOException e2) {
z.throwing(getClass().toString(), "send(" + G0() + ") - JmDNS can not parse what it sends!!!", e2);
}
}
MulticastSocket multicastSocket = this.b;
if (multicastSocket == null || multicastSocket.isClosed()) {
return;
}
multicastSocket.send(datagramPacket);
}
@Override
public boolean o(ll.a aVar) {
return this.p.o(aVar);
}
public void o1(long j2) {
this.s = j2;
}
public void p1(int i2) {
this.r = i2;
}
public jl.a s0() {
return this.i;
}
public void s1() {
if (z.isLoggable(Level.FINER)) {
z.finer("unregisterAllServices()");
}
Iterator<String> it = this.k.keySet().iterator();
while (it.hasNext()) {
p pVar = (p) this.k.get(it.next());
if (pVar != null) {
if (z.isLoggable(Level.FINER)) {
z.finer("Cancelling service info: " + pVar);
}
pVar.B();
}
}
D();
for (String str : this.k.keySet()) {
p pVar2 = (p) this.k.get(str);
if (pVar2 != null) {
if (z.isLoggable(Level.FINER)) {
z.finer("Wait for service info cancel: " + pVar2);
}
pVar2.h0(5000L);
this.k.remove(str, pVar2);
}
}
}
@Override
public void t() {
j.b.a().b(B0()).t();
}
public void t1(long j2, jl.h hVar, h hVar2) {
ArrayList arrayList;
List<m.a> emptyList;
synchronized (this.c) {
arrayList = new ArrayList(this.c);
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
((jl.d) it.next()).a(s0(), j2, hVar);
}
if (kl.e.TYPE_PTR.equals(hVar.f())) {
il.c z2 = hVar.z(this);
if (z2.c() == null || !z2.c().u()) {
p I0 = I0(z2.e(), z2.d(), HttpUrl.FRAGMENT_ENCODE_SET, false);
if (I0.u()) {
z2 = new o(this, z2.e(), z2.d(), I0);
}
}
List<m.a> list = this.d.get(z2.e().toLowerCase());
if (list != null) {
synchronized (list) {
emptyList = new ArrayList(list);
}
} else {
emptyList = Collections.emptyList();
}
if (z.isLoggable(Level.FINEST)) {
z.finest(G0() + ".updating record for event: " + z2 + " list " + emptyList + " operation: " + hVar2);
}
if (emptyList.isEmpty()) {
return;
}
int i2 = g.a[hVar2.ordinal()];
if (i2 == 1) {
for (m.a aVar : emptyList) {
if (aVar.b()) {
aVar.d(z2);
} else {
this.t.submit(new d(aVar, z2));
}
}
return;
}
if (i2 != 2) {
return;
}
for (m.a aVar2 : emptyList) {
if (aVar2.b()) {
aVar2.e(z2);
} else {
this.t.submit(new e(aVar2, z2));
}
}
}
}
public String toString() {
StringBuilder sb = new StringBuilder(2048);
sb.append("\t---- Local Host -----");
sb.append("\n\t");
sb.append(this.p);
sb.append("\n\t---- Services -----");
for (String str : this.k.keySet()) {
sb.append("\n\t\tService: ");
sb.append(str);
sb.append(": ");
sb.append(this.k.get(str));
}
sb.append("\n");
sb.append("\t---- Types ----");
Iterator<String> it = this.n.keySet().iterator();
while (it.hasNext()) {
j jVar = this.n.get(it.next());
sb.append("\n\t\tType: ");
sb.append(jVar.d());
sb.append(": ");
if (jVar.isEmpty()) {
jVar = "no subtypes";
}
sb.append(jVar);
}
sb.append("\n");
sb.append(this.i.toString());
sb.append("\n");
sb.append("\t---- Service Collectors ----");
for (String str2 : this.w.keySet()) {
sb.append("\n\t\tService Collector: ");
sb.append(str2);
sb.append(": ");
sb.append(this.w.get(str2));
}
sb.append("\n");
sb.append("\t---- Service Listeners ----");
for (String str3 : this.d.keySet()) {
sb.append("\n\t\tService Listener: ");
sb.append(str3);
sb.append(": ");
sb.append(this.d.get(str3));
}
return sb.toString();
}
public boolean u1(long j2) {
return this.p.F(j2);
}
public boolean v1(long j2) {
return this.p.G(j2);
}
public a.InterfaceC0005a x0() {
return null;
}
@Override
public void z(jl.c cVar, int i2) {
j.b.a().b(B0()).z(cVar, i2);
}
}