1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00
wireguard-go/src/main.go

49 lines
663 B
Go
Raw Normal View History

package main
2017-06-26 13:14:02 +02:00
import (
"fmt"
"log"
"net"
"os"
2017-06-26 13:14:02 +02:00
)
/* 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)
// 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)
}
}