From ddfc0bbf7889fe4a538379e8fa7b0a099738b88b Mon Sep 17 00:00:00 2001 From: Zephyr Lykos Date: Fri, 15 Mar 2024 03:26:01 +0800 Subject: [PATCH] fix: more ip fixes --- relay.go | 10 +++++----- tg.go | 26 ++++++++++++-------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/relay.go b/relay.go index 0eafd0e..a3d18f3 100644 --- a/relay.go +++ b/relay.go @@ -1,15 +1,15 @@ package main import ( + "log" "fmt" "io" "net/http" - "strings" ) func relay(w http.ResponseWriter, r *http.Request) { u := r.URL - reqip := strings.Split(u.Host, ":")[0] + reqip := u.Hostname() wsurl := ip2wsurl(reqip) // fmt.Println(wsurl) @@ -30,9 +30,9 @@ func relay(w http.ResponseWriter, r *http.Request) { w.Header().Set(k, a.Header.Get(k)) } - // if a.StatusCode != 200 { - // log.Println(a.StatusCode, reqip, ip2dc(reqip), wsurl) - // } + if a.StatusCode != 200 { + log.Println(a.StatusCode, reqip, ip2dc(reqip), wsurl) + } w.WriteHeader(a.StatusCode) diff --git a/tg.go b/tg.go index 521d148..a851a85 100644 --- a/tg.go +++ b/tg.go @@ -3,6 +3,7 @@ package main import ( "encoding/base64" "fmt" + "log" "net/url" "strings" ) @@ -37,12 +38,12 @@ func parseRelayProxy(a string) bool { putmapper("149.154.175.100", 3) putmapper("149.154.167.91", 4) putmapper("149.154.167.92", 4) - putmapper("149.154.171.5", 5) - putmapper("2001:b28:f23d:f001:0000:0000:0000:000a", 1) - putmapper("2001:67c:4e8:f002:0000:0000:0000:000a", 2) - putmapper("2001:b28:f23d:f003:0000:0000:0000:000a", 3) - putmapper("2001:67c:4e8:f004:0000:0000:0000:000a", 4) - putmapper("2001:b28:f23f:f005:0000:0000:0000:000a", 5) + putmapper("149.154.171.", 5) + putmapper("2001:b28:f23d:f001::", 1) + putmapper("2001:67c:4e8:f002::", 2) + putmapper("2001:b28:f23d:f003::", 3) + putmapper("2001:67c:4e8:f004::", 4) + putmapper("2001:b28:f23f:f005::", 5) putmapper("149.154.161.144", 2) putmapper("149.154.167.", 2) putmapper("149.154.175.1", 3) @@ -51,17 +52,12 @@ func parseRelayProxy(a string) bool { putmapper("149.154.165.", 4) putmapper("149.154.166.", 4) putmapper("91.108.56.", 5) - putmapper("2001:b28:f23d:f001:0000:0000:0000:000d", 1) - putmapper("2001:67c:4e8:f002:0000:0000:0000:000d", 2) - putmapper("2001:b28:f23d:f003:0000:0000:0000:000d", 3) - putmapper("2001:67c:4e8:f004:0000:0000:0000:000d", 4) - putmapper("2001:b28:f23f:f005:0000:0000:0000:000d", 5) putmapper("149.154.175.40", 6) putmapper("149.154.167.40", 7) putmapper("149.154.175.117", 8) - putmapper("2001:b28:f23d:f001:0000:0000:0000:000e", 6) - putmapper("2001:67c:4e8:f002:0000:0000:0000:000e", 7) - putmapper("2001:b28:f23d:f003:0000:0000:0000:000e", 8) + putmapper("2001:b28:f23d:f001::e", 6) + putmapper("2001:67c:4e8:f002::e", 7) + putmapper("2001:b28:f23d:f003::e", 8) return true } @@ -84,6 +80,8 @@ func ip2dc(ip string) int { return v } } + log.Printf("missing: %v", ip) + return 0 }