public static string AddFirewallRule(Connection connection) { var result = string.Empty; switch (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { case true: result = WindowsFirewall.BlockIpConnection(connection); break; case false: result = LinuxFirewall.BlockIpConnection(connection); break; } return(result); }
public static string RemoveFirewallRule(Connection connection, PluginConfiguration config) { var result = string.Empty; switch (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { case true: result = WindowsFirewall.AllowIpConnection(connection); config.BannedConnections.Remove(connection); Plugin.Instance.UpdateConfiguration(config); break; case false: result = LinuxFirewall.AllowIpConnection(connection); config.BannedConnections.Remove(connection); Plugin.Instance.UpdateConfiguration(config); break; } return(result); }