导航菜单

页面标题

页面副标题

Oolka v2.4.42 - SocketReceiver.java 源代码

正在查看: Oolka v2.4.42 应用的 SocketReceiver.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package ch.qos.logback.classic.net;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.b;
import ch.qos.logback.classic.net.server.a;
import ch.qos.logback.classic.spi.c;
import ch.qos.logback.core.net.d;
import ch.qos.logback.core.net.h;
import ch.qos.logback.core.util.CloseUtil;
import java.io.EOFException;
import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import javax.net.SocketFactory;

public class SocketReceiver extends ReceiverBase implements Runnable, h.a {
    public String e;
    public InetAddress f;
    public int g;
    public int h;
    public int i = 5000;
    public String j;
    public volatile Socket k;
    public Future<Socket> l;

    @Override
    public void J(h hVar, Exception exc) {
        if (exc instanceof InterruptedException) {
            Z("connector interrupted");
            return;
        }
        if (exc instanceof ConnectException) {
            Z(this.j + "connection refused");
            return;
        }
        Z(this.j + exc);
    }

    @Override
    public Runnable P1() {
        return this;
    }

    @Override
    public void Q1() {
        if (this.k != null) {
            CloseUtil.c(this.k);
        }
    }

    @Override
    public boolean W1() {
        int i;
        if (this.g == 0) {
            g("No port was configured for receiver. For more information, please visit http://logback.qos.ch/codes.html#receiver_no_port");
            i = 1;
        } else {
            i = 0;
        }
        if (this.e == null) {
            i++;
            g("No host name or address was configured for receiver. For more information, please visit http://logback.qos.ch/codes.html#receiver_no_host");
        }
        if (this.h == 0) {
            this.h = 30000;
        }
        if (i == 0) {
            try {
                this.f = InetAddress.getByName(this.e);
            } catch (UnknownHostException unused) {
                g("unknown host: " + this.e);
                i++;
            }
        }
        if (i == 0) {
            this.j = "receiver " + this.e + ":" + this.g + ": ";
        }
        return i == 0;
    }

    public final Future<Socket> a2(h hVar) {
        try {
            return G1().z().submit(hVar);
        } catch (RejectedExecutionException unused) {
            return null;
        }
    }

    public final h b2(InetAddress inetAddress, int i, int i2, int i3) {
        h j2 = j2(inetAddress, i, i2, i3);
        j2.b(this);
        j2.a(g2());
        return j2;
    }

    public final void d2(LoggerContext loggerContext) {
        a aVar;
        StringBuilder sb;
        try {
            try {
                this.k.setSoTimeout(this.i);
                aVar = new a(this.k.getInputStream());
                try {
                    this.k.setSoTimeout(0);
                    Z(this.j + "connection established");
                    while (true) {
                        c cVar = (c) aVar.readObject();
                        b c = loggerContext.c(cVar.l());
                        if (c.o(cVar.b())) {
                            c.c(cVar);
                        }
                    }
                } catch (EOFException unused) {
                    Z(this.j + "end-of-stream detected");
                    CloseUtil.a(aVar);
                    CloseUtil.c(this.k);
                    this.k = null;
                    sb = new StringBuilder();
                    sb.append(this.j);
                    sb.append("connection closed");
                    Z(sb.toString());
                } catch (IOException e) {
                    e = e;
                    Z(this.j + "connection failed: " + e);
                    CloseUtil.a(aVar);
                    CloseUtil.c(this.k);
                    this.k = null;
                    sb = new StringBuilder();
                    sb.append(this.j);
                    sb.append("connection closed");
                    Z(sb.toString());
                } catch (ClassNotFoundException e2) {
                    e = e2;
                    Z(this.j + "unknown event class: " + e);
                    CloseUtil.a(aVar);
                    CloseUtil.c(this.k);
                    this.k = null;
                    sb = new StringBuilder();
                    sb.append(this.j);
                    sb.append("connection closed");
                    Z(sb.toString());
                }
            } catch (Throwable th) {
                th = th;
                CloseUtil.a(null);
                CloseUtil.c(this.k);
                this.k = null;
                Z(this.j + "connection closed");
                throw th;
            }
        } catch (EOFException unused2) {
            aVar = null;
        } catch (IOException e3) {
            e = e3;
            aVar = null;
        } catch (ClassNotFoundException e4) {
            e = e4;
            aVar = null;
        } catch (Throwable th2) {
            th = th2;
            CloseUtil.a(null);
            CloseUtil.c(this.k);
            this.k = null;
            Z(this.j + "connection closed");
            throw th;
        }
    }

    public SocketFactory g2() {
        return SocketFactory.getDefault();
    }

    public h j2(InetAddress inetAddress, int i, int i2, int i3) {
        return new d(inetAddress, i, i2, i3);
    }

    public final Socket o2() throws InterruptedException {
        try {
            Socket socket = this.l.get();
            this.l = null;
            return socket;
        } catch (ExecutionException unused) {
            return null;
        }
    }

    @Override
    public void run() {
        try {
            LoggerContext loggerContext = (LoggerContext) G1();
            while (!Thread.currentThread().isInterrupted()) {
                Future<Socket> a2 = a2(b2(this.f, this.g, 0, this.h));
                this.l = a2;
                if (a2 == null) {
                    break;
                }
                this.k = o2();
                if (this.k == null) {
                    break;
                } else {
                    d2(loggerContext);
                }
            }
        } catch (InterruptedException unused) {
        }
        Z("shutting down");
    }
}