summaryrefslogtreecommitdiff
path: root/obfs4proxy/obfs4proxy.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-15 06:12:31 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-15 06:12:31 +0000
commit50cc180084f086ccd2a81034a06c51c0fab36ba2 (patch)
treeb0164746fc422d2f7c37a18de7dde074c74109de /obfs4proxy/obfs4proxy.go
parent013c3c7c4d94572e96f763421a6b8c68673fdde6 (diff)
Use os.MkdirAll() for creating the pt state directory.
Diffstat (limited to 'obfs4proxy/obfs4proxy.go')
-rw-r--r--obfs4proxy/obfs4proxy.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index 016a0bb..ff53863 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -297,31 +297,23 @@ func ptIsServer() bool {
return env != ""
}
-func ptGetStateDir() string {
- dir := os.Getenv("TOR_PT_STATE_LOCATION")
+func ptGetStateDir() (dir string, err error) {
+ dir = os.Getenv("TOR_PT_STATE_LOCATION")
if dir == "" {
- return dir
+ return
}
- stat, err := os.Stat(dir)
+ err = os.MkdirAll(dir, 0755)
if err != nil {
- if !os.IsNotExist(err) {
- log.Fatalf("[ERROR] Failed to stat path: %s", err)
- }
- err = os.Mkdir(dir, 0755)
- if err != nil {
- log.Fatalf("[ERROR] Failed to create path: %s", err)
- }
- } else if !stat.IsDir() {
- log.Fatalf("[ERROR] Pluggable Transport state location is not a directory")
+ log.Fatalf("[ERROR] Failed to create path: %s", err)
}
- return dir
+ return
}
func ptInitializeLogging() {
- dir := ptGetStateDir()
- if dir == "" {
+ dir, err := ptGetStateDir()
+ if err != nil || dir == "" {
return
}