You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
566 B

4 years ago
package tunnel
import (
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
4 years ago
)
// Unbuffered TCP/UDP queues.
4 years ago
var (
_tcpQueue = make(chan adapter.TCPConn)
_udpQueue = make(chan adapter.UDPConn)
4 years ago
)
func init() {
go process()
}
// TCPIn return fan-in TCP queue.
func TCPIn() chan<- adapter.TCPConn {
return _tcpQueue
4 years ago
}
// UDPIn return fan-in UDP queue.
func UDPIn() chan<- adapter.UDPConn {
return _udpQueue
4 years ago
}
func process() {
for {
select {
case conn := <-_tcpQueue:
go handleTCPConn(conn)
case conn := <-_udpQueue:
go handleUDPConn(conn)
}
4 years ago
}
}