govpn is simple high-performance secure virtual private network daemon.
It uses DH-EKE for mutual zero-knowledge authentication and
-authenticated encrypted transport.
+authenticated encrypted transport. It runs under GNU/Linux and FreeBSD.
DESCRIPTION
"encoding/hex"
"flag"
"fmt"
+ "io"
"log"
"net"
"time"
"code.google.com/p/go.crypto/poly1305"
"code.google.com/p/go.crypto/salsa20"
- "github.com/chon219/water"
)
var (
S20BS = 64
)
+type TAP interface {
+ io.Reader
+ io.Writer
+}
+
type Peer struct {
addr *net.UDPAddr
key *[KeySize]byte // encryption key
// Interface listening
maxIfacePktSize := *mtu - poly1305.TagSize - NonceSize
log.Println("Max MTU", maxIfacePktSize, "on interface", *ifaceName)
- iface, err := water.NewTAP(*ifaceName)
- if err != nil {
- panic(err)
- }
+ iface := NewTAP(*ifaceName)
ethBuf := make([]byte, maxIfacePktSize)
ethSink := make(chan int)
ethSinkReady := make(chan bool)
peer.nonceRecv = nonceRecv
timeouts = 0
if _, err := iface.Write(buf[S20BS : S20BS+udpPkt.size-NonceSize-poly1305.TagSize]); err != nil {
- log.Println("Error writing to iface")
+ log.Println("Error writing to iface: ", err)
}
if *verbose {
fmt.Print("r")
--- /dev/null
+// +build freebsd
+/*
+govpn -- high-performance secure virtual private network daemon
+Copyright (C) 2014 Sergey Matveev <stargrave@stargrave.org>
+*/
+package main
+
+import (
+ "os"
+ "path"
+)
+
+func NewTAP(ifaceName string) TAP {
+ fd, err := os.OpenFile(path.Join("/dev/", ifaceName), os.O_RDWR, os.ModePerm)
+ if err != nil {
+ panic(err)
+ }
+ return fd
+}
--- /dev/null
+// +build linux
+/*
+govpn -- high-performance secure virtual private network daemon
+Copyright (C) 2014 Sergey Matveev <stargrave@stargrave.org>
+*/
+package main
+
+import (
+ "github.com/chon219/water"
+)
+
+func NewTAP(string ifaceName) TAP {
+ iface, err := water.NewTAP(ifaceName)
+ if err != nil {
+ panic(err)
+ }
+ return iface
+}