From 47e2415d92f9a2aa62e10cfa78c5b76bb638238b Mon Sep 17 00:00:00 2001 From: wxm <115806199+youfanx@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:29:23 +0800 Subject: [PATCH 1/2] Update Main.java --- rxlib/src/main/java/org/rx/Main.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rxlib/src/main/java/org/rx/Main.java b/rxlib/src/main/java/org/rx/Main.java index 65f8a14f..7aaf1341 100644 --- a/rxlib/src/main/java/org/rx/Main.java +++ b/rxlib/src/main/java/org/rx/Main.java @@ -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 cache = Cache.getInstance(Cache.MEMORY_CACHE); From 76ba681e588960c39ab4dc9be197838f348c6405 Mon Sep 17 00:00:00 2001 From: wxm <115806199+youfanx@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:41:47 +0800 Subject: [PATCH 2/2] Update Socks5CommandRequestHandler.java --- .../java/org/rx/net/socks/Socks5CommandRequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rxlib/src/main/java/org/rx/net/socks/Socks5CommandRequestHandler.java b/rxlib/src/main/java/org/rx/net/socks/Socks5CommandRequestHandler.java index 8a9ab6ba..d285a235 100644 --- a/rxlib/src/main/java/org/rx/net/socks/Socks5CommandRequestHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/Socks5CommandRequestHandler.java @@ -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); @@ -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(() -> { @@ -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 {