Skip to content

Commit

Permalink
Merge branch 'master' into rxsocks
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Sep 26, 2023
2 parents a7adf61 + 76ba681 commit c93446c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rxlib/src/main/java/org/rx/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public void addWhiteList(InetAddress endpoint) {
if (conf.pcapSourceIp != null
&& InetAddress.getByName(conf.pcapSourceIp).equals(e.getSource().getAddress())) {
log.info("pcap pack {}", e.getSource());
if (conf.pcapUdpDirect) {
e.setUpstream(new Upstream(dstEp));
return;
}
}
// if (conf.pcap2socks && e.getSource().getAddress().isLoopbackAddress()) {
// Cache<String, Boolean> cache = Cache.getInstance(Cache.MEMORY_CACHE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected void channelRead0(ChannelHandlerContext inbound, DefaultSocks5CommandR
pipeline.remove(Socks5CommandRequestDecoder.class.getSimpleName());
pipeline.remove(this);
SocksProxyServer server = SocksContext.server(inbound.channel());
log.debug("socks5[{}] {} {}/{}:{}", server.getConfig().getListenPort(), msg.type(), msg.dstAddrType(), msg.dstAddr(), msg.dstPort());
// log.debug("socks5[{}] {} {}/{}:{}", server.getConfig().getListenPort(), msg.type(), msg.dstAddrType(), msg.dstAddr(), msg.dstPort());

if (server.isAuthEnabled() && ProxyManageHandler.get(inbound).getUser().isAnonymous()) {
inbound.writeAndFlush(new DefaultSocks5CommandResponse(Socks5CommandStatus.FORBIDDEN, msg.dstAddrType())).addListener(ChannelFutureListener.CLOSE);
Expand All @@ -55,6 +55,7 @@ protected void channelRead0(ChannelHandlerContext inbound, DefaultSocks5CommandR
server.raiseEvent(server.onRoute, e);
connect(inbound.channel(), msg.dstAddrType(), e);
} else if (msg.type() == Socks5CommandType.UDP_ASSOCIATE) {
log.info("socks5[{}] UDP_ASSOCIATE {}", server.getConfig().getListenPort(), msg);
pipeline.remove(ProxyChannelIdleHandler.class.getSimpleName());
int max = Math.max(server.config.getUdpReadTimeoutSeconds(), server.config.getUdpWriteTimeoutSeconds());
Tasks.setTimeout(() -> {
Expand All @@ -65,6 +66,7 @@ protected void channelRead0(ChannelHandlerContext inbound, DefaultSocks5CommandR

InetSocketAddress bindEp = (InetSocketAddress) inbound.channel().localAddress();
Socks5AddressType bindAddrType = bindEp.getAddress() instanceof Inet6Address ? Socks5AddressType.IPv6 : Socks5AddressType.IPv4;
// Socks5AddressType bindAddrType = msg.dstAddrType();
inbound.writeAndFlush(new DefaultSocks5CommandResponse(Socks5CommandStatus.SUCCESS, bindAddrType, bindEp.getHostString(), bindEp.getPort()));
// inbound.writeAndFlush(new DefaultSocks5CommandResponse(Socks5CommandStatus.SUCCESS, msg.dstAddrType(), msg.dstAddr(), msg.dstPort()));
} else {
Expand Down

0 comments on commit c93446c

Please sign in to comment.