unknown 5 роки тому
батько
коміт
5e5df224b7

+ 10 - 7
server/common/common_inet_proxy_handle.go

@@ -22,16 +22,19 @@ func (proxy *Proxy) Run(ctx context.Context) (context.Context, error) {
 	clientId := proxy.GetClientId(ctx)
 	brg := proxy.GetBridge(ctx)
 
-	severConn, err := brg.GetConnByClientId(clientId)
+	//severConn, err := brg.GetConnByClientId(clientId)
+	//if err != nil {
+	//	return ctx, err
+	//}
+	//
+	//// send connection information to the npc
+	//if _, err := core.SendInfo(severConn, nil); err != nil {
+	//	return ctx, err
+	//}
+	severConn, err := net.Dial(ctx.Value(core.PROXY_CONNECTION_TYPE).(string), ctx.Value(core.PROXY_CONNECTION_ADDR).(string)+":"+ctx.Value(core.PROXY_CONNECTION_PORT).(string))
 	if err != nil {
 		return ctx, err
 	}
-
-	// send connection information to the npc
-	if _, err := core.SendInfo(severConn, nil); err != nil {
-		return ctx, err
-	}
-
 	// data exchange
 	go core.CopyBuffer(severConn, proxy.clientConn)
 	core.CopyBuffer(proxy.clientConn, severConn)

+ 3 - 1
server/socks5/socks5_server.go

@@ -19,12 +19,14 @@ type S5Server struct {
 	listener     net.Listener
 }
 
-func NewS5Server(globalConfig, clientConfig, pluginConfig map[string]string) *S5Server {
+func NewS5Server(globalConfig, clientConfig, pluginConfig map[string]string, ServerIp string, ServerPort int) *S5Server {
 	s5 := &S5Server{
 		globalConfig: globalConfig,
 		clientConfig: clientConfig,
 		pluginConfig: pluginConfig,
 		plugins:      &core.Plugins{},
+		ServerIp:     ServerIp,
+		ServerPort:   ServerPort,
 	}
 	s5.plugins.Add(new(Handshake), new(Access), new(CheckAccess), new(Request), new(common.Proxy))
 	return s5

+ 15 - 0
server/socks5/socks5_server_test.go

@@ -0,0 +1,15 @@
+package socks5
+
+import (
+	"context"
+	"testing"
+)
+
+func TestNewS5Server(t *testing.T) {
+	g := make(map[string]string)
+	c := make(map[string]string)
+	p := make(map[string]string)
+	s5 := NewS5Server(g, c, p, "", 1099)
+	ctx := context.Background()
+	s5.Start(ctx)
+}