[tor-commits] [obfs4/master] Delay transport initialization till after logging has been setup.
yawning at torproject.org
yawning at torproject.org
Mon Jun 1 16:16:13 UTC 2015
commit 69ffcc39c63f4a9a192082da71eea6b06a1e75d7
Author: Yawning Angel <yawning at torproject.org>
Date: Mon Jun 1 16:15:35 2015 +0000
Delay transport initialization till after logging has been setup.
---
ChangeLog | 2 ++
obfs4proxy/obfs4proxy.go | 4 ++++
transports/transports.go | 11 +++++------
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 15de989..774be88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
Changes in version 0.0.6 - UNRELEASED:
+ - Delay transport factory initialization till after logging has been
+ initialized.
Changes in version 0.0.5 - 2015-04-15:
- Go vet/fmt fixes, and misc. code cleanups. Patches by mvdan.
diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index 5f7f171..a817583 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -347,6 +347,10 @@ func main() {
if err = log.Init(*enableLogging, path.Join(stateDir, obfs4proxyLogFile), *unsafeLogging); err != nil {
golog.Fatalf("[ERROR]: %s - failed to initialize logging", execName)
}
+ if err = transports.Init(); err != nil {
+ log.Errorf("%s - failed to initialize transports: %s", execName, err)
+ os.Exit(-1)
+ }
log.Noticef("%s - launched", getVersion())
diff --git a/transports/transports.go b/transports/transports.go
index ba4e099..e35673b 100644
--- a/transports/transports.go
+++ b/transports/transports.go
@@ -41,7 +41,7 @@ import (
)
var transportMapLock sync.Mutex
-var transportMap map[string]base.Transport
+var transportMap map[string]base.Transport = make(map[string]base.Transport)
// Register registers a transport protocol.
func Register(transport base.Transport) error {
@@ -81,13 +81,12 @@ func Get(name string) base.Transport {
return t
}
-func init() {
- // Initialize the transport list.
- transportMap = make(map[string]base.Transport)
-
- // Register all the currently supported transports.
+// Init initializes all of the integrated transports.
+func Init() error {
Register(new(obfs2.Transport))
Register(new(obfs3.Transport))
Register(new(obfs4.Transport))
Register(new(scramblesuit.Transport))
+
+ return nil
}
More information about the tor-commits
mailing list