]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/tracker.go
Prune unused code
[rbdr/mobius] / hotline / tracker.go
index 69d9fd48aa95b00c56ae46d29867c55ed25f3d80..e0cbe569eaa3d31eaff9e9e796d00c3b936aa175 100644 (file)
@@ -91,6 +91,9 @@ type ServerRecord struct {
 
 func GetListing(addr string) ([]ServerRecord, error) {
        conn, err := net.DialTimeout("tcp", addr, trackerTimeout)
 
 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(
        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
        }
        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 {
 
        var th TrackerHeader
        if err := binary.Read(bytes.NewReader(buf[:6]), binary.BigEndian, &th); err != nil {
@@ -141,7 +144,6 @@ func GetListing(addr string) ([]ServerRecord, error) {
        totalSrv := int(binary.BigEndian.Uint16(info.SrvCount[:]))
 
        srvBuf := buf[14:totalRead]
        totalSrv := int(binary.BigEndian.Uint16(info.SrvCount[:]))
 
        srvBuf := buf[14:totalRead]
-       totalRead += readLen
 
        var servers []ServerRecord
 
 
        var servers []ServerRecord