diff options
Diffstat (limited to 'pkg/server/socket/tun.go')
| -rw-r--r-- | pkg/server/socket/tun.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/server/socket/tun.go b/pkg/server/socket/tun.go index 78bdfd4..c14125b 100644 --- a/pkg/server/socket/tun.go +++ b/pkg/server/socket/tun.go @@ -27,7 +27,7 @@ type tunSocket struct { name string } -type tunChannel struct { +type tunConn struct { name string s *tunSocket fp *os.File @@ -52,7 +52,7 @@ func (s *tunSocket) String() string { return fmt.Sprintf("tun/%s", s.name) } -func (s *tunSocket) Open(env.Env) (Channel, error) { +func (s *tunSocket) Open(env.Env) (Conn, error) { fd, err := unix.Open("/dev/net/tun", unix.O_RDWR, 0) if err != nil { return nil, err @@ -72,7 +72,7 @@ func (s *tunSocket) Open(env.Env) (Channel, error) { return nil, fmt.Errorf("set nonblock %s: %w", s.name, err) } - c := &tunChannel{ + c := &tunConn{ name: strings.Trim(string(ifr.name[:]), "\x00"), fp: os.NewFile(uintptr(fd), "tun"), } @@ -83,7 +83,7 @@ func (s *tunSocket) Open(env.Env) (Channel, error) { func (s *tunSocket) Close() { } -func (c *tunChannel) Send(wq queue.Q) error { +func (c *tunConn) Send(wq queue.Q) error { buf := make([]byte, maxTunBufSize) enc := pack.NewEncoder(wq.Writer()) @@ -97,7 +97,7 @@ func (c *tunChannel) Send(wq queue.Q) error { } } -func (c *tunChannel) Recv(rq queue.Q) error { +func (c *tunConn) Recv(rq queue.Q) error { dec := pack.NewDecoder(rq.Reader()) for { @@ -117,11 +117,11 @@ func (c *tunChannel) Recv(rq queue.Q) error { } } -func (c *tunChannel) String() string { +func (c *tunConn) String() string { return "tun/" + c.name } -func (c *tunChannel) Close() error { +func (c *tunConn) Close() error { err := ErrAlreadyClosed c.once.Do(func() { |
