Exemplo n.º 1
0
func (this *Server) Start() error {
	if this.accepting {
		return nil
	}

	tcpHub, err := internet.ListenTCP(this.meta.Address, this.meta.Port, this.handleConnection, this.meta.StreamSettings)
	if err != nil {
		log.Error("Shadowsocks: Failed to listen TCP on ", this.meta.Address, ":", this.meta.Port, ": ", err)
		return err
	}
	this.tcpHub = tcpHub

	if this.config.UdpEnabled {
		this.udpServer = udp.NewUDPServer(this.packetDispatcher)
		udpHub, err := udp.ListenUDP(this.meta.Address, this.meta.Port, udp.ListenOption{Callback: this.handlerUDPPayload})
		if err != nil {
			log.Error("Shadowsocks: Failed to listen UDP on ", this.meta.Address, ":", this.meta.Port, ": ", err)
			return err
		}
		this.udpHub = udpHub
	}

	this.accepting = true

	return nil
}
Exemplo n.º 2
0
func NewUDPNameServer(address v2net.Destination, dispatcher dispatcher.PacketDispatcher) *UDPNameServer {
	s := &UDPNameServer{
		address:   address,
		requests:  make(map[uint16]*PendingRequest),
		udpServer: udp.NewUDPServer(dispatcher),
	}
	return s
}
Exemplo n.º 3
0
func NewUDPNameServer(address v2net.Destination, dispatcher dispatcher.PacketDispatcher) *UDPNameServer {
	s := &UDPNameServer{
		address:  address,
		requests: make(map[uint16]*PendingRequest),
		udpServer: udp.NewUDPServer(&proxy.InboundHandlerMeta{
			AllowPassiveConnection: false,
		}, dispatcher),
	}
	return s
}
Exemplo n.º 4
0
func (this *Server) listenUDP() error {
	this.udpServer = udp.NewUDPServer(this.meta, this.packetDispatcher)
	udpHub, err := udp.ListenUDP(this.meta.Address, this.meta.Port, udp.ListenOption{Callback: this.handleUDPPayload})
	if err != nil {
		log.Error("Socks: Failed to listen on udp ", this.meta.Address, ":", this.meta.Port)
		return err
	}
	this.udpMutex.Lock()
	this.udpAddress = v2net.UDPDestination(this.config.Address, this.meta.Port)
	this.udpHub = udpHub
	this.udpMutex.Unlock()
	return nil
}
Exemplo n.º 5
0
func (v *Server) listenUDP() error {
	v.udpServer = udp.NewUDPServer(v.packetDispatcher)
	udpHub, err := udp.ListenUDP(v.meta.Address, v.meta.Port, udp.ListenOption{Callback: v.handleUDPPayload})
	if err != nil {
		log.Error("Socks: Failed to listen on udp (", v.meta.Address, ":", v.meta.Port, "): ", err)
		return err
	}
	v.udpMutex.Lock()
	v.udpAddress = v2net.UDPDestination(v.config.GetNetAddress(), v.meta.Port)
	v.udpHub = udpHub
	v.udpMutex.Unlock()
	return nil
}
Exemplo n.º 6
0
func (this *DokodemoDoor) ListenUDP() error {
	this.udpServer = udp.NewUDPServer(this.meta, this.packetDispatcher)
	udpHub, err := udp.ListenUDP(
		this.meta.Address, this.meta.Port, udp.ListenOption{
			Callback:            this.handleUDPPackets,
			ReceiveOriginalDest: this.config.FollowRedirect,
		})
	if err != nil {
		log.Error("Dokodemo failed to listen on ", this.meta.Address, ":", this.meta.Port, ": ", err)
		return err
	}
	this.udpMutex.Lock()
	this.udpHub = udpHub
	this.udpMutex.Unlock()
	return nil
}
Exemplo n.º 7
0
func (v *DokodemoDoor) ListenUDP() error {
	v.udpServer = udp.NewUDPServer(v.packetDispatcher)
	udpHub, err := udp.ListenUDP(
		v.meta.Address, v.meta.Port, udp.ListenOption{
			Callback:            v.handleUDPPackets,
			ReceiveOriginalDest: v.config.FollowRedirect,
			Concurrency:         2,
		})
	if err != nil {
		log.Error("Dokodemo failed to listen on ", v.meta.Address, ":", v.meta.Port, ": ", err)
		return err
	}
	v.udpMutex.Lock()
	v.udpHub = udpHub
	v.udpMutex.Unlock()
	return nil
}