|
|
|
@ -102,28 +102,22 @@ public class ProxyClientContainer implements Container, ChannelStatusListener { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void connectProxyServer() { |
|
|
|
|
bootstrap.connect(config.getStringValue("server.host"), config.getIntValue("server.port")).addListener((ChannelFuture future)->{ |
|
|
|
|
if (future.isSuccess()){ |
|
|
|
|
// 连接成功,向服务器发送客户端认证信息(clientKey)
|
|
|
|
|
ClientChannelMannager.setCmdChannel(future.channel()); |
|
|
|
|
ProxyMessage proxyMessage = new ProxyMessage(); |
|
|
|
|
proxyMessage.setType(ProxyMessage.C_TYPE_AUTH); |
|
|
|
|
proxyMessage.setUri(config.getStringValue("client.key")); |
|
|
|
|
future.channel().writeAndFlush(proxyMessage); |
|
|
|
|
sleepTimeMill = 1000; |
|
|
|
|
logger.info("connect proxy server success, {}", future.channel()); |
|
|
|
|
}else { |
|
|
|
|
logger.warn("connect proxy server failed", future.cause()); |
|
|
|
|
|
|
|
|
|
bootstrap.connect(config.getStringValue("server.host"), config.getIntValue("server.port")).addListener(new ChannelFutureListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void operationComplete(ChannelFuture future) throws Exception { |
|
|
|
|
if (future.isSuccess()) { |
|
|
|
|
|
|
|
|
|
// 连接成功,向服务器发送客户端认证信息(clientKey)
|
|
|
|
|
ClientChannelMannager.setCmdChannel(future.channel()); |
|
|
|
|
ProxyMessage proxyMessage = new ProxyMessage(); |
|
|
|
|
proxyMessage.setType(ProxyMessage.C_TYPE_AUTH); |
|
|
|
|
proxyMessage.setUri(config.getStringValue("client.key")); |
|
|
|
|
future.channel().writeAndFlush(proxyMessage); |
|
|
|
|
sleepTimeMill = 1000; |
|
|
|
|
logger.info("connect proxy server success, {}", future.channel()); |
|
|
|
|
} else { |
|
|
|
|
logger.warn("connect proxy server failed", future.cause()); |
|
|
|
|
|
|
|
|
|
// 连接失败,发起重连
|
|
|
|
|
reconnectWait(); |
|
|
|
|
connectProxyServer(); |
|
|
|
|
} |
|
|
|
|
// 连接失败,发起重连
|
|
|
|
|
reconnectWait(); |
|
|
|
|
connectProxyServer(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|