2017-05-30 22:36:49 +02:00
|
|
|
package main
|
|
|
|
|
2017-06-26 13:14:02 +02:00
|
|
|
import (
|
2017-06-28 23:45:45 +02:00
|
|
|
"log"
|
|
|
|
"net"
|
2017-06-26 13:14:02 +02:00
|
|
|
)
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-28 23:45:45 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* TODO: Fix logging
|
|
|
|
*/
|
|
|
|
|
2017-06-04 21:48:15 +02:00
|
|
|
func main() {
|
2017-06-28 23:45:45 +02:00
|
|
|
// Open TUN device
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-28 23:45:45 +02:00
|
|
|
// TODO: Fix capabilities
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-28 23:45:45 +02:00
|
|
|
tun, err := CreateTUN("test0")
|
|
|
|
log.Println(tun, err)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-28 23:45:45 +02:00
|
|
|
device := NewDevice(tun)
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-28 23:45:45 +02:00
|
|
|
// Start configuration lister
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-05-30 22:36:49 +02:00
|
|
|
l, err := net.Listen("unix", "/var/run/wireguard/wg0.sock")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("listen error:", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
|
|
|
fd, err := l.Accept()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("accept error:", err)
|
|
|
|
}
|
|
|
|
go func(conn net.Conn) {
|
2017-06-28 23:45:45 +02:00
|
|
|
err := ipcListen(device, conn)
|
|
|
|
log.Println(err)
|
2017-05-30 22:36:49 +02:00
|
|
|
}(fd)
|
|
|
|
}
|
|
|
|
}
|