Commit f0b8a068 authored by Andreas Kempe's avatar Andreas Kempe
Browse files

Send error reply on unsupported SOCKS method

No other methods than connect are supported. Relply with an error
message if the client requests any other method.
parent 9e927964
......@@ -88,7 +88,7 @@ actor Proxy is ProxyInterface
res = res + (address and 0xFFFF).string()
res
fun _new_connection(msg: SocksRequestMessage) =>
fun ref _new_connection(msg: SocksRequestMessage) =>
var address: String
address =
......@@ -108,6 +108,10 @@ actor Proxy is ProxyInterface
TCPConnection(_auth, recover SocksNotifier(this) end,
address,
msg.destination_port.string())
else
try
(_socks_relay as SocksRelay)._reply_not_supported()
end
end
be relay(from: TCPConnection tag, data: Array[U8 val] val) =>
......@@ -126,7 +130,7 @@ actor Proxy is ProxyInterface
be socks_failed(conn: TCPConnection tag, err: U8) =>
try
let r = _socks_relay as SocksRelay
r.connection_failed(conn, err)
r.connection_failed(err)
else
_out.print("Connection failed, but no relay active!")
end
......
......@@ -396,7 +396,7 @@ class SocksRelay
addr, local_port)
msg.send(_connection)
fun ref connection_failed(conn: TCPConnection tag, err: U8) =>
fun ref connection_failed(err: U8) =>
_out.print("Connection failed")
try
let msg = SocksRequestReplyMessage(SocksErrors(err)?, SocksAddrIPv4,
......@@ -406,7 +406,13 @@ class SocksRelay
_out.print("Could not send error message. Incorrect error
type: " + err.string())
end
_out.print("Closing connections")
kill()
fun ref _reply_not_supported() =>
_out.print("SOCKS command not supported")
let msg = SocksRequestReplyMessage(SocksCommandNotSupported,
SocksAddrIPv4, U32(0), 0)
msg.send(_connection)
kill()
fun ref kill() =>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment