Просмотр исходного кода

Fix: transparent DNS forwarding could fail
- Rewritten DNS destination IPs were subject
to the IsLoopback restriction.
- Exhibited when running server_test on
Ubuntu, which runs a local DNS server
at 127.0.0.1

Rod Hynes 9 лет назад
Родитель
Сommit
95c6145f96
2 измененных файлов с 10 добавлено и 3 удалено
  1. 9 2
      psiphon/server/tunnelServer.go
  2. 1 1
      psiphon/server/udp.go

+ 9 - 2
psiphon/server/tunnelServer.go

@@ -1237,10 +1237,14 @@ func (sshClient *sshClient) idleUDPPortForwardTimeout() time.Duration {
 const (
 const (
 	portForwardTypeTCP = iota
 	portForwardTypeTCP = iota
 	portForwardTypeUDP
 	portForwardTypeUDP
+	portForwardTypeTransparentDNS
 )
 )
 
 
 func (sshClient *sshClient) isPortForwardPermitted(
 func (sshClient *sshClient) isPortForwardPermitted(
-	portForwardType int, remoteIP net.IP, port int) bool {
+	portForwardType int,
+	isTransparentDNSForwarding bool,
+	remoteIP net.IP,
+	port int) bool {
 
 
 	sshClient.Lock()
 	sshClient.Lock()
 	defer sshClient.Unlock()
 	defer sshClient.Unlock()
@@ -1251,7 +1255,9 @@ func (sshClient *sshClient) isPortForwardPermitted(
 
 
 	// Disallow connection to loopback. This is a failsafe. The server
 	// Disallow connection to loopback. This is a failsafe. The server
 	// should be run on a host with correctly configured firewall rules.
 	// should be run on a host with correctly configured firewall rules.
-	if remoteIP.IsLoopback() {
+	// And exception is made in the case of tranparent DNS forwarding,
+	// where the remoteIP has been rewritten.
+	if !isTransparentDNSForwarding && remoteIP.IsLoopback() {
 		return false
 		return false
 	}
 	}
 
 
@@ -1423,6 +1429,7 @@ func (sshClient *sshClient) handleTCPChannel(
 	if !isWebServerPortForward &&
 	if !isWebServerPortForward &&
 		!sshClient.isPortForwardPermitted(
 		!sshClient.isPortForwardPermitted(
 			portForwardTypeTCP,
 			portForwardTypeTCP,
+			false,
 			lookupResult.IP,
 			lookupResult.IP,
 			portToConnect) {
 			portToConnect) {
 
 

+ 1 - 1
psiphon/server/udp.go

@@ -163,7 +163,7 @@ func (mux *udpPortForwardMultiplexer) run() {
 			}
 			}
 
 
 			if !mux.sshClient.isPortForwardPermitted(
 			if !mux.sshClient.isPortForwardPermitted(
-				portForwardTypeUDP, dialIP, int(message.remotePort)) {
+				portForwardTypeUDP, message.forwardDNS, dialIP, int(message.remotePort)) {
 				// The udpgw protocol has no error response, so
 				// The udpgw protocol has no error response, so
 				// we just discard the message and read another.
 				// we just discard the message and read another.
 				continue
 				continue