Skip to content

Instantly share code, notes, and snippets.

@amiorin
Last active December 21, 2018 14:39
Show Gist options
  • Save amiorin/af0fe57a03bacf1b3c47effef6d3447d to your computer and use it in GitHub Desktop.
Save amiorin/af0fe57a03bacf1b3c47effef6d3447d to your computer and use it in GitHub Desktop.
function regExpMatch(url, pattern) {
try { return new RegExp(pattern).test(url); } catch(ex) { return false; }
}
function FindProxyForURL(url, host) {
// Important: replace 172.31 below with the proper prefix for your VPC subnet
if (shExpMatch(url, "*172.31.*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*saiki.zalan.do*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*ec2*.amazonaws.com*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*.compute.internal*") || shExpMatch(url, "*://compute.internal*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*ec2.internal*")) return 'SOCKS5 localhost:8157';
return 'DIRECT';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment