This is an automated email from the git hooks/post-receive script.
shelikhoo pushed a change to branch main in repository pluggable-transports/snowflake.
from 2c599f8 change bandwidth type from int to int64 to prevent overflow new 33248f3 Add Version Output Support to Snowflake new 4ebd85e add version output to log
The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: client/snowflake.go | 10 ++++++++++ common/utls/client_hello_id.go | 8 ++++++++ common/utls/client_hello_id_version.go | 24 ++++++++++++++++++++++++ common/version/combined.go | 5 +++++ common/version/detail.go | 13 +++++++++++++ common/version/version.go | 7 +++++++ proxy/main.go | 10 ++++++++++ server/server.go | 10 ++++++++++ 8 files changed, 87 insertions(+) create mode 100644 common/utls/client_hello_id_version.go create mode 100644 common/version/combined.go create mode 100644 common/version/detail.go create mode 100644 common/version/version.go
This is an automated email from the git hooks/post-receive script.
shelikhoo pushed a commit to branch main in repository pluggable-transports/snowflake.
commit 33248f3dec5594c985cfd11e6c6143ddaa5613c0 Author: Shelikhoo xiaokangwang@outlook.com AuthorDate: Tue Nov 8 14:58:23 2022 +0000
Add Version Output Support to Snowflake
From now on, there will be a file at common/version/version.go that includes current version number. --- client/snowflake.go | 8 ++++++++ common/utls/client_hello_id.go | 8 ++++++++ common/utls/client_hello_id_version.go | 24 ++++++++++++++++++++++++ common/version/combined.go | 5 +++++ common/version/detail.go | 13 +++++++++++++ common/version/version.go | 7 +++++++ proxy/main.go | 8 ++++++++ server/server.go | 8 ++++++++ 8 files changed, 81 insertions(+)
diff --git a/client/snowflake.go b/client/snowflake.go index 2cb6549..e4344e4 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -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 diff --git a/common/utls/client_hello_id.go b/common/utls/client_hello_id.go index 8a13280..c134ecf 100644 --- a/common/utls/client_hello_id.go +++ b/common/utls/client_hello_id.go @@ -36,3 +36,11 @@ func NameToUTLSID(name string) (utls.ClientHelloID, error) { } return utls.ClientHelloID{}, errNameNotFound } + +func ListAllNames() []string { + var names []string + for k, _ := range clientHelloIDMap { + names = append(names, k) + } + return names +} diff --git a/common/utls/client_hello_id_version.go b/common/utls/client_hello_id_version.go new file mode 100644 index 0000000..7228694 --- /dev/null +++ b/common/utls/client_hello_id_version.go @@ -0,0 +1,24 @@ +package utls + +import ( + "git.torproject.org/pluggable-transports/snowflake.git/v2/common/version" + "strings" +) + +func generateVersionOutput() string { + var versionOutputBuilder strings.Builder + + versionOutputBuilder.WriteString(`Known utls-imitate values: +(empty) +`) + + for _, name := range ListAllNames() { + versionOutputBuilder.WriteString(name) + versionOutputBuilder.WriteRune('\n') + } + return versionOutputBuilder.String() +} + +func init() { + version.AddVersionDetail(generateVersionOutput()) +} diff --git a/common/version/combined.go b/common/version/combined.go new file mode 100644 index 0000000..9de74db --- /dev/null +++ b/common/version/combined.go @@ -0,0 +1,5 @@ +package version + +func ConstructResult() string { + return GetVersion() + "\n" + GetVersionDetail() +} diff --git a/common/version/detail.go b/common/version/detail.go new file mode 100644 index 0000000..6965630 --- /dev/null +++ b/common/version/detail.go @@ -0,0 +1,13 @@ +package version + +import "strings" + +var detailBuilder strings.Builder + +func AddVersionDetail(detail string) { + detailBuilder.WriteString(detail) +} + +func GetVersionDetail() string { + return detailBuilder.String() +} diff --git a/common/version/version.go b/common/version/version.go new file mode 100644 index 0000000..4936905 --- /dev/null +++ b/common/version/version.go @@ -0,0 +1,7 @@ +package version + +func GetVersion() string { + return version +} + +var version = "2.3.1" diff --git a/proxy/main.go b/proxy/main.go index 3dad5a9..2218609 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -2,6 +2,7 @@ package main
import ( "flag" + "fmt" "io" "io/ioutil" "log" @@ -12,6 +13,7 @@ import (
"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" sf "git.torproject.org/pluggable-transports/snowflake.git/v2/proxy/lib" )
@@ -31,11 +33,17 @@ func main() { "the time interval to output summary, 0s disables summaries. Valid time units are "s", "m", "h". ") verboseLogging := flag.Bool("verbose", false, "increase log verbosity") ephemeralPortsRangeFlag := flag.String("ephemeral-ports-range", "", "ICE UDP ephemeral ports range (format:"<min>:<max>")") + versionFlag := flag.Bool("version", false, "display version info to stderr and quit")
var ephemeralPortsRange []uint16 = []uint16{0, 0}
flag.Parse()
+ if *versionFlag { + fmt.Fprintf(os.Stderr, "snowflake-proxy %s", version.ConstructResult()) + os.Exit(0) + } + eventLogger := event.NewSnowflakeEventDispatcher()
if *ephemeralPortsRangeFlag != "" { diff --git a/server/server.go b/server/server.go index 6eb5cf7..8b6c7a5 100644 --- a/server/server.go +++ b/server/server.go @@ -19,6 +19,7 @@ import ( "syscall"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/safelog" + "git.torproject.org/pluggable-transports/snowflake.git/v2/common/version" "golang.org/x/crypto/acme/autocert"
pt "git.torproject.org/pluggable-transports/goptlib.git" @@ -130,6 +131,7 @@ func main() { var disableTLS bool var logFilename string var unsafeLogging bool + var versionFlag bool
flag.Usage = usage flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications") @@ -137,8 +139,14 @@ func main() { flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS") flag.StringVar(&logFilename, "log", "", "log file to write to") flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed") + flag.BoolVar(&versionFlag, "unsafe-logging", false, "display version info to stderr and quit") flag.Parse()
+ if versionFlag { + fmt.Fprintf(os.Stderr, "snowflake-server %s", version.ConstructResult()) + os.Exit(0) + } + log.SetFlags(log.LstdFlags | log.LUTC)
var logOutput io.Writer = os.Stderr
This is an automated email from the git hooks/post-receive script.
shelikhoo pushed a commit to branch main in repository pluggable-transports/snowflake.
commit 4ebd85e5d181182a5a3c1e61bdef8abaa92afee0 Author: Shelikhoo xiaokangwang@outlook.com AuthorDate: Tue Nov 22 15:21:30 2022 +0000
add version output to log --- client/snowflake.go | 2 ++ proxy/main.go | 2 ++ server/server.go | 2 ++ 3 files changed, 6 insertions(+)
diff --git a/client/snowflake.go b/client/snowflake.go index e4344e4..7568c4e 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -203,6 +203,8 @@ func main() { log.SetOutput(&safelog.LogScrubber{Output: logOutput}) }
+ log.Printf("snowflake-client %s\n", version.GetVersion()) + iceAddresses := strings.Split(strings.TrimSpace(*iceServersCommas), ",")
config := sf.ClientConfig{ diff --git a/proxy/main.go b/proxy/main.go index 2218609..67274c7 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -117,6 +117,8 @@ func main() { periodicEventLogger := sf.NewProxyEventLogger(*SummaryInterval, eventlogOutput) eventLogger.AddSnowflakeEventListener(periodicEventLogger)
+ log.Printf("snowflake-proxy %s\n", version.GetVersion()) + err := proxy.Start() if err != nil { log.Fatal(err) diff --git a/server/server.go b/server/server.go index 8b6c7a5..ed1e876 100644 --- a/server/server.go +++ b/server/server.go @@ -165,6 +165,8 @@ func main() { log.SetOutput(&safelog.LogScrubber{Output: logOutput}) }
+ log.Printf("snowflake-server %s\n", version.GetVersion()) + if !disableTLS && acmeHostnamesCommas == "" { log.Fatal("the --acme-hostnames option is required") }
tor-commits@lists.torproject.org