2017-05-30 22:36:49 +02:00
|
|
|
package main
|
|
|
|
|
2017-06-26 13:14:02 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2017-06-04 21:48:15 +02:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
fd, err := CreateTUN("test0")
|
|
|
|
fmt.Println(fd, err)
|
|
|
|
|
|
|
|
queue := make(chan []byte, 1000)
|
|
|
|
|
2017-06-26 13:14:02 +02:00
|
|
|
// var device Device
|
2017-06-04 21:48:15 +02:00
|
|
|
|
2017-06-26 13:14:02 +02:00
|
|
|
// go OutgoingRoutingWorker(&device, queue)
|
2017-06-04 21:48:15 +02:00
|
|
|
|
|
|
|
for {
|
|
|
|
tmp := make([]byte, 1<<16)
|
|
|
|
n, err := fd.Read(tmp)
|
|
|
|
if err != nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
queue <- tmp[:n]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2017-05-30 22:36:49 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
func main() {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
var dev Device
|
|
|
|
go func(conn net.Conn) {
|
|
|
|
err := ipcListen(&dev, conn)
|
|
|
|
fmt.Println(err)
|
|
|
|
}(fd)
|
|
|
|
}
|
|
|
|
}
|
2017-06-04 21:48:15 +02:00
|
|
|
*/
|