apache / apache/incubator-seata

NettyClient支持socks代理

Open
#3,147 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

## Why you need it?
基于某些情况,我们的seata 客户端程序不能直连seata服务器。希望可以通过TCP代理进行连接。

## How it could be?
通过调研发现可以通过在NettyClientBootstrap.java 里面133行后面追加一段逻辑解决此问题。参考以下//添加socks5代理 那一块代码
```
bootstrap.handler(
new ChannelInitializer() {
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
// 添加socks5代理
if ( System.getProperty("socksProxySet") == "true" && null != System.getProperty("socksProxyHost") && null != System.getProperty("socksProxyPort")) {
pipeline.addFirst(new Socks5ProxyHandler(new InetSocketAddress(System.getProperty("socksProxyHost"), System.getProperty("socksProxyPort")), "", ""));
}

pipeline.addLast(
new IdleStateHandler(nettyClientConfig.getChannelMaxReadIdleSeconds(),
nettyClientConfig.getChannelMaxWriteIdleSeconds(),
nettyClientConfig.getChannelMaxAllIdleSeconds()))
.addLast(new ProtocolV1Decoder())
.addLast(new ProtocolV1Encoder());
if (channelHandlers != null) {
addChannelPipelineLast(ch, channelHandlers);
}
}
});

if (initialized.compareAndSet(false, true) && LOGGER.isInfoEnabled()) {
LOGGER.info("NettyClientBootstrap has started");
}
}
```

## Other related information
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Research direction

Start in NettyClientBootstrap.java around the referenced line 133 and inspect how the Netty channel pipeline is initialized. Verify how the SOCKS proxy system properties should control a Socks5ProxyHandler and how it fits with the existing handlers. Done means NettyClient can connect through the configured SOCKS5 proxy without disrupting the existing pipeline.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.