Rod Hynes 11 лет назад
Родитель
Сommit
f841e1f7d1
2 измененных файлов с 12 добавлено и 2 удалено
  1. 2 0
      psiphon/runTunnel.go
  2. 10 2
      psiphon/tunnel.go

+ 2 - 0
psiphon/runTunnel.go

@@ -59,6 +59,8 @@ func establishTunnelWorker(
 			log.Printf("success connecting to %s", tunnel.serverEntry.IpAddress)
 			select {
 			case firstEstablishedTunnel <- tunnel:
+				log.Printf("selected connection to %s using %s",
+					tunnel.serverEntry.IpAddress, tunnel.protocol)
 			default:
 				tunnel.Close()
 			}

+ 10 - 2
psiphon/tunnel.go

@@ -30,11 +30,17 @@ import (
 	"strings"
 )
 
+const (
+	PROTOCOL_SSH            = "SSH"
+	PROTOCOL_OBFUSCATED_SSH = "OSSH"
+)
+
 // Tunnel is a connection to a Psiphon server. An established
 // tunnel includes a network connection to the specified server
 // and an SSH session built on top of that transport.
 type Tunnel struct {
 	serverEntry *ServerEntry
+	protocol    string
 	conn        *Conn
 	sshClient   *ssh.Client
 	isClosed    bool
@@ -68,11 +74,12 @@ func EstablishTunnel(tunnel *Tunnel) (err error) {
 	}
 	// First connect the transport
 	// TODO: meek
-	sshCapable := Contains(tunnel.serverEntry.Capabilities, "SSH")
-	obfuscatedSshCapable := Contains(tunnel.serverEntry.Capabilities, "OSSH")
+	sshCapable := Contains(tunnel.serverEntry.Capabilities, PROTOCOL_SSH)
+	obfuscatedSshCapable := Contains(tunnel.serverEntry.Capabilities, PROTOCOL_OBFUSCATED_SSH)
 	if !sshCapable && !obfuscatedSshCapable {
 		return fmt.Errorf("server does not have sufficient capabilities")
 	}
+	tunnel.protocol = PROTOCOL_SSH
 	port := tunnel.serverEntry.SshPort
 	conn, err := NewConn(0, CONNECTION_CANDIDATE_TIMEOUT, "")
 	if err != nil {
@@ -81,6 +88,7 @@ func EstablishTunnel(tunnel *Tunnel) (err error) {
 	var netConn net.Conn
 	netConn = conn
 	if obfuscatedSshCapable {
+		tunnel.protocol = PROTOCOL_OBFUSCATED_SSH
 		port = tunnel.serverEntry.SshObfuscatedPort
 		netConn, err = NewObfuscatedSshConn(conn, tunnel.serverEntry.SshObfuscatedKey)
 		if err != nil {