diff --git a/README.md b/README.md index 2f5b274..bbcb8ec 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ This is a simple proxy load balancer that will route requests to a cluster of pr This proxy server will transparently forward HTTPS requests without terminating them, meaning a self-signed certificate is not required. Downstream HTTPS proxy servers are not supported. +Memory usage sits at around 25M under load. + ## Install 1. Download the latest release from [/releases](https://git.evulid.cc/cyberes/proxy-loadbalancer/releases) or run `./build.sh` to build the program locally. diff --git a/src/proxy/checkProxy.go b/src/proxy/checkProxy.go index de5367d..bf8f24f 100644 --- a/src/proxy/checkProxy.go +++ b/src/proxy/checkProxy.go @@ -25,17 +25,35 @@ func sendRequestThroughProxy(pxy string, targetURL string) (string, error) { Timeout: config.GetConfig().ProxyConnectTimeout, } - response, err := client.Get(targetURL) + req, err := http.NewRequest("GET", targetURL, nil) if err != nil { return "", err } - defer response.Body.Close() - if response.StatusCode == http.StatusOK { - bodyBytes, err := io.ReadAll(response.Body) + + req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7") + req.Header.Set("Accept-Language", "en-US,en;q=0.9") + req.Header.Set("Priority", "u=0, i") + req.Header.Set("Sec-Ch-Ua", `"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"`) + req.Header.Set("Sec-Ch-Ua-Mobile", "?0") + req.Header.Set("Sec-Ch-Ua-Platform", `"Windows"`) + req.Header.Set("Sec-Fetch-Dest", "document") + req.Header.Set("Sec-Fetch-Mode", "navigate") + req.Header.Set("Sec-Fetch-Site", "cross-site") + req.Header.Set("Sec-Fetch-User", "?1") + req.Header.Set("Upgrade-Insecure-Requests", "1") + req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36") + + resp, err := client.Do(req) + if err != nil { + return "", err + } + defer resp.Body.Close() + if resp.StatusCode == http.StatusOK { + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { return "", err } return string(bodyBytes), nil } - return "", fmt.Errorf("bad response code %d", response.StatusCode) + return "", fmt.Errorf("bad response code %d", resp.StatusCode) } diff --git a/src/proxy/threads.go b/src/proxy/threads.go index e008f90..e0bd6be 100644 --- a/src/proxy/threads.go +++ b/src/proxy/threads.go @@ -57,7 +57,7 @@ func (p *ForwardProxyCluster) ValidateProxiesThread() { // Test the proxy. ipAddr, testErr := sendRequestThroughProxy(pxy, config.GetConfig().IpCheckerURL) if testErr != nil { - log.Warnf("Validate - proxy %s failed: %s", proxyHost, testErr) + log.Warnf("Validate - %s failed: %s", proxyHost, testErr) if isThirdparty(pxy) { newThirdpartyOfflineProxies = append(newThirdpartyOfflineProxies, pxy) } else { @@ -66,7 +66,7 @@ func (p *ForwardProxyCluster) ValidateProxiesThread() { return } if slices.Contains(newIpAddresses, ipAddr) { - log.Warnf("Validate - duplicate IP Address %s for proxy %s", ipAddr, proxyHost) + log.Warnf("Validate - duplicate IP Address %s for %s", ipAddr, proxyHost) if isThirdparty(pxy) { newThirdpartyOfflineProxies = append(newThirdpartyOfflineProxies, pxy) } else { @@ -84,7 +84,7 @@ func (p *ForwardProxyCluster) ValidateProxiesThread() { if bv3hiErr != nil { okToAdd = false newThirdpartyBrokenProxies = append(newThirdpartyBrokenProxies, pxy) - log.Debugf("Validate - Third-party %s failed: %s", proxyHost, bv3hiErr) + log.Debugf("Validate - %s failed third-party test: %s", proxyHost, bv3hiErr) break } }