From d8298c63abe61456f6d6653c5c81442871b6a295 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 24 Jan 2009 17:27:06 +0000 Subject: [PATCH] http error message --- .../i2p/i2ptunnel/socks/SOCKSServerFactory.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java index b9b04c57a..67a52d688 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServerFactory.java @@ -7,6 +7,7 @@ package net.i2p.i2ptunnel.socks; import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; @@ -18,6 +19,15 @@ import net.i2p.util.Log; public class SOCKSServerFactory { private final static Log _log = new Log(SOCKSServerFactory.class); + private final static String ERR_REQUEST_DENIED = + "HTTP/1.1 403 Access Denied\r\n" + + "Content-Type: text/html; charset=iso-8859-1\r\n" + + "Cache-control: no-cache\r\n" + + "\r\n" + + "

I2P SOCKS PROXY ERROR: REQUEST DENIED

" + + "Your browser is misconfigured. This is a SOCKS proxy, not a HTTP proxy" + + ""; + /** * Create a new SOCKS server, using the provided socket (that must * be connected to a client) to select the proper SOCKS protocol @@ -38,6 +48,13 @@ public class SOCKSServerFactory { // SOCKS version 5 serv = new SOCKS5Server(s); break; + case 'C': + case 'G': + case 'H': + case 'P': + DataOutputStream out = new DataOutputStream(s.getOutputStream()); + out.write(ERR_REQUEST_DENIED.getBytes()); + throw new SOCKSException("HTTP request to socks"); default: throw new SOCKSException("SOCKS protocol version not supported (" + Integer.toHexString(socksVer) + ")"); }