summaryrefslogtreecommitdiff
path: root/pkg/server/socket/tun.go
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2020-05-05 20:10:08 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2020-05-05 20:10:08 +0300
commitb089b35f35a14e85d89df69254cc61495d59d3dd (patch)
treeda07e5b015e02f7fa05cf0be181697670af787ed /pkg/server/socket/tun.go
parentf44d6e1a111154b70aaeac9ffe38beaee2cc5dd7 (diff)
add http connect proxy server
Diffstat (limited to 'pkg/server/socket/tun.go')
-rw-r--r--pkg/server/socket/tun.go14
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() {