From 45db388e3f38e8456625509ecb2fa9f953b42d47 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 6 Feb 2016 18:01:27 +0100 Subject: [PATCH] more docs --- common/dice/dice.go | 1 - common/net/net.go | 1 - proxy/proxy.go | 1 - proxy/shadowsocks/shadowsocks.go | 1 - proxy/socks/socks.go | 10 +++++++--- proxy/socks/udp.go | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/dice/dice.go b/common/dice/dice.go index 8e3a061a..c737e1cf 100644 --- a/common/dice/dice.go +++ b/common/dice/dice.go @@ -1,6 +1,5 @@ // Package dice contains common functions to generate random number. // It also initialize math/rand with the time in seconds at launch time. - package dice import ( diff --git a/common/net/net.go b/common/net/net.go index 0984a804..5daa36e0 100644 --- a/common/net/net.go +++ b/common/net/net.go @@ -1,3 +1,2 @@ // Package net contains common network utilities. - package net // import "github.com/v2ray/v2ray-core/common/net" diff --git a/proxy/proxy.go b/proxy/proxy.go index 43febe1d..4562de25 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -1,5 +1,4 @@ // Package proxy contains all proxies used by V2Ray. - package proxy // import "github.com/v2ray/v2ray-core/proxy" import ( diff --git a/proxy/shadowsocks/shadowsocks.go b/proxy/shadowsocks/shadowsocks.go index 633bb217..1dc0519f 100644 --- a/proxy/shadowsocks/shadowsocks.go +++ b/proxy/shadowsocks/shadowsocks.go @@ -1,5 +1,4 @@ // R.I.P Shadowsocks - package shadowsocks import ( diff --git a/proxy/socks/socks.go b/proxy/socks/socks.go index 62819965..37c52265 100644 --- a/proxy/socks/socks.go +++ b/proxy/socks/socks.go @@ -35,6 +35,7 @@ type SocksServer struct { listeningPort v2net.Port } +// NewSocksSocks creates a new SocksServer object. func NewSocksServer(config *Config, packetDispatcher dispatcher.PacketDispatcher) *SocksServer { return &SocksServer{ config: config, @@ -42,10 +43,12 @@ func NewSocksServer(config *Config, packetDispatcher dispatcher.PacketDispatcher } } +// Port implements InboundHandler.Port(). func (this *SocksServer) Port() v2net.Port { return this.listeningPort } +// Close implements InboundHandler.Close(). func (this *SocksServer) Close() { this.accepting = false if this.tcpListener != nil { @@ -62,6 +65,7 @@ func (this *SocksServer) Close() { } } +// Listen implements InboundHandler.Listen(). func (this *SocksServer) Listen(port v2net.Port) error { if this.accepting { if this.listeningPort == port { @@ -72,7 +76,7 @@ func (this *SocksServer) Listen(port v2net.Port) error { } this.listeningPort = port - listener, err := hub.ListenTCP(port, this.HandleConnection) + listener, err := hub.ListenTCP(port, this.handleConnection) if err != nil { log.Error("Socks: failed to listen on port ", port, ": ", err) return err @@ -82,12 +86,12 @@ func (this *SocksServer) Listen(port v2net.Port) error { this.tcpListener = listener this.tcpMutex.Unlock() if this.config.UDPEnabled { - this.ListenUDP(port) + this.listenUDP(port) } return nil } -func (this *SocksServer) HandleConnection(connection *hub.TCPConn) { +func (this *SocksServer) handleConnection(connection *hub.TCPConn) { defer connection.Close() reader := v2net.NewTimeOutReader(120, connection) diff --git a/proxy/socks/udp.go b/proxy/socks/udp.go index cb1aa8a5..561c18d4 100644 --- a/proxy/socks/udp.go +++ b/proxy/socks/udp.go @@ -8,7 +8,7 @@ import ( "github.com/v2ray/v2ray-core/transport/hub" ) -func (this *SocksServer) ListenUDP(port v2net.Port) error { +func (this *SocksServer) listenUDP(port v2net.Port) error { this.udpServer = hub.NewUDPServer(this.packetDispatcher) udpHub, err := hub.ListenUDP(port, this.handleUDPPayload) if err != nil {