-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OpenBSD, FreeBSD, NetBSD and add
InterfaceName
para…
…meter for Windows to allow selecting between multiple `tap0901` adapters on the same system
- Loading branch information
1 parent
bf1a5d0
commit 78c5d97
Showing
8 changed files
with
90 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Tony Lu <[email protected]> | |
ajee cai <[email protected]> | ||
yinheli <[email protected]> | ||
Paul Querna <[email protected]> | ||
Neil Alexander <[email protected]> |
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,20 @@ | ||
// +build openbsd freebsd netbsd dragonfly | ||
|
||
package water | ||
|
||
// PlatformSpecificParams defines parameters in Config that are specific to | ||
// Linux. A zero-value of such type is valid, yielding an interface | ||
// with OS defined name. | ||
type PlatformSpecificParams struct { | ||
// Name is the name to be set for the interface to be created. This overrides | ||
// the default name assigned by OS such as tap0 or tun0. A zero-value of this | ||
// field, i.e. an empty string, indicates that the default name should be | ||
// used. | ||
Name string | ||
} | ||
|
||
func defaultPlatformSpecificParams() PlatformSpecificParams { | ||
return PlatformSpecificParams{ | ||
Name: "/dev/tun0", | ||
} | ||
} |
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,35 @@ | ||
// +build openbsd freebsd netbsd dragonfly | ||
|
||
package water | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func newTAP(config Config) (ifce *Interface, err error) { | ||
if config.Name[:8] != "/dev/tap" { | ||
panic("TUN/TAP name must be in format /dev/tunX or /dev/tapX") | ||
} | ||
|
||
file, err := os.OpenFile(config.Name, os.O_RDWR, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ifce = &Interface{isTAP: true, ReadWriteCloser: file, name: config.Name[5:]} | ||
return | ||
} | ||
|
||
func newTUN(config Config) (ifce *Interface, err error) { | ||
if config.Name[:8] != "/dev/tun" { | ||
panic("TUN/TAP name must be in format /dev/tunX or /dev/tapX") | ||
} | ||
|
||
file, err := os.OpenFile(config.Name, os.O_RDWR, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ifce = &Interface{isTAP: false, ReadWriteCloser: file, name: config.Name[5:]} | ||
return | ||
} |
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