Add Version Output Support to Snowflake

From now on, there will be a file at common/version/version.go that includes current version number.
This commit is contained in:
Shelikhoo 2022-11-08 14:58:23 +00:00
parent 2c599f8827
commit 33248f3dec
No known key found for this signature in database
GPG key ID: C4D5E79D22B25316
8 changed files with 81 additions and 0 deletions

View file

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
@ -19,6 +20,7 @@ import (
sf "git.torproject.org/pluggable-transports/snowflake.git/v2/client/lib"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/safelog"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/version"
)
const (
@ -157,6 +159,7 @@ func main() {
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
max := flag.Int("max", DefaultSnowflakeCapacity,
"capacity for number of multiplexed WebRTC peers")
versionFlag := flag.Bool("version", false, "display version info to stderr and quit")
// Deprecated
oldLogToStateDir := flag.Bool("logToStateDir", false, "use -log-to-state-dir instead")
@ -164,6 +167,11 @@ func main() {
flag.Parse()
if *versionFlag {
fmt.Fprintf(os.Stderr, "snowflake-client %s", version.ConstructResult())
os.Exit(0)
}
log.SetFlags(log.LstdFlags | log.LUTC)
// Don't write to stderr; versions of tor earlier than about 0.3.5.6 do