proxy: added PackerServer interface

This commit is contained in:
nadoo committed 2022-01-16 23:15:18 +08:00
1 parent 253e5008c4
commit cf1a4e3817
11 files changed
+52 -22

No files matched your search

+5
View File
@@ -13,6 +13,11 @@ import (
"github.com/nadoo/glider/proxy"
)
func init() {
proxy.RegisterDialer("trojan", NewTrojanDialer)
proxy.RegisterDialer("trojanc", NewClearTextDialer) // cleartext
}
// NewClearTextDialer returns a trojan cleartext proxy dialer.
func NewClearTextDialer(s string, d proxy.Dialer) (proxy.Dialer, error) {
t, err := NewTrojan(s, d, nil)
+1 -1
View File
@@ -27,7 +27,7 @@ func NewPktConn(c net.Conn, tgtAddr socks.Addr) *PktConn {
// ReadFrom implements the necessary function of net.PacketConn.
// NOTE: the underlying connection is not udp, we returned the target address here,
// it's not the vless server's address, do not WriteTo it.
// it's not the server's address, do not WriteTo it.
func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
// ATYP, DST.ADDR, DST.PORT
_, err := socks.ReadAddr(pc.Conn)
+5
View File
@@ -16,6 +16,11 @@ import (
"github.com/nadoo/glider/proxy"
)
func init() {
proxy.RegisterServer("trojan", NewTrojanServer)
proxy.RegisterServer("trojanc", NewClearTextServer) // cleartext
}
// NewClearTextServer returns a trojan cleartext proxy server.
func NewClearTextServer(s string, p proxy.Proxy) (proxy.Server, error) {
t, err := NewTrojan(s, nil, p)
-7
View File
@@ -31,13 +31,6 @@ type Trojan struct {
fallback string
}
func init() {
proxy.RegisterDialer("trojan", NewTrojanDialer)
proxy.RegisterServer("trojan", NewTrojanServer)
proxy.RegisterDialer("trojanc", NewClearTextDialer) // cleartext
proxy.RegisterServer("trojanc", NewClearTextServer) // cleartext
}
// NewTrojan returns a trojan proxy.
func NewTrojan(s string, d proxy.Dialer, p proxy.Proxy) (*Trojan, error) {
u, err := url.Parse(s)