Skip to content

Instantly share code, notes, and snippets.

@snowyyd
Last active March 6, 2026 02:30
Show Gist options
  • Select an option

  • Save snowyyd/af1dae0b712c7dfaa772ae9a7bc270ef to your computer and use it in GitHub Desktop.

Select an option

Save snowyyd/af1dae0b712c7dfaa772ae9a7bc270ef to your computer and use it in GitHub Desktop.
Deadlock Region Blocker
<#
Deadlock Region Blocker
A simple script to block Deadlock servers within one or more regions.
USAGE: powershell -ExecutionPolicy Bypass .\deadlock-regions.ps1
WARNING
-------
If you enter a lobby hosted in a blocked region (e.g., if two of your friends create a lobby and it is in a blocked region),
you will still be able to enter, but you will be routed to the closest possible region.
The best way to avoid this is for everyone to block the same regions,
or for at least two people with blocked regions to create a lobby first.
----------------------------------------------------------------------------------------------------------------------------------
KNOWN REGIONS
curl -s https://api.steampowered.com/ISteamApps/GetSDRConfig/v1/?appid=1422450 | jq '.pops | with_entries(.value = .value.desc)'
{
"ams": "Amsterdam (Netherlands)",
"atl": "Atlanta (Georgia)",
"dfw": "Dallas (Texas)",
"dxb": "Dubai (United Arab Emirates)",
"eat": "Wenatchee (Washington)",
"eze": "Buenos Aires (Argentina)",
"fra": "Frankfurt (Germany)",
"fsn": "Falkenstein (Germany)",
"gru": "Sao Paulo (Brazil)",
"hel": "Helsinki (Finland)",
"hkg": "Hong Kong",
"iad": "Sterling (Virginia)",
"jnb": "Johannesburg (South Africa)",
"lax": "Los Angeles (California)",
"lhr": "London (England)",
"lim": "Lima (Peru)",
"mad": "Madrid (Spain)",
"ord": "Chicago (Illinois)",
"par": "Paris (France)",
"scl": "Santiago (Chile)",
"sea": "Seattle (Washington)",
"seo": "Seoul (South Korea)",
"sgp": "Singapore",
"sto": "Stockholm - Kista (Sweden)",
"syd": "Sydney (Australia)",
"tyo": "Tokyo Koto City (Japan)",
"vie": "Vienna (Austria)",
"waw": "Warsaw (Poland)",
"bom2": "Mumbai (India)",
"maa2": "Chennai - Ambattur (India)",
"sto2": "Stockholm - Bromma (Sweden)",
"ams4": "Multiplay Amsterdam (Netherlands)",
"hkg4": "Multiplay Hong Kong"
}
----------------------------------------------------------------------------------------------------------------------------------
To block regions simply change the preconfigured list in `$BlacklistedPops = @("eze", "gru", "lim", "scl")`.
Example: To block `Amsterdam (Netherlands)` and `Atlanta (Georgia)`: $BlacklistedPops = @("ams", "atl")
#>
$ErrorActionPreference = "Stop"
try {
# Self-Elevation Wrapper
$IsAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $IsAdmin) {
Write-Host "Requesting administrative privileges..."
Start-Process powershell -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File `"$PSCommandPath`""
$global:ScriptSilentExit = $true
exit
}
# Configuration
$BlacklistedPops = @("eze", "gru", "lim", "scl")
$RuleGroupName = "Deadlock-Blacklisted-Regions"
$RulePrefix = "! [Region Block]"
$Url = "https://api.steampowered.com/ISteamApps/GetSDRConfig/v1/?appid=1422450"
# Remove old rules
Write-Host "Cleaning existing rules for group: $RuleGroupName"
Get-NetFirewallRule -Group $RuleGroupName -ErrorAction SilentlyContinue | Remove-NetFirewallRule
# Download config
Write-Host "Downloading Steam SDR config..."
$response = Invoke-RestMethod -Uri $Url -TimeoutSec 10
if (-not $response.success -or -not $response.pops) {
throw "Invalid API response."
}
# Process POPs
foreach ($pop in $BlacklistedPops) {
$popData = $response.pops.$pop
if (-not $popData -or -not $popData.relays) {
Write-Host "POP '$pop' not found or has no relays."
continue
}
Write-Host "Processing POP: $pop"
foreach ($relay in $popData.relays) {
$ip = $relay.ipv4
$portStart = $relay.port_range[0]
$portEnd = $relay.port_range[1]
$portRangeString = "$portStart-$portEnd"
# $ruleNameIn = "$RulePrefix <IN> $pop ($ip, $portRangeString)"
$ruleNameOut = "$RulePrefix <OUT> $pop ($ip, $portRangeString)"
# Inbound rule
<# New-NetFirewallRule `
-DisplayName $ruleNameIn `
-Group $RuleGroupName `
-Direction Inbound `
-RemoteAddress $ip `
-Protocol UDP `
-RemotePort $portRangeString `
-Action Block `
-Profile Any `
-Description "Added at $(Get-Date -Format 'yyyy-MM-dd')" `
*> $null #>
# Outbound rule
New-NetFirewallRule `
-DisplayName $ruleNameOut `
-Group $RuleGroupName `
-Direction Outbound `
-RemoteAddress $ip `
-Protocol UDP `
-RemotePort $portRangeString `
-Action Block `
-Profile Any `
-Description "Added at $(Get-Date -Format 'yyyy-MM-dd')" `
*> $null
Write-Host " Blocked $ip ($portRangeString)"
}
}
Write-Host "`nFinished updating Steam SDR blacklist rules."
}
catch {
Write-Host ""
Write-Host "ERROR DETECTED" -ForegroundColor Red
Write-Host "Message: $($_.Exception.Message)" -ForegroundColor Yellow
Write-Host "Line: $($_.InvocationInfo.ScriptLineNumber)"
Write-Host "Code: $($_.InvocationInfo.Line.Trim())"
$global:ScriptHadError = $true
}
finally {
if ($global:ScriptSilentExit) {
exit 0
}
Write-Host ""
# Write-Host "Press any key to exit..."
# $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host "Press INTRO to exit..."
$null = Read-Host
if ($global:ScriptHadError) {
exit 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment