Add a dummy port number to USERADDR.

Current versions of tor accept USERADDR with or without a port number,
but future versions may become more strict and require the port number.
https://bugs.torproject.org/23080
This commit is contained in:
David Fifield 2017-10-17 21:41:24 -07:00
parent 83f8712078
commit c84e1a2e03

View file

@ -130,12 +130,16 @@ func proxy(local *net.TCPConn, conn *webSocketConn) {
// Return an address string suitable to pass into pt.DialOr. // Return an address string suitable to pass into pt.DialOr.
func clientAddr(clientIPParam string) string { func clientAddr(clientIPParam string) string {
if clientIPParam == "" {
return ""
}
// Check if client addr is a valid IP // Check if client addr is a valid IP
clientIP := net.ParseIP(clientIPParam) clientIP := net.ParseIP(clientIPParam)
if clientIP == nil { if clientIP == nil {
return "" return ""
} }
return clientIPParam // Add a dummy port number. USERADDR requires a port number.
return (&net.TCPAddr{IP: clientIP, Port: 1, Zone: ""}).String()
} }
func webSocketHandler(ws *websocket.WebSocket) { func webSocketHandler(ws *websocket.WebSocket) {