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 b9b04c57ac2b585069582450402bb84f49759bfb..67a52d6889e9dd6f3aa5a8cdcc99b6e5302cccd9 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" + + "<html><body><H1>I2P SOCKS PROXY ERROR: REQUEST DENIED</H1>" + + "Your browser is misconfigured. This is a SOCKS proxy, not a HTTP proxy" + + "</body></html>"; + /** * 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) + ")"); }