This is an automated email from the git hooks/post-receive script.
shelikhoo pushed a commit to branch main in repository pluggable-transports/snowflake.
The following commit(s) were added to refs/heads/main by this push: new 5ef5142 format using go-1.19 5ef5142 is described below
commit 5ef5142bb02b8d274f88b8457d2ef4272f11a181 Author: trinity-1686a trinity@deuxfleurs.fr AuthorDate: Sun Oct 9 16:36:22 2022 +0200
format using go-1.19 --- client/lib/snowflake.go | 1 - common/amp/doc.go | 9 ++++++--- common/encapsulation/encapsulation.go | 22 ++++++++++++++-------- common/messages/client.go | 2 +- common/messages/proxy.go | 2 +- common/safelog/log.go | 2 +- common/safelog/log_test.go | 4 ++-- common/websocketconn/websocketconn_test.go | 6 ++++-- proxy/lib/snowflake.go | 4 ++-- server/lib/snowflake.go | 3 --- server/server.go | 6 +++--- 11 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index 7231d86..c587e6d 100644 --- a/client/lib/snowflake.go +++ b/client/lib/snowflake.go @@ -22,7 +22,6 @@ The Dial function connects to a Snowflake server: // handle error } defer conn.Close() - */ package snowflake_client
diff --git a/common/amp/doc.go b/common/amp/doc.go index 1387114..82e641b 100644 --- a/common/amp/doc.go +++ b/common/amp/doc.go @@ -2,7 +2,7 @@ Package amp provides functions for working with the AMP (Accelerated Mobile Pages) subset of HTML, and conveying binary data through an AMP cache.
-AMP cache +# AMP cache
The CacheURL function takes a plain URL and converts it to be accessed through a given AMP cache. @@ -11,7 +11,9 @@ The EncodePath and DecodePath functions provide a way to encode data into the suffix of a URL path. AMP caches do not support HTTP POST, but encoding data into a URL path with GET is an alternative means of sending data to the server. The format of an encoded path is: + 0<0 or more bytes, including slash>/<base64 of data> + That is: * "0", a format version number, which controls the interpretation of the rest of the path. Only the first byte matters as a version indicator (not the whole @@ -25,12 +27,13 @@ include slash). For example, an encoding of the string "This is path-encoded data." is the following. The "lgWHcwhXFjUm" following the format version number is random padding that will be ignored on decoding. + 0lgWHcwhXFjUm/VGhpcyBpcyBwYXRoLWVuY29kZWQgZGF0YS4
It is the caller's responsibility to add or remove any directory path prefix before calling EncodePath or DecodePath.
-AMP armor +# AMP armor
AMP armor is a data encoding scheme that that satisfies the requirements of the AMP (Accelerated Mobile Pages) subset of HTML, and survives modification by an @@ -63,7 +66,7 @@ limit the amount of text a decoder may have to buffer while parsing the HTML. Each pre element may contain at most 64 KB of text. pre elements may not be nested.
-Example +# Example
The following is the result of encoding the string "This was encoded with AMP armor.": diff --git a/common/encapsulation/encapsulation.go b/common/encapsulation/encapsulation.go index bfe9b5b..aee6a56 100644 --- a/common/encapsulation/encapsulation.go +++ b/common/encapsulation/encapsulation.go @@ -6,23 +6,29 @@ // represents data or padding (1=data, 0=padding). Another bit ("c" for // "continuation") is the indicates whether there are more bytes in the length // prefix. The remaining 6 bits ("x") encode part of the length value. -// dcxxxxxx +// +// dcxxxxxx +// // If the continuation bit is set, then the next byte is also part of the length // prefix. It lacks the "d" bit, has its own "c" bit, and 7 value-carrying bits // ("y"). -// cyyyyyyy +// +// cyyyyyyy +// // The length is decoded by concatenating value-carrying bits, from left to // right, of all value-carrying bits, up to and including the first byte whose // "c" bit is 0. Although in principle this encoding would allow for length // prefixes of any size, length prefixes are arbitrarily limited to 3 bytes and // any attempt to read or write a longer one is an error. These are therefore // the only valid formats: -// 00xxxxxx xxxxxx₂ bytes of padding -// 10xxxxxx xxxxxx₂ bytes of data -// 01xxxxxx 0yyyyyyy xxxxxxyyyyyyy₂ bytes of padding -// 11xxxxxx 0yyyyyyy xxxxxxyyyyyyy₂ bytes of data -// 01xxxxxx 1yyyyyyy 0zzzzzzz xxxxxxyyyyyyyzzzzzzz₂ bytes of padding -// 11xxxxxx 1yyyyyyy 0zzzzzzz xxxxxxyyyyyyyzzzzzzz₂ bytes of data +// +// 00xxxxxx xxxxxx₂ bytes of padding +// 10xxxxxx xxxxxx₂ bytes of data +// 01xxxxxx 0yyyyyyy xxxxxxyyyyyyy₂ bytes of padding +// 11xxxxxx 0yyyyyyy xxxxxxyyyyyyy₂ bytes of data +// 01xxxxxx 1yyyyyyy 0zzzzzzz xxxxxxyyyyyyyzzzzzzz₂ bytes of padding +// 11xxxxxx 1yyyyyyy 0zzzzzzz xxxxxxyyyyyyyzzzzzzz₂ bytes of data +// // The maximum encodable length is 11111111111111111111₂ = 0xfffff = 1048575. // There is no requirement to use a length prefix of minimum size; i.e. 00000100 // and 01000000 00000100 are both valid encodings of the value 4. diff --git a/common/messages/client.go b/common/messages/client.go index af63e08..4adc2a4 100644 --- a/common/messages/client.go +++ b/common/messages/client.go @@ -1,6 +1,6 @@ //Package for communication with the snowflake broker
-//import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages" +// import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages" package messages
import ( diff --git a/common/messages/proxy.go b/common/messages/proxy.go index b135c34..ef53e07 100644 --- a/common/messages/proxy.go +++ b/common/messages/proxy.go @@ -1,6 +1,6 @@ //Package for communication with the snowflake broker
-//import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages" +// import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages" package messages
import ( diff --git a/common/safelog/log.go b/common/safelog/log.go index 6ca23ee..4c7c73b 100644 --- a/common/safelog/log.go +++ b/common/safelog/log.go @@ -1,6 +1,6 @@ //Package for a safer logging wrapper around the standard logging package
-//import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/safelog" +// import "git.torproject.org/pluggable-transports/snowflake.git/v2/common/safelog" package safelog
import ( diff --git a/common/safelog/log_test.go b/common/safelog/log_test.go index 16edbc9..94ca6e5 100644 --- a/common/safelog/log_test.go +++ b/common/safelog/log_test.go @@ -6,7 +6,7 @@ import ( "testing" )
-//Check to make sure that addresses split across calls to write are still scrubbed +// Check to make sure that addresses split across calls to write are still scrubbed func TestLogScrubberSplit(t *testing.T) { input := []byte("test\nhttp2: panic serving [2620:101:f000:780:9097:75b1:519f:dbb8]:58344: interface conversion: *http2.responseWriter is not http.Hijacker: missing method Hijack\n")
@@ -49,7 +49,7 @@ func TestLogScrubberSplit(t *testing.T) {
}
-//Test the log scrubber on known problematic log messages +// Test the log scrubber on known problematic log messages func TestLogScrubberMessages(t *testing.T) { for _, test := range []struct { input, expected string diff --git a/common/websocketconn/websocketconn_test.go b/common/websocketconn/websocketconn_test.go index 92774d4..be00b1f 100644 --- a/common/websocketconn/websocketconn_test.go +++ b/common/websocketconn/websocketconn_test.go @@ -146,7 +146,8 @@ func TestWrite(t *testing.T) {
// Test that multiple goroutines may call Read on a Conn simultaneously. Run // this with -// go test -race +// +// go test -race func TestConcurrentRead(t *testing.T) { s, c, err := connPair() if err != nil { @@ -189,7 +190,8 @@ func TestConcurrentRead(t *testing.T) {
// Test that multiple goroutines may call Write on a Conn simultaneously. Run // this with -// go test -race +// +// go test -race func TestConcurrentWrite(t *testing.T) { s, c, err := connPair() if err != nil { diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go index f9bcddb..8269d61 100644 --- a/proxy/lib/snowflake.go +++ b/proxy/lib/snowflake.go @@ -70,8 +70,8 @@ const ( NATUnrestricted = "unrestricted" )
-//amount of time after sending an SDP answer before the proxy assumes the -//client is not going to connect +// amount of time after sending an SDP answer before the proxy assumes the +// client is not going to connect const dataChannelTimeout = 20 * time.Second
const readLimit = 100000 //Maximum number of bytes to be read from an HTTP request diff --git a/server/lib/snowflake.go b/server/lib/snowflake.go index 44f287f..082e831 100644 --- a/server/lib/snowflake.go +++ b/server/lib/snowflake.go @@ -17,7 +17,6 @@ Transport as follows:
transport := snowflake_server.NewSnowflakeServer(certManager.GetCertificate)
- The Listen function starts a new listener, and Accept will return incoming Snowflake connections:
ln, err := transport.Listen(addr) @@ -31,8 +30,6 @@ The Listen function starts a new listener, and Accept will return incoming Snowf } // handle conn } - - */ package snowflake_server
diff --git a/server/server.go b/server/server.go index 4b53c86..ad08405 100644 --- a/server/server.go +++ b/server/server.go @@ -42,7 +42,7 @@ additional HTTP listener on port 80 to work with ACME. flag.PrintDefaults() }
-//proxy copies data bidirectionally from one connection to another. +// proxy copies data bidirectionally from one connection to another. func proxy(local *net.TCPConn, conn net.Conn) { var wg sync.WaitGroup wg.Add(2) @@ -67,7 +67,7 @@ func proxy(local *net.TCPConn, conn net.Conn) { wg.Wait() }
-//handleConn bidirectionally connects a client snowflake connection with an ORPort. +// handleConn bidirectionally connects a client snowflake connection with an ORPort. func handleConn(conn net.Conn) error { addr := conn.RemoteAddr().String() statsChannel <- addr != "" @@ -80,7 +80,7 @@ func handleConn(conn net.Conn) error { return nil }
-//acceptLoop accepts incoming client snowflake connection and passes them to a handler function. +// acceptLoop accepts incoming client snowflake connection and passes them to a handler function. func acceptLoop(ln net.Listener) { for { conn, err := ln.Accept()
tor-commits@lists.torproject.org