aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.go')
-rw-r--r--src/main.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/main.go b/src/main.go
index 50140e3..dc27472 100644
--- a/src/main.go
+++ b/src/main.go
@@ -5,6 +5,7 @@ import (
"log"
"net"
"os"
+ "runtime"
)
/* TODO: Fix logging
@@ -18,6 +19,10 @@ func main() {
}
deviceName := os.Args[1]
+ // increase number of go workers (for Go <1.5)
+
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
// open TUN device
tun, err := CreateTUN(deviceName)
@@ -31,17 +36,21 @@ func main() {
// start configuration lister
- socketPath := fmt.Sprintf("/var/run/wireguard/%s.sock", deviceName)
- l, err := net.Listen("unix", socketPath)
- if err != nil {
- log.Fatal("listen error:", err)
- }
-
- for {
- conn, err := l.Accept()
+ go func() {
+ socketPath := fmt.Sprintf("/var/run/wireguard/%s.sock", deviceName)
+ l, err := net.Listen("unix", socketPath)
if err != nil {
- log.Fatal("accept error:", err)
+ log.Fatal("listen error:", err)
}
- go ipcHandle(device, conn)
- }
+
+ for {
+ conn, err := l.Accept()
+ if err != nil {
+ log.Fatal("accept error:", err)
+ }
+ go ipcHandle(device, conn)
+ }
+ }()
+
+ device.Wait()
}