X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/0203a8c58b2ecc9fb6241412b98ea2a242bf0100..9004987d8ec11b788f972e6764f875f2d873cfd6:/hotline/tracker.go?ds=sidebyside diff --git a/hotline/tracker.go b/hotline/tracker.go index d42ff7b..e0cbe56 100644 --- a/hotline/tracker.go +++ b/hotline/tracker.go @@ -91,6 +91,9 @@ type ServerRecord struct { func GetListing(addr string) ([]ServerRecord, error) { conn, err := net.DialTimeout("tcp", addr, trackerTimeout) + if err != nil { + return []ServerRecord{}, err + } defer func() { _ = conn.Close() }() _, err = conn.Write( @@ -110,7 +113,7 @@ func GetListing(addr string) ([]ServerRecord, error) { if readLen, err = conn.Read(buf); err != nil { return nil, err } - totalRead += readLen // 1514 + totalRead += readLen // 1514 var th TrackerHeader if err := binary.Read(bytes.NewReader(buf[:6]), binary.BigEndian, &th); err != nil { @@ -124,6 +127,7 @@ func GetListing(addr string) ([]ServerRecord, error) { payloadSize := int(binary.BigEndian.Uint16(info.MsgDataSize[:])) + buf = buf[:readLen] if totalRead < payloadSize { for { tmpBuf := make([]byte, 4096) @@ -140,7 +144,6 @@ func GetListing(addr string) ([]ServerRecord, error) { totalSrv := int(binary.BigEndian.Uint16(info.SrvCount[:])) srvBuf := buf[14:totalRead] - totalRead += readLen var servers []ServerRecord