summaryrefslogtreecommitdiffhomepage
path: root/src/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.go')
-rw-r--r--src/main.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main.go b/src/main.go
index 7c58972..9c76ff4 100644
--- a/src/main.go
+++ b/src/main.go
@@ -1,21 +1,28 @@
package main
import (
+ "fmt"
"log"
"net"
+ "os"
)
-/*
- *
- * TODO: Fix logging
+/* TODO: Fix logging
+ * TODO: Fix daemon
*/
func main() {
+
+ if len(os.Args) != 2 {
+ return
+ }
+ deviceName := os.Args[1]
+
// Open TUN device
// TODO: Fix capabilities
- tun, err := CreateTUN("test0")
+ tun, err := CreateTUN(deviceName)
log.Println(tun, err)
if err != nil {
return
@@ -25,19 +32,17 @@ func main() {
// Start configuration lister
- l, err := net.Listen("unix", "/var/run/wireguard/wg0.sock")
+ socketPath := fmt.Sprintf("/var/run/wireguard/%s.sock", deviceName)
+ l, err := net.Listen("unix", socketPath)
if err != nil {
log.Fatal("listen error:", err)
}
for {
- fd, err := l.Accept()
+ conn, err := l.Accept()
if err != nil {
log.Fatal("accept error:", err)
}
- go func(conn net.Conn) {
- err := ipcListen(device, conn)
- log.Println(err)
- }(fd)
+ go ipcHandle(device, conn)
}
}