mirror of
https://github.com/fumiama/water.git
synced 2026-06-05 02:00:29 +08:00
populate default PlatformSpecificParams when it's empty (#43)
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
water.test
|
||||||
3
if.go
3
if.go
@@ -53,6 +53,9 @@ func New(config Config) (ifce *Interface, err error) {
|
|||||||
if zeroConfig == config {
|
if zeroConfig == config {
|
||||||
config = defaultConfig()
|
config = defaultConfig()
|
||||||
}
|
}
|
||||||
|
if config.PlatformSpecificParams == zeroConfig.PlatformSpecificParams {
|
||||||
|
config.PlatformSpecificParams = defaultPlatformSpecificParams()
|
||||||
|
}
|
||||||
switch config.DeviceType {
|
switch config.DeviceType {
|
||||||
case TUN:
|
case TUN:
|
||||||
return newTUN(config)
|
return newTUN(config)
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ func (t *tunReadCloser) Write(from []byte) (int, error) {
|
|||||||
} else if ipVer == 6 {
|
} else if ipVer == 6 {
|
||||||
t.wBuf[3] = syscall.AF_INET6
|
t.wBuf[3] = syscall.AF_INET6
|
||||||
} else {
|
} else {
|
||||||
return 0, errors.New("Unable to determine IP version from packet.")
|
return 0, errors.New("Unable to determine IP version from packet")
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(t.wBuf[4:], from)
|
copy(t.wBuf[4:], from)
|
||||||
|
|||||||
Reference in New Issue
Block a user