|
|
@ -24,6 +24,7 @@ import (
|
|
|
|
"v2ray.com/core/transport/internet"
|
|
|
|
"v2ray.com/core/transport/internet"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Client is a inbound handler for HTTP protocol
|
|
|
|
type Client struct {
|
|
|
|
type Client struct {
|
|
|
|
serverPicker protocol.ServerPicker
|
|
|
|
serverPicker protocol.ServerPicker
|
|
|
|
policyManager policy.Manager
|
|
|
|
policyManager policy.Manager
|
|
|
@ -92,7 +93,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|
|
|
p = c.policyManager.ForLevel(user.Level)
|
|
|
|
p = c.policyManager.ForLevel(user.Level)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := setUpHttpTunnel(conn, &destination, user); err != nil {
|
|
|
|
if err := setUpHTTPTunnel(conn, &destination, user); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -124,8 +125,8 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// setUpHttpTunnel will create a socket tunnel via HTTP CONNECT method
|
|
|
|
// setUpHTTPTunnel will create a socket tunnel via HTTP CONNECT method
|
|
|
|
func setUpHttpTunnel(writer io.Writer, destination *net.Destination, user *protocol.MemoryUser) error {
|
|
|
|
func setUpHTTPTunnel(writer io.Writer, destination *net.Destination, user *protocol.MemoryUser) error {
|
|
|
|
var headers []string
|
|
|
|
var headers []string
|
|
|
|
destNetAddr := destination.NetAddr()
|
|
|
|
destNetAddr := destination.NetAddr()
|
|
|
|
headers = append(headers, "CONNECT "+destNetAddr+" HTTP/1.1")
|
|
|
|
headers = append(headers, "CONNECT "+destNetAddr+" HTTP/1.1")
|
|
|
|