summaryrefslogtreecommitdiff
path: root/cmd/tunneld
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/tunneld')
-rw-r--r--cmd/tunneld/main.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/cmd/tunneld/main.go b/cmd/tunneld/main.go
index f713dea..ef274c8 100644
--- a/cmd/tunneld/main.go
+++ b/cmd/tunneld/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "flag"
"log"
"os"
"os/signal"
@@ -8,7 +9,26 @@ import (
"tunnel/pkg/server"
)
+var debugVar bool
+
+func init() {
+ flag.BoolVar(&debugVar, "d", false, "debug: print time and source info")
+}
+
+func initLog() {
+ var logFlags int
+
+ if debugVar {
+ logFlags |= log.Ldate | log.Ltime | log.Lshortfile
+ }
+
+ log.SetFlags(logFlags)
+}
+
func main() {
+ flag.Parse()
+ initLog()
+
var c = make(chan os.Signal)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)