2016-01-01 17:44:11 -05:00
|
|
|
// Package proxy contains all proxies used by V2Ray.
|
2017-02-13 16:11:36 -05:00
|
|
|
//
|
|
|
|
// To implement an inbound or outbound proxy, one needs to do the following:
|
|
|
|
// 1. Implement the interface(s) below.
|
|
|
|
// 2. Register a config creator through common.RegisterConfig.
|
2016-08-19 11:05:15 -04:00
|
|
|
package proxy
|
2016-01-01 17:44:11 -05:00
|
|
|
|
2017-12-02 19:04:57 -05:00
|
|
|
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg proxy -path Proxy
|
2017-04-08 19:43:25 -04:00
|
|
|
|
2016-01-01 17:44:11 -05:00
|
|
|
import (
|
2017-01-14 18:17:06 -05:00
|
|
|
"context"
|
|
|
|
|
2018-01-10 06:22:37 -05:00
|
|
|
"v2ray.com/core"
|
2017-01-13 18:27:45 -05:00
|
|
|
"v2ray.com/core/common/net"
|
2016-08-20 14:55:45 -04:00
|
|
|
"v2ray.com/core/transport/internet"
|
|
|
|
"v2ray.com/core/transport/ray"
|
2016-01-01 17:44:11 -05:00
|
|
|
)
|
|
|
|
|
2017-01-26 14:57:18 -05:00
|
|
|
// An Inbound processes inbound connections.
|
|
|
|
type Inbound interface {
|
2017-02-13 07:13:21 -05:00
|
|
|
// Network returns a list of network that this inbound supports. Connections with not-supported networks will not be passed into Process().
|
2017-01-14 18:57:06 -05:00
|
|
|
Network() net.NetworkList
|
2017-01-26 14:46:44 -05:00
|
|
|
|
2017-02-13 07:13:21 -05:00
|
|
|
// Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
|
2018-01-10 06:22:37 -05:00
|
|
|
Process(context.Context, net.Network, internet.Connection, core.Dispatcher) error
|
2016-01-01 17:44:11 -05:00
|
|
|
}
|
|
|
|
|
2017-01-26 14:57:18 -05:00
|
|
|
// An Outbound process outbound connections.
|
|
|
|
type Outbound interface {
|
2017-02-13 07:13:21 -05:00
|
|
|
// Process processes the given connection. The given dialer may be used to dial a system outbound connection.
|
2017-02-03 16:35:09 -05:00
|
|
|
Process(context.Context, ray.OutboundRay, Dialer) error
|
2016-01-01 17:44:11 -05:00
|
|
|
}
|
2017-01-14 18:17:06 -05:00
|
|
|
|
|
|
|
// Dialer is used by OutboundHandler for creating outbound connections.
|
|
|
|
type Dialer interface {
|
2017-02-13 07:13:21 -05:00
|
|
|
// Dial dials a system connection to the given destination.
|
2017-01-14 18:17:06 -05:00
|
|
|
Dial(ctx context.Context, destination net.Destination) (internet.Connection, error)
|
|
|
|
}
|