chore: delete dead code

This commit is contained in:
wlynxg
2024-09-08 18:25:19 +08:00
parent 2c87388288
commit 58a8b1f91b
2 changed files with 6 additions and 35 deletions

View File

@@ -14,10 +14,10 @@ import (
func (e *Engine) addConnByDst(dst netip.Addr) (PacketChan, error) {
e.log.Debugf("Try to connect to the corresponding node of %s", dst)
var conn PacketChan
if c, ok := e.routeTable.addr.Load(dst); ok {
conn = c
return c, nil
} else {
var conn PacketChan
e.routeTable.m.Range(func(key string, value netip.Prefix) bool {
if value.Addr().Compare(dst) != 0 {
return true
@@ -28,6 +28,7 @@ func (e *Engine) addConnByDst(dst netip.Addr) (PacketChan, error) {
} else {
conn = make(PacketChan, ChanSize)
e.routeTable.addr.Store(dst, conn)
e.routeTable.id.Store(key, conn)
go func() {
defer e.routeTable.id.Delete(key)
defer e.routeTable.addr.Delete(dst)
@@ -36,10 +37,9 @@ func (e *Engine) addConnByDst(dst netip.Addr) (PacketChan, error) {
}
return false
})
}
if conn != nil {
return conn, nil
if conn != nil {
return conn, nil
}
}
return nil, errors.New(fmt.Sprintf("the routing rule corresponding to %s was not found", dst.String()))

View File

@@ -1,29 +0,0 @@
package engine
import (
"io"
)
var _ io.ReadWriteCloser = (*devWrapper)(nil)
type devWrapper struct {
w PacketChan
r PacketChan
}
func (c *devWrapper) Read(p []byte) (n int, err error) {
packet := <-c.r
copy(p, packet.Data)
return len(packet.Data), nil
}
func (c *devWrapper) Write(p []byte) (n int, err error) {
buff := make([]byte, len(p))
copy(buff, p)
c.w <- Payload{Data: buff}
return len(buff), nil
}
func (c *devWrapper) Close() error {
return nil
}