mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-16 19:00:05 +07:00
optimize: disable send_redirects for Real Direct
This commit is contained in:
@ -87,12 +87,16 @@ func checkIpforward(ifname string, ipversion consts.IpVersionStr) error {
|
||||
path := fmt.Sprintf("/proc/sys/net/ipv%v/conf/%v/forwarding", ipversion, ifname)
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Kernel does not support.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
if bytes.Equal(bytes.TrimSpace(b), []byte("1")) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("ipforward on %v is off: %v; see https://github.com/v2rayA/dae#enable-ip-forwarding", ifname, path)
|
||||
return fmt.Errorf("ipforward on %v is off: %v; see https://github.com/v2rayA/dae#kernel-parameters", ifname, path)
|
||||
}
|
||||
|
||||
func CheckIpforward(ifname string) error {
|
||||
@ -105,6 +109,32 @@ func CheckIpforward(ifname string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkSendRedirects(ifname string, ipversion consts.IpVersionStr) error {
|
||||
path := fmt.Sprintf("/proc/sys/net/ipv%v/conf/%v/send_redirects", ipversion, ifname)
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Kernel does not support.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
if bytes.Equal(bytes.TrimSpace(b), []byte("0")) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("send_directs on %v is on: %v; see https://github.com/v2rayA/dae#kernel-parameters", ifname, path)
|
||||
}
|
||||
|
||||
func CheckSendRedirects(ifname string) error {
|
||||
if err := checkSendRedirects(ifname, consts.IpVersionStr_4); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkSendRedirects(ifname, consts.IpVersionStr_6); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func MagicNetwork(network string, mark uint32) string {
|
||||
if mark == 0 {
|
||||
return network
|
||||
|
Reference in New Issue
Block a user