commit ff98b14e76c10481c6e82266c7dfea93a4701f97 Author: David Fifield david@bamsoftware.com Date: Tue Dec 10 23:30:13 2013 -0800
Make TOR_PT_ORPORT optional if we have TOR_PT_EXTENDED_SERVER_PORT. --- pt.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/pt.go b/pt.go index d0ce0b8..9ac14e5 100644 --- a/pt.go +++ b/pt.go @@ -532,14 +532,13 @@ func ServerSetup(methodNames []string) (info ServerInfo, err error) { return }
- orPort, err := getenvRequired("TOR_PT_ORPORT") - if err != nil { - return - } - info.OrAddr, err = resolveAddr(orPort) - if err != nil { - err = envError(fmt.Sprintf("cannot resolve TOR_PT_ORPORT %q: %s", orPort, err.Error())) - return + orPort := getenv("TOR_PT_ORPORT") + if orPort != "" { + info.OrAddr, err = resolveAddr(orPort) + if err != nil { + err = envError(fmt.Sprintf("cannot resolve TOR_PT_ORPORT %q: %s", orPort, err.Error())) + return + } }
var extendedOrPort = getenv("TOR_PT_EXTENDED_SERVER_PORT") @@ -559,6 +558,12 @@ func ServerSetup(methodNames []string) (info ServerInfo, err error) { } }
+ // Need either OrAddr or ExtendedOrAddr. + if (info.OrAddr == nil && (info.ExtendedOrAddr == nil || info.AuthCookie == nil)) { + err = envError("need TOR_PT_ORPORT or TOR_PT_EXTENDED_SERVER_PORT environment variable") + return + } + return info, nil }