add support for socks5, socks4, and http proxies

This commit is contained in:
ading2210 2024-07-19 00:47:14 -04:00
parent 9f033fc848
commit 4d64b27a82
9 changed files with 58 additions and 5 deletions

View file

@ -104,4 +104,14 @@ function c_func_str(target, args=[]) {
let str = UTF8ToString(ptr);
_free(ptr);
return str;
}
//ensure that the proxy url has a valid protocol
function check_proxy(proxy) {
if (typeof proxy === "string" || proxy instanceof String) {
let protocol = new URL(proxy).protocol;
if (!["socks5h:", "socks4a:", "http:"].includes(protocol)) {
throw new TypeError("Only socks5h, socks4a, and http proxies are supported.");
}
}
}