use of com.github.jh3nd3rs0n.jargyle.transport.socks5.MethodEncapsulation in project jargyle by jh3nd3rs0n.
the class Socks5Client method doMethodSubnegotiation.
protected MethodEncapsulation doMethodSubnegotiation(final Method method, final Socket connectedInternalSocket) throws IOException {
MethodSubnegotiator methodSubnegotiator = MethodSubnegotiator.getInstance(method);
MethodEncapsulation methodEncapsulation = null;
try {
methodEncapsulation = methodSubnegotiator.subnegotiate(connectedInternalSocket, this);
} catch (IOException e) {
SocksClientExceptionThrowingHelper.throwAsSocksClientException(e, this);
}
return new SocksClientExceptionThrowingMethodEncapsulation(this, methodEncapsulation);
}
use of com.github.jh3nd3rs0n.jargyle.transport.socks5.MethodEncapsulation in project jargyle by jh3nd3rs0n.
the class Socks5HostResolver method resolve.
@Override
public InetAddress resolve(final String host) throws IOException {
if (host == null) {
return InetAddress.getLoopbackAddress();
}
Properties properties = this.socks5Client.getProperties();
AddressType addressType = AddressType.valueForString(host);
if (!addressType.equals(AddressType.DOMAINNAME) || !properties.getValue(Socks5PropertySpecConstants.SOCKS5_RESOLVE_USE_RESOLVE_COMMAND).booleanValue()) {
return InetAddress.getByName(host);
}
Socket socket = this.socks5Client.newInternalSocket();
this.socks5Client.configureInternalSocket(socket);
Socket sock = this.socks5Client.getConnectedInternalSocket(socket, true);
Method method = this.socks5Client.negotiateMethod(sock);
MethodEncapsulation methodEncapsulation = this.socks5Client.doMethodSubnegotiation(method, sock);
Socket sck = methodEncapsulation.getSocket();
Socks5Request socks5Req = Socks5Request.newInstance(Command.RESOLVE, host, 0);
this.socks5Client.sendSocks5Request(socks5Req, sck);
Socks5Reply socks5Rep = null;
try {
socks5Rep = this.socks5Client.receiveSocks5Reply(sck);
} catch (FailureSocks5ReplyException e) {
Reply reply = e.getFailureSocks5Reply().getReply();
if (reply.equals(Reply.HOST_UNREACHABLE)) {
throw new UnknownHostException(host);
} else {
throw e;
}
}
InetAddress inetAddress = InetAddress.getByName(socks5Rep.getServerBoundAddress());
return InetAddress.getByAddress(host, inetAddress.getAddress());
}
Aggregations