use of com.github.jh3nd3rs0n.jargyle.transport.socks5.ServerMethodSelectionMessage in project jargyle by jh3nd3rs0n.
the class Socks5Client method negotiateMethod.
protected Method negotiateMethod(final Socket connectedInternalSocket) throws IOException {
Methods methods = this.getProperties().getValue(Socks5PropertySpecConstants.SOCKS5_METHODS);
ClientMethodSelectionMessage cmsm = ClientMethodSelectionMessage.newInstance(methods);
Method method = null;
try {
InputStream inputStream = connectedInternalSocket.getInputStream();
OutputStream outputStream = connectedInternalSocket.getOutputStream();
outputStream.write(cmsm.toByteArray());
outputStream.flush();
ServerMethodSelectionMessage smsm = ServerMethodSelectionMessage.newInstanceFrom(inputStream);
method = smsm.getMethod();
} catch (IOException e) {
SocksClientExceptionThrowingHelper.throwAsSocksClientException(e, this);
}
return method;
}
use of com.github.jh3nd3rs0n.jargyle.transport.socks5.ServerMethodSelectionMessage in project jargyle by jh3nd3rs0n.
the class Socks5Worker method negotiateMethod.
private Method negotiateMethod() {
InputStream in = new SequenceInputStream(new ByteArrayInputStream(new byte[] { Version.V5.byteValue() }), this.clientFacingInputStream);
ClientMethodSelectionMessage cmsm = null;
try {
cmsm = ClientMethodSelectionMessage.newInstanceFrom(in);
} catch (IOException e) {
ClientFacingIOExceptionLoggingHelper.log(LOGGER, ObjectLogMessageHelper.objectLogMessage(this, "Error in parsing the method selection message " + "from the client"), e);
return null;
}
LOGGER.debug(ObjectLogMessageHelper.objectLogMessage(this, "Received %s", cmsm.toString()));
Method method = null;
Methods methods = this.settings.getLastValue(Socks5SettingSpecConstants.SOCKS5_METHODS);
for (Method meth : methods.toList()) {
if (cmsm.getMethods().contains(meth)) {
method = meth;
break;
}
}
if (method == null) {
method = Method.NO_ACCEPTABLE_METHODS;
}
ServerMethodSelectionMessage smsm = ServerMethodSelectionMessage.newInstance(method);
LOGGER.debug(ObjectLogMessageHelper.objectLogMessage(this, "Sending %s", smsm.toString()));
try {
this.socks5WorkerContext.writeThenFlush(smsm.toByteArray());
} catch (IOException e) {
ClientFacingIOExceptionLoggingHelper.log(LOGGER, ObjectLogMessageHelper.objectLogMessage(this, "Error in writing the method selection message to " + "the client"), e);
return null;
}
return smsm.getMethod();
}
Aggregations