1
0
mirror of https://github.com/fumiama/water.git synced 2026-06-05 02:00:29 +08:00
This commit is contained in:
fumiama
2021-12-29 20:59:42 +08:00
parent 2b4b6d7c09
commit 5b6a70c00f
4 changed files with 18 additions and 6 deletions

8
go.mod Normal file
View File

@@ -0,0 +1,8 @@
module github.com/fumiama/water
go 1.17
require (
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
)

4
go.sum Normal file
View File

@@ -0,0 +1,4 @@
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@@ -28,7 +28,7 @@ type PlatformSpecificParams struct {
func defaultPlatformSpecificParams() PlatformSpecificParams {
return PlatformSpecificParams{
ComponentID: "tap0901",
ComponentID: "root\\tap0901",
Network: "192.168.1.10/24",
}
}

View File

@@ -281,11 +281,6 @@ func openDev(config Config) (ifce *Interface, err error) {
fd := &wfile{fd: file, ro: ro, wo: wo}
ifce = &Interface{isTAP: (config.DeviceType == TAP), ReadWriteCloser: fd}
// bring up device.
if err := setStatus(file, true); err != nil {
return nil, err
}
//TUN
if config.DeviceType == TUN {
if err := setTUN(file, config.PlatformSpecificParams.Network); err != nil {
@@ -293,6 +288,11 @@ func openDev(config Config) (ifce *Interface, err error) {
}
}
// bring up device.
if err := setStatus(file, true); err != nil {
return nil, err
}
// find the name of tap interface(u need it to set the ip or other command)
ifces, err := net.Interfaces()
if err != nil {