Skip to content

Instantly share code, notes, and snippets.

@Abreto
Last active January 1, 2020 13:39
Show Gist options
  • Save Abreto/647d2471d446f96c517a1e64065ab239 to your computer and use it in GitHub Desktop.
Save Abreto/647d2471d446f96c517a1e64065ab239 to your computer and use it in GitHub Desktop.
Use proxy of host-machine
# /etc/environment
ALL_PROXY="http://192.168.98.1:6152"
HTTP_PROXY="http://192.168.98.1:6152"
HTTPS_PROXY="http://192.168.98.1:6152"
SOCKS_PROXY="socks5://192.168.98.1:6153"
NO_PROXY="localhost,127.0.0.0/8,::1,.local,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,100.64.0.0/10"
all_proxy="http://192.168.98.1:6152"
http_proxy="http://192.168.98.1:6152"
https_proxy="http://192.168.98.1:6152"
socks_proxy="socks5://192.168.98.1:6153"
no_proxy="localhost,127.0.0.0/8,::1,.local,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,100.64.0.0/10"
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
}("+host-machine", {
"+host-machine": function(url, host, scheme) {
"use strict";
if (host[host.length - 1] >= 0 && isInNet(host, "127.0.0.0", "255.0.0.0") || /^::1$/.test(host) || /^localhost$/.test(host) || /\.local$/.test(host) || host[host.length - 1] >= 0 && isInNet(host, "192.168.0.0", "255.255.0.0") || host[host.length - 1] >= 0 && isInNet(host, "10.0.0.0", "255.0.0.0") || host[host.length - 1] >= 0 && isInNet(host, "172.16.0.0", "255.240.0.0") || host[host.length - 1] >= 0 && isInNet(host, "100.64.0.0", "255.192.0.0")) return "DIRECT";
switch (scheme) {
case "http":
return "PROXY 192.168.98.1:6152";
case "https":
return "HTTPS 192.168.98.1:6152";
case "ftp":
return "PROXY 192.168.98.1:6152";
default:
return "SOCKS5 192.168.98.1:6153; SOCKS 192.168.98.1:6153";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment