http.go 790 B

123456789101112131415161718192021222324252627282930313233343536
  1. package http
  2. import (
  3. "net"
  4. // "net/http"
  5. "github.com/v2ray/v2ray-core/app"
  6. "github.com/v2ray/v2ray-core/common/log"
  7. jsonconfig "github.com/v2ray/v2ray-core/proxy/http/config/json"
  8. )
  9. type HttpProxyServer struct {
  10. accepting bool
  11. dispatcher app.PacketDispatcher
  12. config *jsonconfig.HttpProxyConfig
  13. }
  14. func NewHttpProxyServer(dispatcher app.PacketDispatcher, config *jsonconfig.HttpProxyConfig) *HttpProxyServer {
  15. return &HttpProxyServer{
  16. dispatcher: dispatcher,
  17. config: config,
  18. }
  19. }
  20. func (server *HttpProxyServer) Listen(port uint16) error {
  21. _, err := net.ListenTCP("tcp", &net.TCPAddr{
  22. IP: []byte{0, 0, 0, 0},
  23. Port: int(port),
  24. Zone: "",
  25. })
  26. if err != nil {
  27. log.Error("HTTP Proxy failed to listen on port %d: %v", port, err)
  28. return err
  29. }
  30. return nil
  31. }