github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/proxy/proxy.go (about) 1 // Package proxy contains all proxies used by V2Ray. 2 // 3 // To implement an inbound or outbound proxy, one needs to do the following: 4 // 1. Implement the interface(s) below. 5 // 2. Register a config creator through common.RegisterConfig. 6 package proxy 7 8 import ( 9 "context" 10 11 "v2ray.com/core/common/net" 12 "v2ray.com/core/common/protocol" 13 "v2ray.com/core/features/routing" 14 "v2ray.com/core/transport" 15 "v2ray.com/core/transport/internet" 16 ) 17 18 // An Inbound processes inbound connections. 19 type Inbound interface { 20 // Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process(). 21 Network() []net.Network 22 23 // Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound. 24 Process(context.Context, net.Network, internet.Connection, routing.Dispatcher) error 25 } 26 27 // An Outbound process outbound connections. 28 type Outbound interface { 29 // Process processes the given connection. The given dialer may be used to dial a system outbound connection. 30 Process(context.Context, *transport.Link, internet.Dialer) error 31 } 32 33 // UserManager is the interface for Inbounds and Outbounds that can manage their users. 34 type UserManager interface { 35 // AddUser adds a new user. 36 AddUser(context.Context, *protocol.MemoryUser) error 37 38 // RemoveUser removes a user by email. 39 RemoveUser(context.Context, string) error 40 } 41 42 type GetInbound interface { 43 GetInbound() Inbound 44 } 45 46 type GetOutbound interface { 47 GetOutbound() Outbound 48 }