Created
March 31, 2024 14:10
-
-
Save Sucareto/4c27cde6afddce3704ee2f9704659a0c to your computer and use it in GitHub Desktop.
让 wsa 使用 windows 的 http 代理(已弃用)
This file contains 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
# 启动任意 wsa 程序 | |
Start-Process "wsa://jp.co.craftegg.band" | |
timeout 3 | Out-Null | |
Remove-NetFirewallRule -DisplayName "WSLCore" | Out-Null # 删除旧的防火墙规则并重新添加 | |
New-NetFirewallRule -DisplayName "WSLCore" -Direction Inbound -InterfaceAlias "vEthernet (WSLCore)" -Action Allow | Out-Null | |
# 获取 WSA IP | |
$ip = Get-NetIPAddress -InterfaceAlias 'vEthernet (WSLCore)' -AddressFamily IPV4 | Select-Object -ExpandProperty IPAddress | |
Write-Output "添加端口映射" | |
netsh interface portproxy reset # 清除端口映射规则,然后重新添加,wsa 访问 28080 将会转发到 windows 的 127.0.0.1:8080 | |
netsh interface portproxy add v4tov4 listenport=28080 listenaddress=$ip connectport=8080 connectaddress=127.0.0.1 | |
adb connect 127.0.0.1:58526 2>&1 > $null # adb 连接 wsa,设置 http 代理 | |
adb shell 'settings put global http_proxy `ip route list match 0 table all scope global | cut -F3`:28080' | |
netsh interface portproxy show all | |
timeout 3 | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment