chore: change C.PacketAdapter from a struct to an interface

This commit is contained in:
wwqgtxx
2022-12-04 14:37:52 +08:00
parent 4f75201a98
commit 6fc62da7ae
32 changed files with 267 additions and 251 deletions

View File

@ -21,7 +21,7 @@ type Listener struct {
var _listener *Listener
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *C.PacketAdapter) (*Listener, error) {
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter) (*Listener, error) {
addr, cipher, password, err := ParseSSURL(config)
if err != nil {
return nil, err

View File

@ -17,7 +17,7 @@ type UDPListener struct {
closed bool
}
func NewUDP(addr string, pickCipher core.Cipher, in chan<- *C.PacketAdapter) (*UDPListener, error) {
func NewUDP(addr string, pickCipher core.Cipher, in chan<- C.PacketAdapter) (*UDPListener, error) {
l, err := net.ListenPacket("udp", addr)
if err != nil {
return nil, err
@ -53,7 +53,7 @@ func (l *UDPListener) Close() error {
return l.packetConn.Close()
}
func handleSocksUDP(pc net.PacketConn, in chan<- *C.PacketAdapter, buf []byte, addr net.Addr) {
func handleSocksUDP(pc net.PacketConn, in chan<- C.PacketAdapter, buf []byte, addr net.Addr) {
tgtAddr := socks5.SplitAddr(buf)
if tgtAddr == nil {
// Unresolved UDP packet, return buffer to the pool