forked from eycorsican/go-tun2socks
-
Notifications
You must be signed in to change notification settings - Fork 7
/
handler.go
34 lines (25 loc) · 907 Bytes
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package core
import (
"net"
)
// ConnectionHandler handles connections comming from TUN.
type ConnectionHandler interface {
// Connect connects the proxy server.
Connect(conn Connection, target net.Addr) error
// DidReceive will be called when data arrives from TUN.
DidReceive(conn Connection, data []byte) error
// DidSend will be called when sent data has been acknowledged by local clients.
DidSend(conn Connection, len uint16)
// DidClose will be called when the connection has been closed.
DidClose(conn Connection)
// LocalDidClose will be called when local client has close the connection.
LocalDidClose(conn Connection)
}
var tcpConnectionHandler ConnectionHandler
var udpConnectionHandler ConnectionHandler
func RegisterTCPConnectionHandler(h ConnectionHandler) {
tcpConnectionHandler = h
}
func RegisterUDPConnectionHandler(h ConnectionHandler) {
udpConnectionHandler = h
}