导航菜单

页面标题

页面副标题

Chaupal v3.2 - k1.java 源代码

正在查看: Chaupal v3.2 应用的 k1.java JAVA 源代码文件

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


package io.grpc.internal;

import io.grpc.HttpConnectProxiedSocketAddress;
import io.grpc.ProxiedSocketAddress;
import java.io.IOException;
import java.net.Authenticator;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import okhttp3.HttpUrl;

class k1 implements io.grpc.u0 {
    private static final Logger d = Logger.getLogger(k1.class.getName());
    private static final c e = new a();
    private static final com.google.common.base.q<ProxySelector> f = new b();
    private final com.google.common.base.q<ProxySelector> a;
    private final c b;
    private final InetSocketAddress c;

    class a implements c {
        a() {
        }

        @Override
        public PasswordAuthentication a(String str, InetAddress inetAddress, int i, String str2, String str3, String str4) {
            URL url;
            try {
                url = new URL(str2, str, i, HttpUrl.FRAGMENT_ENCODE_SET);
            } catch (MalformedURLException unused) {
                k1.d.log(Level.WARNING, String.format("failed to create URL for Authenticator: %s %s", str2, str));
                url = null;
            }
            return Authenticator.requestPasswordAuthentication(str, inetAddress, i, str2, str3, str4, url, Authenticator.RequestorType.PROXY);
        }
    }

    class b implements com.google.common.base.q<ProxySelector> {
        b() {
        }

        public ProxySelector get() {
            return ProxySelector.getDefault();
        }
    }

    interface c {
        PasswordAuthentication a(String str, InetAddress inetAddress, int i, String str2, String str3, String str4);
    }

    public k1() {
        this(f, e, System.getenv("GRPC_PROXY_EXP"));
    }

    private ProxiedSocketAddress c(InetSocketAddress inetSocketAddress) throws IOException {
        try {
            URI uri = new URI("https", null, GrpcUtil.h(inetSocketAddress), inetSocketAddress.getPort(), null, null, null);
            ProxySelector proxySelector = (ProxySelector) this.a.get();
            if (proxySelector == null) {
                d.log(Level.FINE, "proxy selector is null, so continuing without proxy lookup");
                return null;
            }
            List<Proxy> select = proxySelector.select(uri);
            if (select.size() > 1) {
                d.warning("More than 1 proxy detected, gRPC will select the first one");
            }
            Proxy proxy = select.get(0);
            if (proxy.type() == Proxy.Type.DIRECT) {
                return null;
            }
            InetSocketAddress inetSocketAddress2 = (InetSocketAddress) proxy.address();
            PasswordAuthentication a2 = this.b.a(GrpcUtil.h(inetSocketAddress2), inetSocketAddress2.getAddress(), inetSocketAddress2.getPort(), "https", HttpUrl.FRAGMENT_ENCODE_SET, null);
            if (inetSocketAddress2.isUnresolved()) {
                inetSocketAddress2 = new InetSocketAddress(InetAddress.getByName(inetSocketAddress2.getHostName()), inetSocketAddress2.getPort());
            }
            HttpConnectProxiedSocketAddress.b c2 = HttpConnectProxiedSocketAddress.newBuilder().d(inetSocketAddress).c(inetSocketAddress2);
            if (a2 == null) {
                return c2.a();
            }
            return c2.e(a2.getUserName()).b(a2.getPassword() != null ? new String(a2.getPassword()) : null).a();
        } catch (URISyntaxException e2) {
            d.log(Level.WARNING, "Failed to construct URI for proxy lookup, proceeding without proxy", (Throwable) e2);
            return null;
        }
    }

    private static InetSocketAddress d(String str) {
        if (str == null) {
            return null;
        }
        String[] split = str.split(":", 2);
        int parseInt = split.length > 1 ? Integer.parseInt(split[1]) : 80;
        d.warning("Detected GRPC_PROXY_EXP and will honor it, but this feature will be removed in a future release. Use the JVM flags \"-Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT\" to set the https proxy for this JVM.");
        return new InetSocketAddress(split[0], parseInt);
    }

    @Override
    public ProxiedSocketAddress a(SocketAddress socketAddress) throws IOException {
        if (socketAddress instanceof InetSocketAddress) {
            return this.c != null ? HttpConnectProxiedSocketAddress.newBuilder().c(this.c).d((InetSocketAddress) socketAddress).a() : c((InetSocketAddress) socketAddress);
        }
        return null;
    }

    k1(com.google.common.base.q<ProxySelector> qVar, c cVar, String str) {
        this.a = (com.google.common.base.q) com.google.common.base.l.o(qVar);
        this.b = (c) com.google.common.base.l.o(cVar);
        if (str != null) {
            this.c = d(str);
        } else {
            this.c = null;
        }
    }
}