Search in sources :

Example 16 with Socks5Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply in project jargyle by jh3nd3rs0n.

the class Socks5Worker method canAllowSocks5Request.

private boolean canAllowSocks5Request(final FirewallRule.Context context) {
    Socks5RequestFirewallRules socks5RequestFirewallRules = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_SOCKS5_REQUEST_FIREWALL_RULES);
    socks5RequestFirewallRules.applyTo(context);
    if (FirewallRuleAction.ALLOW.equals(context.getFirewallRuleAction())) {
        return true;
    }
    Socks5Reply socks5Rep = Socks5Reply.newFailureInstance(Reply.CONNECTION_NOT_ALLOWED_BY_RULESET);
    this.socks5WorkerContext.sendSocks5Reply(this, socks5Rep, LOGGER);
    return false;
}
Also used : Socks5Reply(com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply) Socks5RequestFirewallRules(com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5RequestFirewallRules)

Example 17 with Socks5Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply in project jargyle by jh3nd3rs0n.

the class UdpAssociateCommandWorker method newClientFacingDatagramSocket.

private DatagramSocket newClientFacingDatagramSocket() {
    Host bindHost = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_ON_UDP_ASSOCIATE_CLIENT_FACING_BIND_HOST);
    InetAddress bindInetAddress = bindHost.toInetAddress();
    DatagramSocket clientFacingDatagramSock = null;
    try {
        clientFacingDatagramSock = new DatagramSocket(new InetSocketAddress(bindInetAddress, 0));
    } catch (SocketException e) {
        LOGGER.error(ObjectLogMessageHelper.objectLogMessage(this, "Error in creating the client-facing UDP socket"), e);
        Socks5Reply socks5Rep = Socks5Reply.newFailureInstance(Reply.GENERAL_SOCKS_SERVER_FAILURE);
        this.commandWorkerContext.sendSocks5Reply(this, socks5Rep, LOGGER);
        return null;
    }
    return clientFacingDatagramSock;
}
Also used : SocketException(java.net.SocketException) DatagramSocket(java.net.DatagramSocket) InetSocketAddress(java.net.InetSocketAddress) Socks5Reply(com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply) Host(com.github.jh3nd3rs0n.jargyle.common.net.Host) InetAddress(java.net.InetAddress)

Example 18 with Socks5Reply

use of com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply in project jargyle by jh3nd3rs0n.

the class UdpAssociateCommandWorker method newPeerFacingDatagramSocket.

private DatagramSocket newPeerFacingDatagramSocket() {
    Host bindHost = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_ON_UDP_ASSOCIATE_PEER_FACING_BIND_HOST);
    InetAddress bindInetAddress = bindHost.toInetAddress();
    DatagramSocket peerFacingDatagramSock = null;
    try {
        peerFacingDatagramSock = this.netObjectFactory.newDatagramSocket(new InetSocketAddress(bindInetAddress, 0));
    } catch (SocketException e) {
        LOGGER.error(ObjectLogMessageHelper.objectLogMessage(this, "Error in creating the peer-facing UDP socket"), e);
        Socks5Reply socks5Rep = Socks5Reply.newFailureInstance(Reply.GENERAL_SOCKS_SERVER_FAILURE);
        this.commandWorkerContext.sendSocks5Reply(this, socks5Rep, LOGGER);
        return null;
    }
    return peerFacingDatagramSock;
}
Also used : SocketException(java.net.SocketException) DatagramSocket(java.net.DatagramSocket) InetSocketAddress(java.net.InetSocketAddress) Socks5Reply(com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply) Host(com.github.jh3nd3rs0n.jargyle.common.net.Host) InetAddress(java.net.InetAddress)

Aggregations

Socks5Reply (com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply)18 IOException (java.io.IOException)10 InetAddress (java.net.InetAddress)9 InetSocketAddress (java.net.InetSocketAddress)5 Socket (java.net.Socket)5 Host (com.github.jh3nd3rs0n.jargyle.common.net.Host)4 FirewallRule (com.github.jh3nd3rs0n.jargyle.server.rules.impl.FirewallRule)4 Socks5ReplyFirewallRule (com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5ReplyFirewallRule)4 DatagramSocket (java.net.DatagramSocket)4 UnknownHostException (java.net.UnknownHostException)4 HostResolver (com.github.jh3nd3rs0n.jargyle.client.HostResolver)3 Socks5Request (com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Request)3 SocketException (java.net.SocketException)3 RelayServer (com.github.jh3nd3rs0n.jargyle.server.RelayServer)2 Socks5ReplyFirewallRules (com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5ReplyFirewallRules)2 Reply (com.github.jh3nd3rs0n.jargyle.transport.socks5.Reply)2 ServerSocket (java.net.ServerSocket)2 Properties (com.github.jh3nd3rs0n.jargyle.client.Properties)1 SocketSettings (com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings)1 Socks5RequestFirewallRules (com.github.jh3nd3rs0n.jargyle.server.rules.impl.Socks5RequestFirewallRules)1