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 }