admin管理员组

文章数量:1531454

2024年1月21日发(作者:)

public class SocketCheckThread implements Callable{ private Logger logger = ger();

/** * 等待超时时间 */ private final int SEC_WAIT = 5;

private String ip;

public SocketCheckThread(String ip) { = ip; }

@Override public CheckStatus call() { CheckStatus checkStatus = new CheckStatus(); (ip); tus(check()); return checkStatus; }

private boolean check() { Socket socket = null; try {

Proxy proxy = createProxy(); socket = new Socket(proxy); t(new InetSocketAddress( ,80), SEC_WAIT * 1000); return true; } catch (Exception e) { ("检测超时{}",,e); } finally { try { (); } catch (IOException e) { ("关闭socket失败",sage()); } } return false; }

private static Proxy createProxy() { // 设置认证 String proxyAddr = ip; int proxyPort = port; ault(new Authenticator(){ @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("user", "password".toCharArray()); } });

SocksProxy proxy = (new InetSocketAddress(proxyAddr, proxyPort),5); return proxy; } }

本文标签: 搭建等待失败设置