org.rx.net.socks.upstream.Socks5UdpUpstream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rxlib Show documentation
Show all versions of rxlib Show documentation
A set of utilities for Java
package org.rx.net.socks.upstream;
import io.netty.channel.Channel;
import lombok.NonNull;
import lombok.SneakyThrows;
import org.rx.exception.InvalidException;
import org.rx.net.AuthenticEndpoint;
import org.rx.net.Sockets;
import org.rx.net.socks.SocksConfig;
import org.rx.net.support.UnresolvedEndpoint;
import org.rx.net.support.UpstreamSupport;
import org.rx.util.function.Func;
public class Socks5UdpUpstream extends Upstream {
final SocksConfig config;
final Func router;
public Socks5UdpUpstream(@NonNull UnresolvedEndpoint dstEp, @NonNull SocksConfig config, @NonNull Func router) {
super(dstEp);
this.config = config;
this.router = router;
}
@SneakyThrows
@Override
public void initChannel(Channel channel) {
UpstreamSupport next = router.invoke();
if (next == null) {
throw new InvalidException("ProxyHandlers is empty");
}
AuthenticEndpoint svrEp = socksServer = next.getEndpoint();
Sockets.addBackendHandler(channel, config, svrEp.getEndpoint());
}
}