mirror of
https://github.com/Threnklyn/wg-ui.git
synced 2026-06-04 20:59:16 +02:00
Only enable IP forwarding if it is disabled
Any value other than 0 is considered enabled: https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt Fixes #30
This commit is contained in:
@@ -112,9 +112,19 @@ func NewServer() *Server {
|
||||
}
|
||||
|
||||
func (s *Server) enableIPForward() error {
|
||||
log.Info("Enabling sys.net.ipv4.ip_forward")
|
||||
p := "/proc/sys/net/ipv4/ip_forward"
|
||||
return ioutil.WriteFile(p, []byte("1"), 0640)
|
||||
|
||||
content, err := ioutil.ReadFile(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if string(content) == "0\n" {
|
||||
log.Info("Enabling sys.net.ipv4.ip_forward")
|
||||
return ioutil.WriteFile(p, []byte("1"), 0640)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) initInterface() error {
|
||||
|
||||
Reference in New Issue
Block a user