1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-29 05:27:02 -05:00

rename proxy interfaces

This commit is contained in:
Darien Raymond 2017-01-26 20:57:18 +01:00
parent d2764d8776
commit 7f36a5d1d3
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
8 changed files with 19 additions and 19 deletions

View File

@ -21,7 +21,7 @@ func (s *AllocationStrategy) GetRefreshValue() uint32 {
return s.Refresh.Value return s.Refresh.Value
} }
func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.OutboundHandler, error) { func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.Outbound, error) {
if c == nil { if c == nil {
return nil, errors.New("Proxyman: OutboundHandlerConfig is nil.") return nil, errors.New("Proxyman: OutboundHandlerConfig is nil.")
} }

View File

@ -11,7 +11,7 @@ import (
) )
type AlwaysOnInboundHandler struct { type AlwaysOnInboundHandler struct {
proxy proxy.InboundHandler proxy proxy.Inbound
workers []worker workers []worker
} }
@ -72,7 +72,7 @@ func (h *AlwaysOnInboundHandler) Close() {
} }
} }
func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.InboundHandler, net.Port, int) { func (h *AlwaysOnInboundHandler) GetRandomInboundProxy() (proxy.Inbound, net.Port, int) {
w := h.workers[dice.Roll(len(h.workers))] w := h.workers[dice.Roll(len(h.workers))]
return w.Proxy(), w.Port(), 9999 return w.Proxy(), w.Port(), 9999
} }

View File

@ -136,7 +136,7 @@ func (h *DynamicInboundHandler) Close() {
h.cancel() h.cancel()
} }
func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.InboundHandler, v2net.Port, int) { func (h *DynamicInboundHandler) GetRandomInboundProxy() (proxy.Inbound, v2net.Port, int) {
w := h.worker[dice.Roll(len(h.worker))] w := h.worker[dice.Roll(len(h.worker))]
expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute) expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute)
return w.Proxy(), w.Port(), int(expire) return w.Proxy(), w.Port(), int(expire)

View File

@ -21,13 +21,13 @@ type worker interface {
Start() error Start() error
Close() Close()
Port() v2net.Port Port() v2net.Port
Proxy() proxy.InboundHandler Proxy() proxy.Inbound
} }
type tcpWorker struct { type tcpWorker struct {
address v2net.Address address v2net.Address
port v2net.Port port v2net.Port
proxy proxy.InboundHandler proxy proxy.Inbound
stream *internet.StreamConfig stream *internet.StreamConfig
recvOrigDest bool recvOrigDest bool
tag string tag string
@ -56,7 +56,7 @@ func (w *tcpWorker) callback(conn internet.Connection) {
conn.Close() conn.Close()
} }
func (w *tcpWorker) Proxy() proxy.InboundHandler { func (w *tcpWorker) Proxy() proxy.Inbound {
return w.proxy return w.proxy
} }
@ -148,7 +148,7 @@ func (*udpConn) SetReusable(bool) {}
type udpWorker struct { type udpWorker struct {
sync.RWMutex sync.RWMutex
proxy proxy.InboundHandler proxy proxy.Inbound
hub *udp.Hub hub *udp.Hub
address v2net.Address address v2net.Address
port v2net.Port port v2net.Port
@ -264,6 +264,6 @@ func (w *udpWorker) Port() v2net.Port {
return w.port return w.port
} }
func (w *udpWorker) Proxy() proxy.InboundHandler { func (w *udpWorker) Proxy() proxy.Inbound {
return w.proxy return w.proxy
} }

View File

@ -20,7 +20,7 @@ import (
type Handler struct { type Handler struct {
config *proxyman.OutboundHandlerConfig config *proxyman.OutboundHandlerConfig
senderSettings *proxyman.SenderConfig senderSettings *proxyman.SenderConfig
proxy proxy.OutboundHandler proxy proxy.Outbound
outboundManager proxyman.OutboundHandlerManager outboundManager proxyman.OutboundHandlerManager
} }

View File

@ -22,7 +22,7 @@ type InboundHandler interface {
Close() Close()
// For migration // For migration
GetRandomInboundProxy() (proxy.InboundHandler, net.Port, int) GetRandomInboundProxy() (proxy.Inbound, net.Port, int)
} }
type OutboundHandlerManager interface { type OutboundHandlerManager interface {

View File

@ -7,26 +7,26 @@ import (
"v2ray.com/core/common/errors" "v2ray.com/core/common/errors"
) )
func CreateInboundHandler(ctx context.Context, config interface{}) (InboundHandler, error) { func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
handler, err := common.CreateObject(ctx, config) handler, err := common.CreateObject(ctx, config)
if err != nil { if err != nil {
return nil, err return nil, err
} }
switch h := handler.(type) { switch h := handler.(type) {
case InboundHandler: case Inbound:
return h, nil return h, nil
default: default:
return nil, errors.New("Proxy: Not a InboundHandler.") return nil, errors.New("Proxy: Not a InboundHandler.")
} }
} }
func CreateOutboundHandler(ctx context.Context, config interface{}) (OutboundHandler, error) { func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
handler, err := common.CreateObject(ctx, config) handler, err := common.CreateObject(ctx, config)
if err != nil { if err != nil {
return nil, err return nil, err
} }
switch h := handler.(type) { switch h := handler.(type) {
case OutboundHandler: case Outbound:
return h, nil return h, nil
default: default:
return nil, errors.New("Proxy: Not a OutboundHandler.") return nil, errors.New("Proxy: Not a OutboundHandler.")

View File

@ -9,15 +9,15 @@ import (
"v2ray.com/core/transport/ray" "v2ray.com/core/transport/ray"
) )
// An InboundHandler handles inbound network connections to V2Ray. // An Inbound processes inbound connections.
type InboundHandler interface { type Inbound interface {
Network() net.NetworkList Network() net.NetworkList
Process(context.Context, net.Network, internet.Connection) error Process(context.Context, net.Network, internet.Connection) error
} }
// An OutboundHandler handles outbound network connection for V2Ray. // An Outbound process outbound connections.
type OutboundHandler interface { type Outbound interface {
Process(context.Context, ray.OutboundRay) error Process(context.Context, ray.OutboundRay) error
} }