# I2P Router Windows Firewall Rules # Run from an elevated PowerShell prompt: # powershell -ExecutionPolicy Bypass -File firewall.ps1 # # To remove rules: # powershell -ExecutionPolicy Bypass -File firewall.ps1 -Remove param( [switch]$Remove ) $rules = @( @{ Name = "I2P Router NTCP2 (TCP)" Protocol = "TCP" LocalPort = 9700 Description = "I2P NTCP2 transport protocol" }, @{ Name = "I2P Router SSU2 (UDP)" Protocol = "UDP" LocalPort = 9700 Description = "I2P SSU2 transport protocol" } ) if ($Remove) { foreach ($rule in $rules) { $existing = Get-NetFirewallRule -DisplayName $rule.Name -ErrorAction SilentlyContinue if ($existing) { Remove-NetFirewallRule -DisplayName $rule.Name Write-Host "Removed: $($rule.Name)" } else { Write-Host "Not found: $($rule.Name)" } } } else { foreach ($rule in $rules) { $existing = Get-NetFirewallRule -DisplayName $rule.Name -ErrorAction SilentlyContinue if ($existing) { Write-Host "Already exists: $($rule.Name)" } else { New-NetFirewallRule ` -DisplayName $rule.Name ` -Direction Inbound ` -Protocol $rule.Protocol ` -LocalPort $rule.LocalPort ` -Action Allow ` -Description $rule.Description ` -Profile Any Write-Host "Created: $($rule.Name)" } } }