Search in sources :

Example 1 with SocketSettings

use of com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings in project jargyle by jh3nd3rs0n.

the class WorkerContextFactory method configureClientFacingSocket.

private void configureClientFacingSocket(final Socket clientFacingSock, final Configuration config) throws SocketException {
    Settings settings = config.getSettings();
    SocketSettings socketSettings = settings.getLastValue(GeneralSettingSpecConstants.CLIENT_FACING_SOCKET_SETTINGS);
    socketSettings.applyTo(clientFacingSock);
}
Also used : SocketSettings(com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings) SocketSettings(com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings)

Example 2 with SocketSettings

use of com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings in project jargyle by jh3nd3rs0n.

the class SocksClient method configureInternalSocket.

protected void configureInternalSocket(final Socket internalSocket) throws SocketException {
    SocketSettings socketSettings = this.properties.getValue(GeneralPropertySpecConstants.INTERNAL_SOCKET_SETTINGS);
    socketSettings.applyTo(internalSocket);
}
Also used : SocketSettings(com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings)

Example 3 with SocketSettings

use of com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings in project jargyle by jh3nd3rs0n.

the class ConnectCommandWorker method configureServerFacingSocket.

private boolean configureServerFacingSocket(final Socket serverFacingSocket) {
    SocketSettings socketSettings = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_ON_CONNECT_SERVER_FACING_SOCKET_SETTINGS);
    Host bindHost = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_ON_CONNECT_SERVER_FACING_BIND_HOST);
    InetAddress bindInetAddress = bindHost.toInetAddress();
    try {
        socketSettings.applyTo(serverFacingSocket);
        serverFacingSocket.bind(new InetSocketAddress(bindInetAddress, 0));
    } catch (SocketException e) {
        LOGGER.error(ObjectLogMessageHelper.objectLogMessage(this, "Error in setting the server-facing socket"), e);
        Socks5Reply socks5Rep = Socks5Reply.newFailureInstance(Reply.GENERAL_SOCKS_SERVER_FAILURE);
        this.commandWorkerContext.sendSocks5Reply(this, socks5Rep, LOGGER);
        return false;
    } catch (IOException e) {
        LOGGER.error(ObjectLogMessageHelper.objectLogMessage(this, "Error in binding the server-facing socket"), e);
        Socks5Reply socks5Rep = Socks5Reply.newFailureInstance(Reply.GENERAL_SOCKS_SERVER_FAILURE);
        this.commandWorkerContext.sendSocks5Reply(this, socks5Rep, LOGGER);
        return false;
    }
    return true;
}
Also used : SocketException(java.net.SocketException) InetSocketAddress(java.net.InetSocketAddress) Socks5Reply(com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply) Host(com.github.jh3nd3rs0n.jargyle.common.net.Host) IOException(java.io.IOException) SocketSettings(com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings) InetAddress(java.net.InetAddress)

Aggregations

SocketSettings (com.github.jh3nd3rs0n.jargyle.common.net.SocketSettings)3 Host (com.github.jh3nd3rs0n.jargyle.common.net.Host)1 Socks5Reply (com.github.jh3nd3rs0n.jargyle.transport.socks5.Socks5Reply)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketException (java.net.SocketException)1