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 Dec 9, 2024
2 parents 0af3589 + ee55926 commit 5888b49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ public ProxyChannelIdleHandler(int readerIdleTimeSeconds, int writerIdleTimeSeco
@Override
protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) {
Channel channel = ctx.channel();
if (channel == null) {
return;
}

log.info("{} {} idle: {}", Sockets.protocolName(channel), channel, evt.state());
SocksContext sc = SocksContext.ctx(channel);
if (sc.onClose != null) {
SocksContext sc = SocksContext.ctx(channel, false);
if (sc != null && sc.onClose != null) {
sc.onClose.invoke();
}
super.channelIdle(ctx, evt);
Expand Down
8 changes: 6 additions & 2 deletions rxlib/src/main/java/org/rx/net/socks/SocksContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public final class SocksContext extends EventArgs {
private static final long serialVersionUID = 323020524764860674L;
static final AttributeKey<SocksProxyServer> SERVER = AttributeKey.valueOf("SERVER");
static final AttributeKey<SocksContext> CTX = AttributeKey.valueOf("PROXY_CTX");
private static final AttributeKey<SocksContext> CTX = AttributeKey.valueOf("PROXY_CTX");
//ss
static final AttributeKey<ShadowsocksServer> SS_SERVER = AttributeKey.valueOf("SS_SERVER");

Expand All @@ -56,7 +56,11 @@ public static void mark(Channel inbound, Channel outbound, SocksContext sc, bool
}

public static SocksContext ctx(Channel channel) {
return require(channel.attr(CTX).get());
return ctx(channel, true);
}

public static SocksContext ctx(Channel channel, boolean throwOnEmpty) {
return throwOnEmpty ? require(channel.attr(CTX).get()) : channel.attr(CTX).get();
}

//region common
Expand Down
2 changes: 1 addition & 1 deletion rxlib/src/test/java/org/rx/net/TestSocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void ssProxy() {
SocksUser usr = new SocksUser("rocky");
usr.setPassword(defPwd);
usr.setMaxIpCount(-1);
SocksProxyServer backSvr = new SocksProxyServer(backConf, Authenticator.dbAuth(Collections.singletonList(usr), null));
SocksProxyServer backSvr = new SocksProxyServer(backConf, new DefaultSocksAuthenticator(Collections.singletonList(usr)));

RpcServerConfig rpcServerConf = new RpcServerConfig(new TcpServerConfig(backSrvEp.getPort() + 1));
rpcServerConf.getTcpConfig().setTransportFlags(TransportFlags.FRONTEND_COMPRESS.flags());
Expand Down

0 comments on commit 5888b49

Please sign in to comment.