diff --git a/examples/listener/listener.go b/examples/listener/listener.go index 36709ea..23ae231 100644 --- a/examples/listener/listener.go +++ b/examples/listener/listener.go @@ -56,7 +56,7 @@ func main() { log.Printf("Expected ID: %v", id) cfg := &bulb.NewOnionConfig{ - DiscardPK: true, + DiscardPK: true, PrivateKey: pk, } l, err := c.NewListener(cfg, 80) diff --git a/listener.go b/listener.go index 399beae..d8bba8f 100644 --- a/listener.go +++ b/listener.go @@ -8,14 +8,15 @@ package bulb import ( + "crypto" goodrand "crypto/rand" + "encoding/binary" "fmt" - "net" - "strconv" "golang.org/x/crypto/sha3" - "encoding/binary" - "crypto" - ) + "log" + "net" + "strconv" +) type onionAddr struct { info *OnionInfo @@ -86,6 +87,7 @@ func (c *Conn) RecoverListener(config *NewOnionConfig, onion string, vports ...u if port < 1024 { // this is not uniformly random, but we don't need it to be port += 1024 } + log.Printf("using local port: %d\n", port) var loopbackAddr = "127.0.0.1:" + strconv.Itoa(port) // Listen on the loopback interface. diff --git a/status.go b/status.go index c0971c5..21f2b21 100644 --- a/status.go +++ b/status.go @@ -9,8 +9,8 @@ package bulb import ( "fmt" - "strings" "net/textproto" + "strings" ) // The various control port StatusCode constants. diff --git a/utils/utils.go b/utils/utils.go index d741a8b..a01ae28 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -18,19 +18,19 @@ import ( // SplitQuoted splits s by sep if it is found outside substring // quoted by quote. func SplitQuoted(s string, quote, sep rune) (splitted []string) { - quoteFlag := false + quoteFlag := false NewSubstring: - for i, c := range s { - if c == quote { - quoteFlag = !quoteFlag - } - if c == sep && !quoteFlag { - splitted = append(splitted, s[:i]) - s = s[i+1:] - goto NewSubstring - } - } - return append(splitted, s) + for i, c := range s { + if c == quote { + quoteFlag = !quoteFlag + } + if c == sep && !quoteFlag { + splitted = append(splitted, s[:i]) + s = s[i+1:] + goto NewSubstring + } + } + return append(splitted, s) } // ParseControlPortString parses a string representation of a control port