|
@@ -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,51 @@ 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 builtWith bytes.Buffer
|
|
|
|
|
+ builtWith.WriteString(b.GoVersion)
|
|
|
|
|
+ if b.GomobileVersion != "" {
|
|
|
|
|
+ builtWith.WriteString(" (")
|
|
|
|
|
+ builtWith.WriteString(b.GomobileVersion)
|
|
|
|
|
+ builtWith.WriteString(")")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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, builtWith.String(), 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
|