mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-04 22:57:20 +02:00
parent
d596d6b843
commit
c248dacccf
@ -4,9 +4,11 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/net/publicsuffix"
|
||||||
"imuslab.com/zoraxy/mod/utils"
|
"imuslab.com/zoraxy/mod/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -217,11 +219,24 @@ func getWebsiteStatusWithLatency(url string) (bool, int64, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getWebsiteStatus(url string) (int, error) {
|
func getWebsiteStatus(url string) (int, error) {
|
||||||
|
// Create a one-time use cookie jar to store cookies
|
||||||
|
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
|
Jar: jar,
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Get(url)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
|
req.Header = http.Header{
|
||||||
|
"User-Agent": {"zoraxy-uptime/1.1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
//resp, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//Try replace the http with https and vise versa
|
//Try replace the http with https and vise versa
|
||||||
rewriteURL := ""
|
rewriteURL := ""
|
||||||
@ -231,7 +246,12 @@ func getWebsiteStatus(url string) (int, error) {
|
|||||||
rewriteURL = strings.ReplaceAll(url, "http://", "https://")
|
rewriteURL = strings.ReplaceAll(url, "http://", "https://")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err = client.Get(rewriteURL)
|
req, _ := http.NewRequest("GET", rewriteURL, nil)
|
||||||
|
req.Header = http.Header{
|
||||||
|
"User-Agent": {"zoraxy-uptime/1.1"},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "http: server gave HTTP response to HTTPS client") {
|
if strings.Contains(err.Error(), "http: server gave HTTP response to HTTPS client") {
|
||||||
//Invalid downstream reverse proxy settings, but it is online
|
//Invalid downstream reverse proxy settings, but it is online
|
||||||
|
Loading…
x
Reference in New Issue
Block a user