chore: add WaitReadFrom support in ssr

This commit is contained in:
wwqgtxx
2023-05-28 22:51:26 +08:00
parent 097f3e250c
commit 8e88e0b9f5
20 changed files with 182 additions and 88 deletions

View File

@ -7,6 +7,7 @@ import (
"sort"
"strings"
N "github.com/Dreamacro/clash/common/net"
"github.com/Dreamacro/clash/transport/shadowsocks/shadowaead"
"github.com/Dreamacro/clash/transport/shadowsocks/shadowstream"
)
@ -21,7 +22,7 @@ type StreamConnCipher interface {
}
type PacketConnCipher interface {
PacketConn(net.PacketConn) net.PacketConn
PacketConn(N.EnhancePacketConn) N.EnhancePacketConn
}
// ErrCipherNotSupported occurs when a cipher is not supported (likely because of security concerns).
@ -128,7 +129,7 @@ type AeadCipher struct {
}
func (aead *AeadCipher) StreamConn(c net.Conn) net.Conn { return shadowaead.NewConn(c, aead) }
func (aead *AeadCipher) PacketConn(c net.PacketConn) net.PacketConn {
func (aead *AeadCipher) PacketConn(c N.EnhancePacketConn) N.EnhancePacketConn {
return shadowaead.NewPacketConn(c, aead)
}
@ -139,7 +140,7 @@ type StreamCipher struct {
}
func (ciph *StreamCipher) StreamConn(c net.Conn) net.Conn { return shadowstream.NewConn(c, ciph) }
func (ciph *StreamCipher) PacketConn(c net.PacketConn) net.PacketConn {
func (ciph *StreamCipher) PacketConn(c N.EnhancePacketConn) N.EnhancePacketConn {
return shadowstream.NewPacketConn(c, ciph)
}
@ -147,8 +148,8 @@ func (ciph *StreamCipher) PacketConn(c net.PacketConn) net.PacketConn {
type dummy struct{}
func (dummy) StreamConn(c net.Conn) net.Conn { return c }
func (dummy) PacketConn(c net.PacketConn) net.PacketConn { return c }
func (dummy) StreamConn(c net.Conn) net.Conn { return c }
func (dummy) PacketConn(c N.EnhancePacketConn) N.EnhancePacketConn { return c }
// key-derivation function from original Shadowsocks
func Kdf(password string, keyLen int) []byte {