mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
Full implementation of Socks5 protocol, proxying is on the way
This commit is contained in:
1 parent
5317b7d112
commit
fb1ad8b81b
7 files changed
+121
-10
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package socks
|
||||
|
||||
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.AcceptConnections(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
|
||||
}
|
||||
Reference in new issue
Block a user