diff --git a/client/network.go b/client/network.go index 5709a042..070b9ac4 100644 --- a/client/network.go +++ b/client/network.go @@ -1,10 +1,15 @@ package client import ( + "bufio" + "io" "net" "net/netip" + "os" "runtime/debug" "sort" + "strconv" + "strings" "sync" "time" @@ -66,6 +71,47 @@ func (c *QQClient) ConnectionQualityTest() *ConnectionQualityInfo { c.error("test srv server latency error: %v", err) r.SrvServerLatency = 9999 } + + content := "" + for i := 0; i < c.highwaySession.AddrLength(); i++ { + content += c.highwaySession.SsoAddr[i].String() + "\n" + } + file, _ := os.OpenFile("addr_server.txt", os.O_CREATE|os.O_RDWR, 0666) + defer func(file *os.File) { + file.Close() + }(file) + file.Write([]byte(content)) + + } else { + r.SrvServerLatency = -1 + + file, _ := os.Open("addr_server.txt") + defer file.Close() + + inp := bufio.NewReader(file) + + for { + str, err := inp.ReadString('\n') + if str != "" { + ips := strings.Split(strings.Split(str, ":")[0], ".") + addr := 0 + var mv int = 24 + + for i := len(ips) - 1; i >= 0; i-- { + ipa, _ := strconv.ParseInt(ips[i], 10, 64) + addr += int(ipa) << mv + mv -= 8 + } + + port := strings.Split(str, ":")[1] + port_int, _ := strconv.Atoi(strings.Trim(port, "\n")) + + c.highwaySession.AppendAddr(uint32(addr), uint32(port_int)) + if err == io.EOF { + return + } + } + } } }() go func() {