mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
fix
This commit is contained in:
@@ -72,6 +72,7 @@ func ServeProtect(path string, fwmark int) {
|
||||
log.Println("getOneFd:", err)
|
||||
return
|
||||
}
|
||||
defer syscall.Close(fd)
|
||||
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, fwmark); err != nil {
|
||||
log.Println("syscall.SetsockoptInt:", err)
|
||||
|
||||
@@ -2,9 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io"
|
||||
"log"
|
||||
"nekoray_core/protect_server"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/jsimonetti/rtnetlink"
|
||||
linuxcap "kernel.org/pub/linux/libs/security/libcap/cap"
|
||||
@@ -63,5 +67,27 @@ func ToolBox() {
|
||||
log.Println(protectListenPath, protectFwMark)
|
||||
protect_server.ServeProtect(protectListenPath, protectFwMark)
|
||||
}
|
||||
case "btd": // Test the permission
|
||||
{
|
||||
d := &net.Dialer{
|
||||
Control: func(network, address string, c syscall.RawConn) (err error) {
|
||||
c.Control(func(fd uintptr) {
|
||||
err = syscall.BindToDevice(int(fd), os.Args[3])
|
||||
})
|
||||
return
|
||||
},
|
||||
}
|
||||
c := http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialContext: d.DialContext,
|
||||
},
|
||||
}
|
||||
resp, err := c.Get(os.Args[4])
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
io.Copy(os.Stdout, resp.Body)
|
||||
resp.Body.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user