update tap

This commit is contained in:
ginuerzh
2022-11-04 18:48:28 +08:00
parent 30d44c7376
commit 05ddda70e3
9 changed files with 181 additions and 92 deletions

View File

@ -1,18 +1,20 @@
package tap
import (
"context"
"errors"
"io"
"net"
"time"
mdata "github.com/go-gost/core/metadata"
"github.com/songgao/water"
)
type conn struct {
ifce *water.Interface
laddr net.Addr
raddr net.Addr
ifce io.ReadWriteCloser
laddr net.Addr
raddr net.Addr
cancel context.CancelFunc
}
func (c *conn) Read(b []byte) (n int, err error) {
@ -44,6 +46,9 @@ func (c *conn) SetWriteDeadline(t time.Time) error {
}
func (c *conn) Close() (err error) {
if c.cancel != nil {
c.cancel()
}
return c.ifce.Close()
}