1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

beginning of http proxy

This commit is contained in:
V2Ray 2015-10-28 12:13:27 +01:00
parent 294376edc0
commit 08328d23fa
3 changed files with 52 additions and 1 deletions

View File

@ -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
proxy/http/http.go Normal file
View File

@ -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
}

View File

@ -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)