1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-27 01:45:23 +00:00
v2fly/proxy/http/http.go

38 lines
842 B
Go
Raw Normal View History

2015-10-28 11:13:27 +00:00
package http
import (
"net"
// "net/http"
"github.com/v2ray/v2ray-core/app"
"github.com/v2ray/v2ray-core/common/log"
2015-12-02 20:44:01 +00:00
v2net "github.com/v2ray/v2ray-core/common/net"
2015-10-28 11:13:27 +00:00
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,
}
}
2015-12-02 20:44:01 +00:00
func (server *HttpProxyServer) Listen(port v2net.Port) error {
2015-10-28 11:13:27 +00:00
_, 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
}