-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INF-180] Add SOCKS5 proxy for use with client (#3467)
* Add socks5 proxy for use with client * Fix colon * Remove hot reload of libs * Disable rsyslog * Fix docker ps * Add back sleep * Extend proxy * Hardcode proxy version
- Loading branch information
1 parent
df69fa6
commit e3bb6f5
Showing
5 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python | ||
|
||
import socket | ||
import http | ||
import http.server | ||
|
||
IP_ADDRESS = socket.gethostbyname(socket.gethostname()) | ||
TLD = socket.getfqdn().split(".")[-1] | ||
|
||
PAC_TEMPLATE = """ | ||
function FindProxyForURL(url, host) {{ | ||
if (isInNet(host, "{ip}", "255.255.0.0") || host.endsWith("{tld}") || !host.includes(".")) {{ | ||
return "SOCKS5 {proxy_host}:1080" | ||
}} | ||
return "DIRECT"; | ||
}} | ||
""" | ||
|
||
|
||
class Handler(http.server.BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
self.send_response(http.HTTPStatus.OK) | ||
self.send_header("Content-type", "application/x-ns-proxy-autoconfig") | ||
self.end_headers() | ||
|
||
pac = PAC_TEMPLATE.format( | ||
ip=IP_ADDRESS, tld=TLD, proxy_host=self.headers["Host"].split(":")[0] | ||
) | ||
|
||
self.wfile.write(pac.encode()) | ||
|
||
|
||
def main(): | ||
httpd = http.server.HTTPServer(("", 80), Handler) | ||
httpd.serve_forever() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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