forked from hsheth2/water
-
Notifications
You must be signed in to change notification settings - Fork 2
/
if.go
41 lines (34 loc) · 1020 Bytes
/
if.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package water
import (
"io"
)
// Interface is a TUN/TAP interface.
type Interface struct {
isTAP bool
io.ReadWriteCloser
name string
}
// Create a new TAP interface whose name is ifName.
// If ifName is empty, a default name (tap0, tap1, ... ) will be assigned.
// ifName should not exceed 16 bytes.
func NewTAP(ifName string) (ifce *Interface, err error) {
return newTAP(ifName)
}
// Create a new TUN interface whose name is ifName.
// If ifName is empty, a default name (tap0, tap1, ... ) will be assigned.
// ifName should not exceed 16 bytes.
func NewTUN(ifName string) (ifce *Interface, err error) {
return newTUN(ifName)
}
// Returns true if ifce is a TUN interface, otherwise returns false;
func (ifce *Interface) IsTUN() bool {
return !ifce.isTAP
}
// Returns true if ifce is a TAP interface, otherwise returns false;
func (ifce *Interface) IsTAP() bool {
return ifce.isTAP
}
// Returns the interface name of ifce, e.g. tun0, tap1, etc..
func (ifce *Interface) Name() string {
return ifce.name
}