mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 06:01:37 +00:00
Add BSD support (openbsd, freebsd, solaris)
This commit is contained in:
parent
ebc4eacee4
commit
f8dda26dba
@ -7,7 +7,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/songgao/water"
|
"github.com/neilalexander/water"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mtu = 65535
|
const mtu = 65535
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/songgao/water"
|
"github.com/neilalexander/water"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mtu = 65535
|
const mtu = 65535
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/songgao/water"
|
"github.com/neilalexander/water"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mtu = 65535
|
const mtu = 65535
|
||||||
|
29
src/yggdrasil/tun_bsd.go
Normal file
29
src/yggdrasil/tun_bsd.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// +build openbsd freebsd solaris
|
||||||
|
|
||||||
|
package yggdrasil
|
||||||
|
|
||||||
|
import water "github.com/neilalexander/water"
|
||||||
|
|
||||||
|
// This is to catch BSD platforms
|
||||||
|
|
||||||
|
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
|
||||||
|
var config water.Config
|
||||||
|
if iftapmode {
|
||||||
|
config = water.Config{DeviceType: water.TAP}
|
||||||
|
} else {
|
||||||
|
config = water.Config{DeviceType: water.TUN}
|
||||||
|
}
|
||||||
|
config.Name = ifname
|
||||||
|
iface, err := water.New(config)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
tun.iface = iface
|
||||||
|
tun.mtu = mtu //1280 // Lets default to the smallest thing allowed for now
|
||||||
|
return tun.setupAddress(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tun *tunDevice) setupAddress(addr string) error {
|
||||||
|
tun.core.log.Println("Platform not supported, you must set the address of", tun.iface.Name(), "to", addr)
|
||||||
|
return nil
|
||||||
|
}
|
@ -8,7 +8,7 @@ import "strconv"
|
|||||||
import "encoding/binary"
|
import "encoding/binary"
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
import water "github.com/songgao/water"
|
import water "github.com/neilalexander/water"
|
||||||
|
|
||||||
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
|
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
|
||||||
if iftapmode {
|
if iftapmode {
|
||||||
|
@ -7,7 +7,7 @@ import "fmt"
|
|||||||
import "os/exec"
|
import "os/exec"
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
import water "github.com/songgao/water"
|
import water "github.com/neilalexander/water"
|
||||||
|
|
||||||
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
|
func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) error {
|
||||||
var config water.Config
|
var config water.Config
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// +build !linux
|
// +build !linux
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
// +build !openbsd
|
||||||
|
// +build !freebsd
|
||||||
|
// +build !solaris
|
||||||
|
|
||||||
package yggdrasil
|
package yggdrasil
|
||||||
|
|
||||||
import water "github.com/songgao/water"
|
import water "github.com/neilalexander/water"
|
||||||
|
|
||||||
// This is to catch unsupported platforms
|
// This is to catch unsupported platforms
|
||||||
// If your platform supports tun devices, you could try configuring it manually
|
// If your platform supports tun devices, you could try configuring it manually
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package yggdrasil
|
package yggdrasil
|
||||||
|
|
||||||
import water "github.com/songgao/water"
|
import water "github.com/neilalexander/water"
|
||||||
import "os/exec"
|
import "os/exec"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
Loading…
Reference in New Issue
Block a user