forked from XTLS/libXray
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller_android.go
More file actions
27 lines (23 loc) · 808 Bytes
/
controller_android.go
File metadata and controls
27 lines (23 loc) · 808 Bytes
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
package libXray
import (
"syscall"
xinternet "github.com/xtls/xray-core/transport/internet"
)
// Give a callback before connection beginning. Useful for Android development.
// It depends on xray:api:beta
func RegisterDialerController(controller DialerController) {
xinternet.RegisterDialerController(func(network, address string, conn syscall.RawConn) error {
return conn.Control(func(fd uintptr) {
controller.ProtectFd(int(fd))
})
})
}
// Give a callback before listener beginning. Useful for Android development.
// It depends on xray:api:beta
func RegisterListenerController(controller DialerController) {
xinternet.RegisterListenerController(func(network, address string, conn syscall.RawConn) error {
return conn.Control(func(fd uintptr) {
controller.ProtectFd(int(fd))
})
})
}