Search in sources :

Example 1 with WorkerContext

use of com.github.jh3nd3rs0n.jargyle.server.WorkerContext in project jargyle by jh3nd3rs0n.

the class Socks5Worker method run.

public void run() throws IOException {
    this.clientFacingInputStream = this.clientFacingSocket.getInputStream();
    Method method = this.negotiateMethod();
    if (method == null) {
        return;
    }
    MethodSubnegotiationResults methodSubnegotiationResults = this.doMethodSubnegotiation(method);
    if (methodSubnegotiationResults == null) {
        return;
    }
    Socket socket = methodSubnegotiationResults.getSocket();
    this.clientFacingInputStream = socket.getInputStream();
    this.clientFacingSocket = socket;
    this.socks5WorkerContext = new Socks5WorkerContext(new WorkerContext(this.clientFacingSocket, this.socks5WorkerContext.getConfiguration(), this.socks5WorkerContext.getRoute(), this.socks5WorkerContext.getRoutes(), this.socks5WorkerContext.getClientFacingDtlsDatagramSocketFactory()));
    Socks5Request socks5Request = this.newSocks5Request();
    if (socks5Request == null) {
        return;
    }
    if (!this.canAllowSocks5Request(new Socks5RequestFirewallRule.Context(this.clientFacingSocket.getInetAddress().getHostAddress(), this.clientFacingSocket.getLocalAddress().getHostAddress(), methodSubnegotiationResults, socks5Request))) {
        return;
    }
    Route route = this.selectRoute(new Socks5RequestRoutingRule.Context(this.clientFacingSocket.getInetAddress().getHostAddress(), this.clientFacingSocket.getLocalAddress().getHostAddress(), methodSubnegotiationResults, socks5Request, this.socks5WorkerContext.getRoutes()));
    if (route == null) {
        return;
    }
    this.socks5WorkerContext = new Socks5WorkerContext(new WorkerContext(this.socks5WorkerContext.getClientFacingSocket(), this.socks5WorkerContext.getConfiguration(), route, this.socks5WorkerContext.getRoutes(), this.socks5WorkerContext.getClientFacingDtlsDatagramSocketFactory()));
    Socks5RequestWorkerContext socks5RequestWorkerContext = new Socks5RequestWorkerContext(this.socks5WorkerContext, methodSubnegotiationResults, socks5Request);
    Socks5RequestWorker socks5RequestWorker = this.newSocks5RequestWorker(socks5RequestWorkerContext);
    socks5RequestWorker.run();
}
Also used : WorkerContext(com.github.jh3nd3rs0n.jargyle.server.WorkerContext) Socks5Request(com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Request) Method(com.github.jh3nd3rs0n.jargyle.transport.socks5.Method) WorkerContext(com.github.jh3nd3rs0n.jargyle.server.WorkerContext) Socks5RequestRoutingRule(com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5RequestRoutingRule) Socket(java.net.Socket) Route(com.github.jh3nd3rs0n.jargyle.server.Route)

Aggregations

Route (com.github.jh3nd3rs0n.jargyle.server.Route)1 WorkerContext (com.github.jh3nd3rs0n.jargyle.server.WorkerContext)1 Socks5RequestRoutingRule (com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5RequestRoutingRule)1 Method (com.github.jh3nd3rs0n.jargyle.transport.socks5.Method)1 Socks5Request (com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Request)1 Socket (java.net.Socket)1