http error message

This commit is contained in:
zzz
2009-01-24 17:27:06 +00:00
parent 9a089b7da0
commit d8298c63ab

View File

@ -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) + ")");
}