mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
remove unnecessary proxy functions
This commit is contained in:
parent
42d83a703e
commit
92aef24f98
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/app/proxyman/mux"
|
"v2ray.com/core/app/proxyman/mux"
|
||||||
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/dice"
|
"v2ray.com/core/common/dice"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/proxy"
|
"v2ray.com/core/proxy"
|
||||||
@ -18,10 +19,14 @@ type AlwaysOnInboundHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*AlwaysOnInboundHandler, error) {
|
func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*AlwaysOnInboundHandler, error) {
|
||||||
p, err := proxy.CreateInboundHandler(ctx, proxyConfig)
|
rawProxy, err := common.CreateObject(ctx, proxyConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
p, ok := rawProxy.(proxy.Inbound)
|
||||||
|
if !ok {
|
||||||
|
return nil, newError("not an inbound proxy.")
|
||||||
|
}
|
||||||
|
|
||||||
h := &AlwaysOnInboundHandler{
|
h := &AlwaysOnInboundHandler{
|
||||||
proxy: p,
|
proxy: p,
|
||||||
@ -80,6 +85,7 @@ func (h *AlwaysOnInboundHandler) Close() error {
|
|||||||
for _, worker := range h.workers {
|
for _, worker := range h.workers {
|
||||||
worker.Close()
|
worker.Close()
|
||||||
}
|
}
|
||||||
|
h.mux.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/app/proxyman/mux"
|
"v2ray.com/core/app/proxyman/mux"
|
||||||
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/proxy"
|
"v2ray.com/core/proxy"
|
||||||
@ -50,11 +51,16 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (*Handl
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyHandler, err := proxy.CreateOutboundHandler(ctx, proxyConfig)
|
rawProxyHandler, err := common.CreateObject(ctx, proxyConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxyHandler, ok := rawProxyHandler.(proxy.Outbound)
|
||||||
|
if !ok {
|
||||||
|
return nil, newError("not an outbound handler")
|
||||||
|
}
|
||||||
|
|
||||||
if h.senderSettings != nil && h.senderSettings.MultiplexSettings != nil && h.senderSettings.MultiplexSettings.Enabled {
|
if h.senderSettings != nil && h.senderSettings.MultiplexSettings != nil && h.senderSettings.MultiplexSettings.Enabled {
|
||||||
config := h.senderSettings.MultiplexSettings
|
config := h.senderSettings.MultiplexSettings
|
||||||
if config.Concurrency < 1 || config.Concurrency > 1024 {
|
if config.Concurrency < 1 || config.Concurrency > 1024 {
|
||||||
@ -134,5 +140,6 @@ func (h *Handler) Start() error {
|
|||||||
|
|
||||||
// Close implements common.Runnable.
|
// Close implements common.Runnable.
|
||||||
func (h *Handler) Close() error {
|
func (h *Handler) Close() error {
|
||||||
|
common.Close(h.mux)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
|
|
||||||
handler, err := common.CreateObject(ctx, config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to create inbound handler").Base(err)
|
|
||||||
}
|
|
||||||
switch h := handler.(type) {
|
|
||||||
case Inbound:
|
|
||||||
return h, nil
|
|
||||||
default:
|
|
||||||
return nil, newError("not a InboundHandler")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
|
|
||||||
handler, err := common.CreateObject(ctx, config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, newError("failed to create outbound handler").Base(err)
|
|
||||||
}
|
|
||||||
switch h := handler.(type) {
|
|
||||||
case Outbound:
|
|
||||||
return h, nil
|
|
||||||
default:
|
|
||||||
return nil, newError("not a OutboundHandler")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user