v2ray-core/proxy/proxy.go

39 lines
1.4 KiB
Go
Raw Normal View History

// Package proxy contains all proxies used by V2Ray.
2017-02-13 21:11:36 +00: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 15:05:15 +00:00
package proxy
2017-12-03 00:04:57 +00:00
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg proxy -path Proxy
2017-04-08 23:43:25 +00:00
import (
2017-01-14 23:17:06 +00:00
"context"
"v2ray.com/core/app/dispatcher"
2017-01-13 23:27:45 +00:00
"v2ray.com/core/common/net"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/transport/internet"
"v2ray.com/core/transport/ray"
)
2017-01-26 19:57:18 +00:00
// An Inbound processes inbound connections.
type Inbound interface {
2017-02-13 12:13:21 +00: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 23:57:06 +00:00
Network() net.NetworkList
2017-02-13 12:13:21 +00:00
// Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
Process(context.Context, net.Network, internet.Connection, dispatcher.Interface) error
}
2017-01-26 19:57:18 +00:00
// An Outbound process outbound connections.
type Outbound interface {
2017-02-13 12:13:21 +00:00
// Process processes the given connection. The given dialer may be used to dial a system outbound connection.
Process(context.Context, ray.OutboundRay, Dialer) error
}
2017-01-14 23:17:06 +00:00
// Dialer is used by OutboundHandler for creating outbound connections.
type Dialer interface {
2017-02-13 12:13:21 +00:00
// Dial dials a system connection to the given destination.
2017-01-14 23:17:06 +00:00
Dial(ctx context.Context, destination net.Destination) (internet.Connection, error)
}