Selaa lähdekoodia

beginning of http proxy

V2Ray 10 vuotta sitten
vanhempi
commit
08328d23fa
3 muutettua tiedostoa jossa 52 lisäystä ja 1 poistoa
  1. 15 0
      proxy/http/config/json/json.go
  2. 36 0
      proxy/http/http.go
  3. 1 1
      proxy/vmess/vmessin.go

+ 15 - 0
proxy/http/config/json/json.go

@@ -0,0 +1,15 @@
+package json
+
+import (
+	"github.com/v2ray/v2ray-core/config"
+	"github.com/v2ray/v2ray-core/config/json"
+)
+
+type HttpProxyConfig struct {
+}
+
+func init() {
+	json.RegisterConfigType("http", config.TypeInbound, func() interface{} {
+		return new(HttpProxyConfig)
+	})
+}

+ 36 - 0
proxy/http/http.go

@@ -0,0 +1,36 @@
+package http
+
+import (
+	"net"
+	// "net/http"
+
+	"github.com/v2ray/v2ray-core/app"
+	"github.com/v2ray/v2ray-core/common/log"
+	jsonconfig "github.com/v2ray/v2ray-core/proxy/http/config/json"
+)
+
+type HttpProxyServer struct {
+	accepting  bool
+	dispatcher app.PacketDispatcher
+	config     *jsonconfig.HttpProxyConfig
+}
+
+func NewHttpProxyServer(dispatcher app.PacketDispatcher, config *jsonconfig.HttpProxyConfig) *HttpProxyServer {
+	return &HttpProxyServer{
+		dispatcher: dispatcher,
+		config:     config,
+	}
+}
+
+func (server *HttpProxyServer) Listen(port uint16) error {
+	_, err := net.ListenTCP("tcp", &net.TCPAddr{
+		IP:   []byte{0, 0, 0, 0},
+		Port: int(port),
+		Zone: "",
+	})
+	if err != nil {
+		log.Error("HTTP Proxy failed to listen on port %d: %v", port, err)
+		return err
+	}
+	return nil
+}

+ 1 - 1
proxy/vmess/vmessin.go

@@ -91,7 +91,7 @@ func (handler *VMessInboundHandler) HandleConnection(connection *net.TCPConn) er
 	readFinish.Lock()
 	writeFinish.Lock()
 
-  connReader.SetTimeOut(120)
+	connReader.SetTimeOut(120)
 	go handleInput(request, connReader, input, &readFinish)
 
 	responseKey := md5.Sum(request.RequestKey)