simplify dialer and dispatcher parameters

This commit is contained in:
Darien Raymond committed 2017-02-03 22:35:09 +01:00
1 parent 504ff4b0c4
commit c4d0227977
19 files changed
+152 -147

No files matched your search

+8 -9
View File
@@ -5,10 +5,9 @@ import (
"sync"
"v2ray.com/core/app/dispatcher"
"v2ray.com/core/common/buf"
"v2ray.com/core/app/log"
"v2ray.com/core/common/buf"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy"
"v2ray.com/core/transport/ray"
)
@@ -16,14 +15,14 @@ type ResponseCallback func(payload *buf.Buffer)
type Dispatcher struct {
sync.RWMutex
conns map[string]ray.InboundRay
packetDispatcher dispatcher.Interface
conns map[string]ray.InboundRay
dispatcher dispatcher.Interface
}
func NewDispatcher(packetDispatcher dispatcher.Interface) *Dispatcher {
func NewDispatcher(dispatcher dispatcher.Interface) *Dispatcher {
return &Dispatcher{
conns: make(map[string]ray.InboundRay),
packetDispatcher: packetDispatcher,
conns: make(map[string]ray.InboundRay),
dispatcher: dispatcher,
}
}
@@ -47,8 +46,8 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest v2net.Destination)
}
log.Info("UDP|Server: establishing new connection for ", dest)
ctx = proxy.ContextWithDestination(ctx, dest)
return v.packetDispatcher.DispatchToOutbound(ctx), false
inboundRay, _ := v.dispatcher.Dispatch(ctx, dest)
return inboundRay, false
}
func (v *Dispatcher) Dispatch(ctx context.Context, destination v2net.Destination, payload *buf.Buffer, callback ResponseCallback) {