mirror of https://github.com/v2ray/v2ray-core
rename udp.Server
parent
83c35c1e41
commit
18e1ca85aa
|
@ -43,7 +43,7 @@ type UDPNameServer struct {
|
|||
sync.Mutex
|
||||
address v2net.Destination
|
||||
requests map[uint16]*PendingRequest
|
||||
udpServer *udp.Server
|
||||
udpServer *udp.Dispatcher
|
||||
nextCleanup time.Time
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func NewUDPNameServer(address v2net.Destination, dispatcher dispatcher.Interface
|
|||
s := &UDPNameServer{
|
||||
address: address,
|
||||
requests: make(map[uint16]*PendingRequest),
|
||||
udpServer: udp.NewServer(dispatcher),
|
||||
udpServer: udp.NewDispatcher(dispatcher),
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ type Server struct {
|
|||
config *ServerConfig
|
||||
user *protocol.User
|
||||
account *ShadowsocksAccount
|
||||
udpServer *udp.Server
|
||||
udpServer *udp.Dispatcher
|
||||
}
|
||||
|
||||
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
type Server struct {
|
||||
packetDispatcher dispatcher.Interface
|
||||
config *ServerConfig
|
||||
udpServer *udp.Server
|
||||
udpServer *udp.Dispatcher
|
||||
}
|
||||
|
||||
// NewServer creates a new Server object.
|
||||
|
@ -41,7 +41,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
|||
if s.packetDispatcher == nil {
|
||||
return errors.New("Socks|Server: Dispatcher is not found in the space.")
|
||||
}
|
||||
s.udpServer = udp.NewServer(s.packetDispatcher)
|
||||
s.udpServer = udp.NewDispatcher(s.packetDispatcher)
|
||||
return nil
|
||||
})
|
||||
return s, nil
|
||||
|
|
|
@ -14,20 +14,20 @@ import (
|
|||
|
||||
type ResponseCallback func(payload *buf.Buffer)
|
||||
|
||||
type Server struct {
|
||||
type Dispatcher struct {
|
||||
sync.RWMutex
|
||||
conns map[string]ray.InboundRay
|
||||
packetDispatcher dispatcher.Interface
|
||||
}
|
||||
|
||||
func NewServer(packetDispatcher dispatcher.Interface) *Server {
|
||||
return &Server{
|
||||
func NewDispatcher(packetDispatcher dispatcher.Interface) *Dispatcher {
|
||||
return &Dispatcher{
|
||||
conns: make(map[string]ray.InboundRay),
|
||||
packetDispatcher: packetDispatcher,
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Server) RemoveRay(name string) {
|
||||
func (v *Dispatcher) RemoveRay(name string) {
|
||||
v.Lock()
|
||||
defer v.Unlock()
|
||||
if conn, found := v.conns[name]; found {
|
||||
|
@ -37,7 +37,7 @@ func (v *Server) RemoveRay(name string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (v *Server) getInboundRay(ctx context.Context, dest v2net.Destination) (ray.InboundRay, bool) {
|
||||
func (v *Dispatcher) getInboundRay(ctx context.Context, dest v2net.Destination) (ray.InboundRay, bool) {
|
||||
destString := dest.String()
|
||||
v.Lock()
|
||||
defer v.Unlock()
|
||||
|
@ -51,7 +51,7 @@ func (v *Server) getInboundRay(ctx context.Context, dest v2net.Destination) (ray
|
|||
return v.packetDispatcher.DispatchToOutbound(ctx), false
|
||||
}
|
||||
|
||||
func (v *Server) Dispatch(ctx context.Context, destination v2net.Destination, payload *buf.Buffer, callback ResponseCallback) {
|
||||
func (v *Dispatcher) Dispatch(ctx context.Context, destination v2net.Destination, payload *buf.Buffer, callback ResponseCallback) {
|
||||
// TODO: Add user to destString
|
||||
destString := destination.String()
|
||||
log.Debug("UDP|Server: Dispatch request: ", destString)
|
Loading…
Reference in New Issue