Last active
February 19, 2022 21:00
-
-
Save seanhenry/2119670dea90e9415985f346b694a9b7 to your computer and use it in GitHub Desktop.
Source: Better network debugging with Charles Proxy and iOS. See original post for explanation http://seanhenry.codes/ios/better-network-debugging-charles-proxy-ios/
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
source 'https://rubygems.org' do | |
gem 'sinatra' | |
end |
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
#!/bin/sh | |
bundle | |
# Use `networksetup -listallnetworkservices` to list network device names. | |
networkdevice=Wi-Fi | |
systemip=$(ipconfig getifaddr en0) | |
address=http://localhost:4567/proxy.pac | |
externaladdress=http://$systemip:4567/proxy.pac | |
networksetup -setautoproxyurl "$networkdevice" $address | |
echo "***\n\n$externaladdress has been copied to your clipboard. Paste it in your automatic proxy settings in iOS.\n\n***" | |
echo $externaladdress | pbcopy | |
PUBLIC_IP=$systemip ruby server.rb -o 0.0.0.0 | |
networksetup -setautoproxystate "$networkdevice" off |
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
require 'sinatra' | |
require 'socket' | |
get '/proxy.pac' do | |
content_type 'text/plain' | |
ip = ENV['PUBLIC_IP'] | |
%(var proxy = "PROXY #{ip}:8888"; | |
var noProxy = "DIRECT"; | |
function FindProxyForURL(url, host) { | |
if (shExpMatch(host, "*.my-app.com")) { | |
return proxy; | |
} | |
return noProxy; | |
}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment