chore: cleanup unneed patch

This commit is contained in:
wwqgtxx 2023-10-22 18:15:31 +08:00
parent f2857b3243
commit 5cca3569e9
7 changed files with 0 additions and 135 deletions

View File

@ -1,7 +0,0 @@
package outbound
import "net"
func (c *conn) RawConn() (net.Conn, bool) {
return c.ExtendedConn, true
}

View File

@ -1,11 +0,0 @@
package net
import "net"
func (c *BufferedConn) RawConn() (net.Conn, bool) {
if c.r.Buffered() == 0 {
return c.ExtendedConn, true
}
return nil, false
}

View File

@ -1,11 +0,0 @@
package constant
import "net"
type WrappedConn interface {
RawConn() (net.Conn, bool)
}
type WrappedPacketConn interface {
RawPacketConn() (net.PacketConn, bool)
}

View File

@ -1,7 +0,0 @@
package context
import "net"
func (c *ConnContext) RawConn() (net.Conn, bool) {
return c.conn, true
}

View File

@ -83,11 +83,5 @@ func closeAllLocalCoon(lAddr string) {
} }
func handleSocket(ctx C.ConnContext, outbound net.Conn) { func handleSocket(ctx C.ConnContext, outbound net.Conn) {
left := unwrap(ctx.Conn())
right := unwrap(outbound)
if relayHijack(left, right) {
return
}
N.Relay(ctx.Conn(), outbound) N.Relay(ctx.Conn(), outbound)
} }

View File

@ -1,73 +0,0 @@
package tunnel
import (
"net"
C "github.com/Dreamacro/clash/constant"
)
func relayHijack(left net.Conn, right net.Conn) bool {
var l *net.TCPConn
var r *net.TCPConn
var ok bool
if l, ok = left.(*net.TCPConn); !ok {
return false
}
if r, ok = right.(*net.TCPConn); !ok {
return false
}
closed := make(chan struct{})
go func() {
defer close(closed)
r.ReadFrom(l)
r.Close()
}()
l.ReadFrom(r)
l.Close()
<-closed
return true
}
func unwrap(conn net.Conn) net.Conn {
r := conn
for {
w, ok := r.(C.WrappedConn)
if !ok {
break
}
rc, ok := w.RawConn()
if !ok {
break
}
r = rc
}
return r
}
func unwrapPacket(conn net.PacketConn) net.PacketConn {
r := conn
for {
w, ok := r.(C.WrappedPacketConn)
if !ok {
break
}
rc, ok := w.RawPacketConn()
if !ok {
break
}
r = rc
}
return r
}

View File

@ -1,25 +1,5 @@
package statistic package statistic
import (
"net"
)
func (m *Manager) Total() (up, down int64) { func (m *Manager) Total() (up, down int64) {
return m.uploadTotal.Load(), m.downloadTotal.Load() return m.uploadTotal.Load(), m.downloadTotal.Load()
} }
func (tt *tcpTracker) RawConn() (net.Conn, bool) {
if tt.Chain.Last() == "DIRECT" {
return tt.Conn, true
}
return nil, false
}
func (ut *udpTracker) RawPacketConn() (net.PacketConn, bool) {
if ut.Chain.Last() == "DIRECT" {
return ut.PacketConn, true
}
return nil, false
}