Create a gist now

Instantly share code, notes, and snippets.

@seanhenry /Gemfile
Last active Nov 29, 2017

What would you like to do?
Source: Better network debugging with Charles Proxy and iOS. See original post for explanation http://seanhenry.codes/ios/better-network-debugging-charles-proxy-ios/
source 'https://rubygems.org' do
gem 'sinatra'
end
#!/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
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