| 
									
										
										
										
											2016-01-01 23:44:11 +01:00
										 |  |  | // Package proxy contains all proxies used by V2Ray. | 
					
						
							| 
									
										
										
										
											2017-02-13 22:11:36 +01: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 17:05:15 +02:00
										 |  |  | package proxy | 
					
						
							| 
									
										
										
										
											2016-01-01 23:44:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2017-01-15 00:17:06 +01:00
										 |  |  | 	"context" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 04:31:50 +08:00
										 |  |  | 	"github.com/v2fly/v2ray-core/v4/common/net" | 
					
						
							|  |  |  | 	"github.com/v2fly/v2ray-core/v4/common/protocol" | 
					
						
							|  |  |  | 	"github.com/v2fly/v2ray-core/v4/features/routing" | 
					
						
							|  |  |  | 	"github.com/v2fly/v2ray-core/v4/transport" | 
					
						
							|  |  |  | 	"github.com/v2fly/v2ray-core/v4/transport/internet" | 
					
						
							| 
									
										
										
										
											2016-01-01 23:44:11 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 20:57:18 +01:00
										 |  |  | // An Inbound processes inbound connections. | 
					
						
							|  |  |  | type Inbound interface { | 
					
						
							| 
									
										
										
										
											2018-11-20 16:58:26 +01:00
										 |  |  | 	// Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process(). | 
					
						
							|  |  |  | 	Network() []net.Network | 
					
						
							| 
									
										
										
										
											2017-01-26 20:46:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-13 13:13:21 +01:00
										 |  |  | 	// Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound. | 
					
						
							| 
									
										
										
										
											2018-10-11 20:43:37 +02:00
										 |  |  | 	Process(context.Context, net.Network, internet.Connection, routing.Dispatcher) error | 
					
						
							| 
									
										
										
										
											2016-01-01 23:44:11 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 20:57:18 +01:00
										 |  |  | // An Outbound process outbound connections. | 
					
						
							|  |  |  | type Outbound interface { | 
					
						
							| 
									
										
										
										
											2017-02-13 13:13:21 +01:00
										 |  |  | 	// Process processes the given connection. The given dialer may be used to dial a system outbound connection. | 
					
						
							| 
									
										
										
										
											2018-11-03 12:36:29 +01:00
										 |  |  | 	Process(context.Context, *transport.Link, internet.Dialer) error | 
					
						
							| 
									
										
										
										
											2017-01-15 00:17:06 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-05 23:38:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | // UserManager is the interface for Inbounds and Outbounds that can manage their users. | 
					
						
							|  |  |  | type UserManager interface { | 
					
						
							|  |  |  | 	// AddUser adds a new user. | 
					
						
							| 
									
										
										
										
											2018-08-27 00:11:32 +02:00
										 |  |  | 	AddUser(context.Context, *protocol.MemoryUser) error | 
					
						
							| 
									
										
										
										
											2018-02-05 23:38:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 15:17:36 +08:00
										 |  |  | 	// RemoveUser removes a user by email. | 
					
						
							| 
									
										
										
										
											2018-02-05 23:38:24 +01:00
										 |  |  | 	RemoveUser(context.Context, string) error | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type GetInbound interface { | 
					
						
							|  |  |  | 	GetInbound() Inbound | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type GetOutbound interface { | 
					
						
							|  |  |  | 	GetOutbound() Outbound | 
					
						
							| 
									
										
										
										
											2018-02-05 23:39:04 +01:00
										 |  |  | } |