chore: clean code
This commit is contained in:
parent
545af5d11c
commit
728dd10a89
4 changed files with 1 additions and 30 deletions
|
@ -1,7 +1,6 @@
|
|||
package faketcp
|
||||
|
||||
import (
|
||||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/Dreamacro/clash/transport/hysteria/obfs"
|
||||
"net"
|
||||
"sync"
|
||||
|
@ -14,7 +13,6 @@ const udpBufferSize = 65535
|
|||
type ObfsFakeTCPConn struct {
|
||||
orig *TCPConn
|
||||
obfs obfs.Obfuscator
|
||||
closed bool
|
||||
readBuf []byte
|
||||
readMutex sync.Mutex
|
||||
writeBuf []byte
|
||||
|
@ -33,13 +31,7 @@ func NewObfsFakeTCPConn(orig *TCPConn, obfs obfs.Obfuscator) *ObfsFakeTCPConn {
|
|||
func (c *ObfsFakeTCPConn) ReadFrom(p []byte) (int, net.Addr, error) {
|
||||
for {
|
||||
c.readMutex.Lock()
|
||||
if c.closed {
|
||||
log.Infoln("read faketcp obfs before")
|
||||
}
|
||||
n, addr, err := c.orig.ReadFrom(c.readBuf)
|
||||
if c.closed {
|
||||
log.Infoln("read faketcp obfs after")
|
||||
}
|
||||
if n <= 0 {
|
||||
c.readMutex.Unlock()
|
||||
return 0, addr, err
|
||||
|
@ -69,7 +61,6 @@ func (c *ObfsFakeTCPConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
|||
}
|
||||
|
||||
func (c *ObfsFakeTCPConn) Close() error {
|
||||
c.closed = true
|
||||
return c.orig.Close()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package udp
|
||||
|
||||
import (
|
||||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/Dreamacro/clash/transport/hysteria/obfs"
|
||||
"net"
|
||||
"sync"
|
||||
|
@ -17,7 +16,6 @@ type ObfsUDPConn struct {
|
|||
readMutex sync.Mutex
|
||||
writeBuf []byte
|
||||
writeMutex sync.Mutex
|
||||
closed bool
|
||||
}
|
||||
|
||||
func NewObfsUDPConn(orig net.PacketConn, obfs obfs.Obfuscator) *ObfsUDPConn {
|
||||
|
@ -32,13 +30,7 @@ func NewObfsUDPConn(orig net.PacketConn, obfs obfs.Obfuscator) *ObfsUDPConn {
|
|||
func (c *ObfsUDPConn) ReadFrom(p []byte) (int, net.Addr, error) {
|
||||
for {
|
||||
c.readMutex.Lock()
|
||||
if c.closed {
|
||||
log.Infoln("read udp obfs before")
|
||||
}
|
||||
n, addr, err := c.orig.ReadFrom(c.readBuf)
|
||||
if c.closed {
|
||||
log.Infoln("read udp obfs after")
|
||||
}
|
||||
if n <= 0 {
|
||||
c.readMutex.Unlock()
|
||||
return 0, addr, err
|
||||
|
@ -68,7 +60,6 @@ func (c *ObfsUDPConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
|||
}
|
||||
|
||||
func (c *ObfsUDPConn) Close() error {
|
||||
c.closed = true
|
||||
return c.orig.Close()
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ const udpBufferSize = 65535
|
|||
type ObfsWeChatUDPConn struct {
|
||||
orig net.PacketConn
|
||||
obfs obfs.Obfuscator
|
||||
closed bool
|
||||
readBuf []byte
|
||||
readMutex sync.Mutex
|
||||
writeBuf []byte
|
||||
|
@ -37,13 +36,7 @@ func NewObfsWeChatUDPConn(orig net.PacketConn, obfs obfs.Obfuscator) *ObfsWeChat
|
|||
func (c *ObfsWeChatUDPConn) ReadFrom(p []byte) (int, net.Addr, error) {
|
||||
for {
|
||||
c.readMutex.Lock()
|
||||
if c.closed {
|
||||
log.Infoln("read wechat obfs before")
|
||||
}
|
||||
n, addr, err := c.orig.ReadFrom(c.readBuf)
|
||||
if c.closed {
|
||||
log.Infoln("read wechat obfs after")
|
||||
}
|
||||
if n <= 13 {
|
||||
c.readMutex.Unlock()
|
||||
return 0, addr, err
|
||||
|
@ -84,7 +77,6 @@ func (c *ObfsWeChatUDPConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
|
|||
}
|
||||
|
||||
func (c *ObfsWeChatUDPConn) Close() error {
|
||||
c.closed = true
|
||||
return c.orig.Close()
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,7 @@ import (
|
|||
)
|
||||
|
||||
type ClientTransport struct {
|
||||
Dialer *net.Dialer
|
||||
PrefEnabled bool
|
||||
PrefIPv6 bool
|
||||
PrefExclusive bool
|
||||
Dialer *net.Dialer
|
||||
}
|
||||
|
||||
func (ct *ClientTransport) quicPacketConn(proto string, server string, obfs obfs.Obfuscator, dialer PacketDialer) (net.PacketConn, error) {
|
||||
|
|
Loading…
Reference in a new issue