Platform specific tun code

This commit is contained in:
Tiago Carvalho
2022-01-24 22:38:19 +00:00
parent 48531ebdc2
commit b1caae2d87
3 changed files with 8 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build !windows && !linux
// +build !windows,!linux
package tun
@@ -11,7 +11,7 @@ import (
)
// New creates and returns a new TUN interface for the application.
func New(name string, address string) (result *water.Interface, err error) {
func New(name, address string) (result *water.Interface, err error) {
// Setup TUN Config
cfg := water.Config{
DeviceType: water.TUN,

View File

@@ -9,7 +9,7 @@ import (
)
// New creates and returns a new TUN interface for the application.
func New(name string) (result *water.Interface, err error) {
func New(name, address string) (result *water.Interface, err error) {
// Setup TUN Config
cfg := water.Config{
DeviceType: water.TUN,

View File

@@ -4,15 +4,15 @@
package tun
import (
"os/exec"
"net"
"fmt"
"net"
"os/exec"
"github.com/songgao/water"
)
// New creates and returns a new TUN interface for the application.
func New(name string, address string) (result *water.Interface, err error) {
func New(name, address string) (result *water.Interface, err error) {
// TUN on Windows requires address and network to be set on device creation stage
// We also set network to 0.0.0.0/0 so we able to reach networks behind the node
// https://github.com/songgao/water/blob/master/params_windows.go
@@ -23,7 +23,7 @@ func New(name string, address string) (result *water.Interface, err error) {
}
network := net.IPNet{
IP: ip,
Mask: net.IPv4Mask(0,0,0,0),
Mask: net.IPv4Mask(0, 0, 0, 0),
}
// Setup TUN Config
cfg := water.Config{