1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00
v2fly/net/sockshandler.go
2015-09-07 14:49:40 +02:00

36 lines
654 B
Go

package net
import (
"net"
)
// SocksServer is a SOCKS 5 proxy server
type SocksServer struct {
accepting bool
}
func (server *SocksServer) Listen(port uint8) error {
listener, err := net.Listen("tcp", ":"+string(port))
if err != nil {
return err
}
server.accepting = true
go server.AcceptConns(listener)
return nil
}
func (server *SocksServer) AcceptConnections(listener net.Listener) error {
for server.accepting {
connection, err := listener.Accept()
if err != nil {
return err
}
go server.HandleConnection(connection)
}
return nil
}
func (server *SocksServer) HandleConnection(connection *net.Conn) error {
return nil
}