v2ray-core/proxy/proxy.go

49 lines
1.5 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
import (
2017-01-14 23:17:06 +00:00
"context"
2017-01-13 23:27:45 +00:00
"v2ray.com/core/common/net"
2018-02-05 22:38:24 +00:00
"v2ray.com/core/common/protocol"
"v2ray.com/core/features/routing"
2018-11-03 11:36:29 +00:00
"v2ray.com/core/transport"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/transport/internet"
)
2017-01-26 19:57:18 +00:00
// An Inbound processes inbound connections.
type Inbound interface {
2018-11-20 15:58:26 +00: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-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, routing.Dispatcher) 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.
2018-11-03 11:36:29 +00:00
Process(context.Context, *transport.Link, internet.Dialer) error
2017-01-14 23:17:06 +00:00
}
2018-02-05 22:38:24 +00:00
// UserManager is the interface for Inbounds and Outbounds that can manage their users.
type UserManager interface {
// AddUser adds a new user.
2018-08-26 22:11:32 +00:00
AddUser(context.Context, *protocol.MemoryUser) error
2018-02-05 22:38:24 +00:00
// RemoveUser removes a user by email.
2018-02-05 22:38:24 +00:00
RemoveUser(context.Context, string) error
}
type GetInbound interface {
GetInbound() Inbound
}
type GetOutbound interface {
GetOutbound() Outbound
2018-02-05 22:39:04 +00:00
}