blob: b89af17eaee3b4e8d8f0ed2963242bb59c0a31d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package main
import (
"fmt"
"log"
"net"
"os"
)
/* 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(deviceName)
log.Println(tun, err)
if err != nil {
return
}
device := NewDevice(tun, LogLevelDebug)
// 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()
if err != nil {
log.Fatal("accept error:", err)
}
go ipcHandle(device, conn)
}
}
|