mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +03:00
use embeded elements instead or private field for /dev/net/tun
this makes it possible to get *os.File by using type assertion over ReadWriteCloser. resolves #7
This commit is contained in:
parent
4a6164f5ed
commit
6a76f249f6
2 changed files with 5 additions and 19 deletions
20
if.go
20
if.go
|
@ -1,14 +1,12 @@
|
|||
package water
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
import "io"
|
||||
|
||||
// Interface is a TUN/TAP interface.
|
||||
type Interface struct {
|
||||
isTAP bool
|
||||
file *os.File
|
||||
name string
|
||||
io.ReadWriteCloser
|
||||
name string
|
||||
}
|
||||
|
||||
// Create a new TAP interface whose name is ifName.
|
||||
|
@ -39,15 +37,3 @@ func (ifce *Interface) IsTAP() bool {
|
|||
func (ifce *Interface) Name() string {
|
||||
return ifce.name
|
||||
}
|
||||
|
||||
// Implement io.Writer interface.
|
||||
func (ifce *Interface) Write(p []byte) (n int, err error) {
|
||||
n, err = ifce.file.Write(p)
|
||||
return
|
||||
}
|
||||
|
||||
// Implement io.Reader interface.
|
||||
func (ifce *Interface) Read(p []byte) (n int, err error) {
|
||||
n, err = ifce.file.Read(p)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue