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

Merge branch 'master' of https://github.com/Psiphon-Labs/psiphon-tunnel-core into staging-client

Rod Hynes 9 лет назад
Родитель
Сommit
2e6df64fdb
2 измененных файлов с 46 добавлено и 1 удалено
  1. 39 0
      ConsoleClient/main.go
  2. 7 1
      psiphon/common/tls/handshake_client.go

+ 39 - 0
ConsoleClient/main.go

@@ -20,12 +20,16 @@
 package main
 package main
 
 
 import (
 import (
+	"bytes"
+	"encoding/json"
 	"flag"
 	"flag"
+	"fmt"
 	"io"
 	"io"
 	"io/ioutil"
 	"io/ioutil"
 	"os"
 	"os"
 	"os/signal"
 	"os/signal"
 	"runtime/pprof"
 	"runtime/pprof"
+	"sort"
 	"sync"
 	"sync"
 
 
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon"
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon"
@@ -52,8 +56,43 @@ func main() {
 	var interfaceName string
 	var interfaceName string
 	flag.StringVar(&interfaceName, "listenInterface", "", "Interface Name")
 	flag.StringVar(&interfaceName, "listenInterface", "", "Interface Name")
 
 
+	var versionDetails bool
+	flag.BoolVar(&versionDetails, "version", false, "Print build information and exit")
+	flag.BoolVar(&versionDetails, "v", false, "Print build information and exit")
+
 	flag.Parse()
 	flag.Parse()
 
 
+	if versionDetails {
+		b := common.GetBuildInfo()
+
+		var printableDependencies bytes.Buffer
+		var dependencyMap map[string]string
+		longestRepoUrl := 0
+		json.Unmarshal(b.Dependencies, &dependencyMap)
+
+		sortedRepoUrls := make([]string, 0, len(dependencyMap))
+		for repoUrl := range dependencyMap {
+			repoUrlLength := len(repoUrl)
+			if repoUrlLength > longestRepoUrl {
+				longestRepoUrl = repoUrlLength
+			}
+
+			sortedRepoUrls = append(sortedRepoUrls, repoUrl)
+		}
+		sort.Strings(sortedRepoUrls)
+
+		for repoUrl := range sortedRepoUrls {
+			printableDependencies.WriteString(fmt.Sprintf("    %s  ", sortedRepoUrls[repoUrl]))
+			for i := 0; i < (longestRepoUrl - len(sortedRepoUrls[repoUrl])); i++ {
+				printableDependencies.WriteString(" ")
+			}
+			printableDependencies.WriteString(fmt.Sprintf("%s\n", dependencyMap[sortedRepoUrls[repoUrl]]))
+		}
+
+		fmt.Printf("Psiphon Console Client\n  Build Date: %s\n  Built With: %s\n  Repository: %s\n  Revision: %s\n  Dependencies:\n%s\n", b.BuildDate, b.GoVersion, b.BuildRepo, b.BuildRev, printableDependencies.String())
+		os.Exit(0)
+	}
+
 	// Initialize default Notice output (stderr)
 	// Initialize default Notice output (stderr)
 
 
 	var noticeWriter io.Writer
 	var noticeWriter io.Writer

+ 7 - 1
psiphon/common/tls/handshake_client.go

@@ -120,7 +120,13 @@ NextCipherSuite:
 	// Session resumption is not allowed if renegotiating because
 	// Session resumption is not allowed if renegotiating because
 	// renegotiation is primarily used to allow a client to send a client
 	// renegotiation is primarily used to allow a client to send a client
 	// certificate, which would be skipped if session resumption occurred.
 	// certificate, which would be skipped if session resumption occurred.
-	if sessionCache != nil && c.handshakes == 0 {
+	if sessionCache != nil && c.handshakes == 0 &&
+		// [Psiphon]
+		// Add nil guard as conn.RemoteAddr may be nil. When nil and
+		// when no ServerName for clientSessionCacheKey to use, skip
+		// caching entrely.
+		(c.conn.RemoteAddr() != nil || len(c.config.ServerName) > 0) {
+
 		// Try to resume a previously negotiated TLS session, if
 		// Try to resume a previously negotiated TLS session, if
 		// available.
 		// available.
 		cacheKey = clientSessionCacheKey(c.conn.RemoteAddr(), c.config)
 		cacheKey = clientSessionCacheKey(c.conn.RemoteAddr(), c.config)