-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add windows support and update wireguard-go deps
- Loading branch information
Showing
7 changed files
with
152 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build linux darwin | ||
|
||
package iface | ||
|
||
import ( | ||
"golang.zx2c4.com/wireguard/ipc" | ||
"net" | ||
) | ||
|
||
// getUAPI returns a Listener | ||
func getUAPI(iface string) (net.Listener, error) { | ||
tunSock, err := ipc.UAPIOpen(iface) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ipc.UAPIListen(iface, tunSock) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package iface | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"net" | ||
|
||
"golang.zx2c4.com/wireguard/ipc" | ||
"golang.zx2c4.com/wireguard/tun" | ||
|
||
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" | ||
) | ||
|
||
// assignAddr Adds IP address to the tunnel interface and network route based on the range provided | ||
func assignAddr(address string, tunDevice tun.Device) error { | ||
ifaceName, err := tunDevice.Name() | ||
nativeTunDevice := tunDevice.(*tun.NativeTun) | ||
luid := winipcfg.LUID(nativeTunDevice.LUID()) | ||
|
||
ip, ipnet, _ := net.ParseCIDR(address) | ||
|
||
log.Debugf("adding address %s to interface: %s", address, ifaceName) | ||
err = luid.SetIPAddresses([]net.IPNet{{ip, ipnet.Mask}}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Debugf("adding Routes to interface: %s", ifaceName) | ||
err = luid.SetRoutes([]*winipcfg.RouteData{{*ipnet, ipnet.IP, 0}}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// getUAPI returns a Listener | ||
func getUAPI(iface string) (net.Listener, error) { | ||
return ipc.UAPIListen(iface) | ||
} |