[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Pass the incoming client_ip into the ExtORPort.



commit 9e5eb7f5ee1c15122425ab4fe47fa6ad6ec75f92
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Sat Oct 14 14:57:53 2017 -0400

    Pass the incoming client_ip into the ExtORPort.
---
 server/server.go | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/server/server.go b/server/server.go
index 3e29a0b..562ccf8 100644
--- a/server/server.go
+++ b/server/server.go
@@ -139,10 +139,18 @@ func webSocketHandler(ws *websocket.WebSocket) {
 		handlerChan <- -1
 	}()
 
-	// Pass an empty string for the client address. The remote address on
-	// the incoming connection reflects that of the browser proxy, not of
-	// the client. See https://bugs.torproject.org/18628.
-	or, err := pt.DialOr(&ptInfo, "", ptMethodName)
+	// Check if client addr is a valid IP
+	addr := ws.Request().URL.Query().Get("client_ip")
+	clientIP := net.ParseIP(addr)
+
+	if clientIP == nil {
+		// Set client addr to empty
+		addr = ""
+	}
+
+	// Pass the address of client as the remote address of incoming connection
+	or, err := pt.DialOr(&ptInfo, addr, ptMethodName)
+
 	if err != nil {
 		log.Printf("failed to connect to ORPort: %s", err)
 		return

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits