rename udp.Server

pull/330/merge
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 sync.Mutex
address v2net.Destination address v2net.Destination
requests map[uint16]*PendingRequest requests map[uint16]*PendingRequest
udpServer *udp.Server udpServer *udp.Dispatcher
nextCleanup time.Time nextCleanup time.Time
} }
@ -51,7 +51,7 @@ func NewUDPNameServer(address v2net.Destination, dispatcher dispatcher.Interface
s := &UDPNameServer{ s := &UDPNameServer{
address: address, address: address,
requests: make(map[uint16]*PendingRequest), requests: make(map[uint16]*PendingRequest),
udpServer: udp.NewServer(dispatcher), udpServer: udp.NewDispatcher(dispatcher),
} }
return s return s
} }

View File

@ -23,7 +23,7 @@ type Server struct {
config *ServerConfig config *ServerConfig
user *protocol.User user *protocol.User
account *ShadowsocksAccount account *ShadowsocksAccount
udpServer *udp.Server udpServer *udp.Dispatcher
} }
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {

View File

@ -24,7 +24,7 @@ import (
type Server struct { type Server struct {
packetDispatcher dispatcher.Interface packetDispatcher dispatcher.Interface
config *ServerConfig config *ServerConfig
udpServer *udp.Server udpServer *udp.Dispatcher
} }
// NewServer creates a new Server object. // NewServer creates a new Server object.
@ -41,7 +41,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
if s.packetDispatcher == nil { if s.packetDispatcher == nil {
return errors.New("Socks|Server: Dispatcher is not found in the space.") 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 nil
}) })
return s, nil return s, nil

View File

@ -14,20 +14,20 @@ import (
type ResponseCallback func(payload *buf.Buffer) type ResponseCallback func(payload *buf.Buffer)
type Server struct { type Dispatcher struct {
sync.RWMutex sync.RWMutex
conns map[string]ray.InboundRay conns map[string]ray.InboundRay
packetDispatcher dispatcher.Interface packetDispatcher dispatcher.Interface
} }
func NewServer(packetDispatcher dispatcher.Interface) *Server { func NewDispatcher(packetDispatcher dispatcher.Interface) *Dispatcher {
return &Server{ return &Dispatcher{
conns: make(map[string]ray.InboundRay), conns: make(map[string]ray.InboundRay),
packetDispatcher: packetDispatcher, packetDispatcher: packetDispatcher,
} }
} }
func (v *Server) RemoveRay(name string) { func (v *Dispatcher) RemoveRay(name string) {
v.Lock() v.Lock()
defer v.Unlock() defer v.Unlock()
if conn, found := v.conns[name]; found { 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() destString := dest.String()
v.Lock() v.Lock()
defer v.Unlock() defer v.Unlock()
@ -51,7 +51,7 @@ func (v *Server) getInboundRay(ctx context.Context, dest v2net.Destination) (ray
return v.packetDispatcher.DispatchToOutbound(ctx), false 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 // TODO: Add user to destString
destString := destination.String() destString := destination.String()
log.Debug("UDP|Server: Dispatch request: ", destString) log.Debug("UDP|Server: Dispatch request: ", destString)