1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

more docs

This commit is contained in:
v2ray 2016-02-06 18:01:27 +01:00
parent b53fddf229
commit 45db388e3f
6 changed files with 8 additions and 8 deletions

View File

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

View File

@ -1,3 +1,2 @@
// Package net contains common network utilities.
package net // import "github.com/v2ray/v2ray-core/common/net"

View File

@ -1,5 +1,4 @@
// Package proxy contains all proxies used by V2Ray.
package proxy // import "github.com/v2ray/v2ray-core/proxy"
import (

View File

@ -1,5 +1,4 @@
// R.I.P Shadowsocks
package shadowsocks
import (

View File

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

View File

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