Last active
June 6, 2026 04:58
-
-
Save timsonner/9657b3a3c29694d5439865a3df614ad2 to your computer and use it in GitHub Desktop.
Hack to allow Pangolin tunnel over mobile hotspot on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Fixes Pangolin DNS issues with some mobile hotspots where they don't allow 1.1.1.1 or others and force device to use 172.20.10.1:53 | |
| # This patches olm config file on the fly to allow connection. Allows Pangolin tunnel over personal hotspot. uWu. | |
| # Run in elevated PowerShell terminal | |
| # Get the active network's DNS server IP (excluding loopback and Pangolin itself) | |
| $dnsServers = @(Get-DnsClientServerAddress -AddressFamily IPv4 | | |
| Where-Object { $_.InterfaceAlias -ne "Pangolin" -and $_.InterfaceAlias -notlike "Loopback*" -and $_.ServerAddresses.Count -gt 0 } | | |
| Select-Object -ExpandProperty ServerAddresses) | |
| if ($dnsServers.Count -eq 0) { | |
| Write-Host "No active DNS server found. Are you connected to Wi-Fi/Ethernet?" -ForegroundColor Red | |
| exit | |
| } | |
| $activeDns = $dnsServers[0] | |
| Write-Host "Detected active DNS Server: $activeDns" -ForegroundColor Green | |
| $configPath = "C:\ProgramData\Pangolin\Tunnels\olm.json" | |
| if (-not (Test-Path $configPath)) { | |
| Write-Host "Pangolin configuration file not found at $configPath." -ForegroundColor Red | |
| exit | |
| } | |
| # Stop the tunnel service | |
| Write-Host "Stopping Pangolin tunnel service..." | |
| Stop-Service -Name 'PangolinTunnel$olm' -ErrorAction SilentlyContinue | |
| # Remove read-only attribute if present | |
| if ((Get-Item $configPath).IsReadOnly) { | |
| Set-ItemProperty -Path $configPath -Name IsReadOnly -Value $false | |
| } | |
| # Read and modify config | |
| $config = Get-Content $configPath -Raw | ConvertFrom-Json | |
| $config.dns = $activeDns | |
| $config.upstreamDns = @("$activeDns`:53") | |
| $jsonText = $config | ConvertTo-Json -Depth 10 -Compress | |
| # Write file without UTF-8 BOM to prevent Go parsing errors | |
| [System.IO.File]::WriteAllText($configPath, $jsonText, [System.Text.UTF8Encoding]::new($false)) | |
| # Set back to read-only to prevent UI overwrite | |
| Set-ItemProperty -Path $configPath -Name IsReadOnly -Value $true | |
| # Start service | |
| Write-Host "Starting Pangolin tunnel service..." | |
| Start-Service -Name 'PangolinTunnel$olm' -ErrorAction SilentlyContinue | |
| Write-Host "Pangolin DNS fix applied successfully!" -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment