All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.net.socks.upstream.Socks5UdpUpstream Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy