1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-26 09:25:23 +00:00

rename udp.Server

This commit is contained in:
Darien Raymond 2017-01-27 14:45:16 +01:00
parent 83c35c1e41
commit 18e1ca85aa
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
4 changed files with 11 additions and 11 deletions

View File

@ -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
}

View File

@ -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) {

View File

@ -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

View File

@ -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)