From 82ffa7ca3e84efe789cd77b361e66f931116b755 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Fri, 31 Dec 2021 01:36:50 +0100 Subject: [PATCH] New function firewallDetectIndicatorFile to detect the presence of the indicator file created by the setup. --- Networks.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Networks.go b/Networks.go index 28e32bf..cd3b794 100644 --- a/Networks.go +++ b/Networks.go @@ -7,6 +7,7 @@ Author: Peter Kleissner package core import ( + "os" "sync" "github.com/PeernetOfficial/core/protocol" @@ -60,5 +61,23 @@ func (backend *Backend) initMessageSequence() { // Windows: If the user runs as non-admin, it can be assumed that the Windows Firewall creates a rule to drop unsolicited incoming packets. // Changing the Windows Firewall (via netsh or otherwise) requires elevated admin rights. // This flag will be passed on to other peers to indicate that uncontacted peers shall use the Traverse message for establishing connections. + backend.firewallDetectIndicatorFile() backend.networks.localFirewall = backend.Config.LocalFirewall } + +const firewallIndicatorFile = "firewallnotset" + +// Detects the file "firewallnotset". It may be set by an Peernet client installer to indicate the presence of a local firewall. +func (backend *Backend) firewallDetectIndicatorFile() { + if _, err := os.Stat(firewallIndicatorFile); err == nil { + // If the config firewall flag isn't set, set it. + if !backend.Config.LocalFirewall { + backend.Config.LocalFirewall = true + + backend.SaveConfig() + } + + // the indicator is one-time only, remove + os.Remove(firewallIndicatorFile) + } +}