forked from I2P_Developers/i2p.i2p
i2ptunnel: More localhost checks
This commit is contained in:
@ -203,7 +203,8 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
|||||||
restofline = request.substring(pos); // ":80 HTTP/1.1" or " HTTP/1.1"
|
restofline = request.substring(pos); // ":80 HTTP/1.1" or " HTTP/1.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host.toLowerCase(Locale.US).endsWith(".i2p")) {
|
String hostLowerCase = host.toLowerCase(Locale.US);
|
||||||
|
if (hostLowerCase.endsWith(".i2p")) {
|
||||||
// Destination gets the host name
|
// Destination gets the host name
|
||||||
destination = host;
|
destination = host;
|
||||||
} else if (host.contains(".") || host.startsWith("[")) {
|
} else if (host.contains(".") || host.startsWith("[")) {
|
||||||
@ -235,7 +236,9 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
|||||||
usingWWWProxy = true;
|
usingWWWProxy = true;
|
||||||
newRequest.append("CONNECT ").append(host).append(restofline).append("\r\n"); // HTTP spec
|
newRequest.append("CONNECT ").append(host).append(restofline).append("\r\n"); // HTTP spec
|
||||||
}
|
}
|
||||||
} else if (host.toLowerCase(Locale.US).equals("localhost")) {
|
} else if (hostLowerCase.equals("localhost") || host.equals("127.0.0.1") ||
|
||||||
|
hostLowerCase.endsWith(".localhost") ||
|
||||||
|
host.startsWith("192.168.") || host.equals("[::1]")) {
|
||||||
writeErrorMessage(ERR_LOCALHOST, out);
|
writeErrorMessage(ERR_LOCALHOST, out);
|
||||||
return;
|
return;
|
||||||
} else { // full b64 address (hopefully)
|
} else { // full b64 address (hopefully)
|
||||||
|
@ -210,7 +210,8 @@ class SOCKS4aServer extends SOCKSServer {
|
|||||||
I2PSocket destSock;
|
I2PSocket destSock;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (connHostName.toLowerCase(Locale.US).endsWith(".i2p")) {
|
String hostLowerCase = connHostName.toLowerCase(Locale.US);
|
||||||
|
if (hostLowerCase.endsWith(".i2p")) {
|
||||||
Destination dest = _context.namingService().lookup(connHostName);
|
Destination dest = _context.namingService().lookup(connHostName);
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
try {
|
try {
|
||||||
@ -224,7 +225,9 @@ class SOCKS4aServer extends SOCKSServer {
|
|||||||
I2PSocketOptions sktOpts = t.buildOptions(overrides);
|
I2PSocketOptions sktOpts = t.buildOptions(overrides);
|
||||||
sktOpts.setPort(connPort);
|
sktOpts.setPort(connPort);
|
||||||
destSock = t.createI2PSocket(dest, sktOpts);
|
destSock = t.createI2PSocket(dest, sktOpts);
|
||||||
} else if ("localhost".equals(connHostName) || "127.0.0.1".equals(connHostName)) {
|
} else if ("localhost".equals(hostLowerCase) || "127.0.0.1".equals(connHostName) ||
|
||||||
|
hostLowerCase.endsWith(".localhost") ||
|
||||||
|
connHostName.startsWith("192.168.") || connHostName.equals("[::1]")) {
|
||||||
String err = "No localhost accesses allowed through the Socks Proxy";
|
String err = "No localhost accesses allowed through the Socks Proxy";
|
||||||
_log.error(err);
|
_log.error(err);
|
||||||
try {
|
try {
|
||||||
|
@ -369,7 +369,8 @@ class SOCKS5Server extends SOCKSServer {
|
|||||||
I2PSocket destSock;
|
I2PSocket destSock;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (connHostName.toLowerCase(Locale.US).endsWith(".i2p")) {
|
String hostLowerCase = connHostName.toLowerCase(Locale.US);
|
||||||
|
if (hostLowerCase.endsWith(".i2p")) {
|
||||||
// Let's not do a new Dest for every request, huh?
|
// Let's not do a new Dest for every request, huh?
|
||||||
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
||||||
//destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
|
//destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
|
||||||
@ -386,7 +387,9 @@ class SOCKS5Server extends SOCKSServer {
|
|||||||
I2PSocketOptions sktOpts = t.buildOptions(overrides);
|
I2PSocketOptions sktOpts = t.buildOptions(overrides);
|
||||||
sktOpts.setPort(connPort);
|
sktOpts.setPort(connPort);
|
||||||
destSock = t.createI2PSocket(dest, sktOpts);
|
destSock = t.createI2PSocket(dest, sktOpts);
|
||||||
} else if ("localhost".equals(connHostName) || "127.0.0.1".equals(connHostName)) {
|
} else if (hostLowerCase.equals("localhost") || connHostName.equals("127.0.0.1") ||
|
||||||
|
hostLowerCase.endsWith(".localhost") ||
|
||||||
|
connHostName.startsWith("192.168.") || connHostName.equals("[::1]")) {
|
||||||
String err = "No localhost accesses allowed through the Socks Proxy";
|
String err = "No localhost accesses allowed through the Socks Proxy";
|
||||||
_log.error(err);
|
_log.error(err);
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user