A Python port of the Invisible Internet Project (I2P)
at main 54 lines 1.6 kB view raw
1# I2P Router Windows Firewall Rules 2# Run from an elevated PowerShell prompt: 3# powershell -ExecutionPolicy Bypass -File firewall.ps1 4# 5# To remove rules: 6# powershell -ExecutionPolicy Bypass -File firewall.ps1 -Remove 7 8param( 9 [switch]$Remove 10) 11 12$rules = @( 13 @{ 14 Name = "I2P Router NTCP2 (TCP)" 15 Protocol = "TCP" 16 LocalPort = 9700 17 Description = "I2P NTCP2 transport protocol" 18 }, 19 @{ 20 Name = "I2P Router SSU2 (UDP)" 21 Protocol = "UDP" 22 LocalPort = 9700 23 Description = "I2P SSU2 transport protocol" 24 } 25) 26 27if ($Remove) { 28 foreach ($rule in $rules) { 29 $existing = Get-NetFirewallRule -DisplayName $rule.Name -ErrorAction SilentlyContinue 30 if ($existing) { 31 Remove-NetFirewallRule -DisplayName $rule.Name 32 Write-Host "Removed: $($rule.Name)" 33 } else { 34 Write-Host "Not found: $($rule.Name)" 35 } 36 } 37} else { 38 foreach ($rule in $rules) { 39 $existing = Get-NetFirewallRule -DisplayName $rule.Name -ErrorAction SilentlyContinue 40 if ($existing) { 41 Write-Host "Already exists: $($rule.Name)" 42 } else { 43 New-NetFirewallRule ` 44 -DisplayName $rule.Name ` 45 -Direction Inbound ` 46 -Protocol $rule.Protocol ` 47 -LocalPort $rule.LocalPort ` 48 -Action Allow ` 49 -Description $rule.Description ` 50 -Profile Any 51 Write-Host "Created: $($rule.Name)" 52 } 53 } 54}