我正在寻找一个支持身份验证的 java socks 代理客户端类,有什么建议吗?java.net.Proxy 不支持身份验证。
编辑:我似乎找不到通过套接字将身份验证数据附加到特定代理主机的方法。Authenticator.setDefault() 只允许一组凭证。
Authenticator.setDefault(new Authenticator(){
protected PasswordAuthentication getPasswordAuthentication(){
PasswordAuthentication p=new PasswordAuthentication("xxx", "xxx".toCharArray());
return p;
}
});
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("xxx.xx.xxx.xxx", xxx));
Socket sock = new Socket(proxy);
sock.connect(new InetSocketAddress(server,xx));