Pass the incoming client_ip into the ExtORPort.

This commit is contained in:
David Fifield 2017-10-14 14:57:53 -04:00
parent eca7ebb265
commit 9e5eb7f5ee

View file

@ -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