流利说-英语 v8.47.26版本的 MD5 值为:0079dce5ff96e6cdbc95c261b3f51387

以下内容为反编译后的 i.java 源代码,内容仅作参考


package com.danikula.videocache;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Arrays;
import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class i {
    private static final org.slf4j.b HQ = org.slf4j.c.wJ("Pinger");
    private final ExecutorService If = Executors.newSingleThreadExecutor();
    private final String host;
    private final int port;

    public i(String str, int i) {
        this.host = (String) j.checkNotNull(str);
        this.port = i;
    }

    public boolean s(int i, int i2) {
        j.checkArgument(i >= 1);
        j.checkArgument(i2 > 0);
        int i3 = i2;
        int i4 = 0;
        while (i4 < i) {
            try {
            } catch (InterruptedException e) {
                e = e;
                HQ.error("Error pinging server due to unexpected error", e);
            } catch (ExecutionException e2) {
                e = e2;
                HQ.error("Error pinging server due to unexpected error", e);
            } catch (TimeoutException unused) {
                HQ.warn("Error pinging server (attempt: " + i4 + ", timeout: " + i3 + "). ");
            }
            if (((Boolean) this.If.submit(new a()).get(i3, TimeUnit.MILLISECONDS)).booleanValue()) {
                return true;
            }
            i4++;
            i3 *= 2;
        }
        String format = String.format("Error pinging server (attempts: %d, max timeout: %d). If you see this message, please, email me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues", Integer.valueOf(i4), Integer.valueOf(i3 / 2));
        HQ.error(format, (Throwable) new ProxyCacheException(format));
        return false;
    }

    public boolean ba(String str) {
        return "ping".equals(str);
    }

    public void g(Socket socket) throws IOException {
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("HTTP/1.1 200 OK\n\n".getBytes());
        outputStream.write("ping ok".getBytes());
    }

    public boolean kr() throws ProxyCacheException {
        h hVar = new h(ks());
        try {
            byte[] bytes = "ping ok".getBytes();
            hVar.as(0);
            byte[] bArr = new byte[bytes.length];
            hVar.read(bArr);
            boolean equals = Arrays.equals(bytes, bArr);
            HQ.info("Ping response: `" + new String(bArr) + "`, pinged? " + equals);
            return equals;
        } catch (ProxyCacheException e) {
            HQ.error("Error reading ping response", (Throwable) e);
            return false;
        } finally {
            hVar.close();
        }
    }

    private String ks() {
        return String.format(Locale.US, "http://%s:%d/%s", this.host, Integer.valueOf(this.port), "ping");
    }

    private class a implements Callable<Boolean> {
        private a() {
        }

        @Override
        public Boolean call() throws Exception {
            return Boolean.valueOf(i.this.kr());
        }
    }
}