1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -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
}
func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.OutboundHandler, error) {
func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.Outbound, error) {
if c == nil {
return nil, errors.New("Proxyman: OutboundHandlerConfig is nil.")
}

View File

@ -11,7 +11,7 @@ import (
)
type AlwaysOnInboundHandler struct {
proxy proxy.InboundHandler
proxy proxy.Inbound
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))]
return w.Proxy(), w.Port(), 9999
}

View File

@ -136,7 +136,7 @@ func (h *DynamicInboundHandler) Close() {
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))]
expire := h.receiverConfig.AllocationStrategy.GetRefreshValue() - uint32(time.Since(h.lastRefresh)/time.Minute)
return w.Proxy(), w.Port(), int(expire)

View File

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

View File

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

View File

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

View File

@ -7,26 +7,26 @@ import (
"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)
if err != nil {
return nil, err
}
switch h := handler.(type) {
case InboundHandler:
case Inbound:
return h, nil
default:
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)
if err != nil {
return nil, err
}
switch h := handler.(type) {
case OutboundHandler:
case Outbound:
return h, nil
default:
return nil, errors.New("Proxy: Not a OutboundHandler.")

View File

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