populate default PlatformSpecificParams when it's empty (#43)

This commit is contained in:
Song Gao 2018-04-20 14:47:39 +08:00 committed by GitHub
parent 8bbc3c8191
commit bf1a5d0277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
water.test

3
if.go
View file

@ -53,6 +53,9 @@ func New(config Config) (ifce *Interface, err error) {
if zeroConfig == config {
config = defaultConfig()
}
if config.PlatformSpecificParams == zeroConfig.PlatformSpecificParams {
config.PlatformSpecificParams = defaultPlatformSpecificParams()
}
switch config.DeviceType {
case TUN:
return newTUN(config)

View file

@ -175,7 +175,7 @@ func (t *tunReadCloser) Write(from []byte) (int, error) {
} else if ipVer == 6 {
t.wBuf[3] = syscall.AF_INET6
} 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)