Fix segfault on macOS when port wasn't properly parsed.
This commit is contained in:
parent
812436fce3
commit
4e6cca530b
@ -12,6 +12,7 @@ package requester
|
|||||||
import (
|
import (
|
||||||
// stdlib
|
// stdlib
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -169,7 +170,7 @@ func (r *Requester) updateServerGoroutineDispatcher(data [][]string) map[string]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updates information about specific server.
|
// Updates information about specific server.
|
||||||
func (r *Requester) UpdateServer(server *datamodels.Server) {
|
func (r *Requester) UpdateServer(server *datamodels.Server) error {
|
||||||
srv := server.Ip + ":" + server.Port
|
srv := server.Ip + ":" + server.Port
|
||||||
fmt.Println("Updating server: " + srv)
|
fmt.Println("Updating server: " + srv)
|
||||||
|
|
||||||
@ -177,6 +178,7 @@ func (r *Requester) UpdateServer(server *datamodels.Server) {
|
|||||||
conn, err1 := net.Dial("udp", srv)
|
conn, err1 := net.Dial("udp", srv)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
fmt.Println("Error dialing to server " + srv + "!")
|
fmt.Println("Error dialing to server " + srv + "!")
|
||||||
|
return errors.New("Error dialing to server " + srv + "!")
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
@ -233,4 +235,6 @@ func (r *Requester) UpdateServer(server *datamodels.Server) {
|
|||||||
|
|
||||||
// ToDo: Calculate ping. 0 for now.
|
// ToDo: Calculate ping. 0 for now.
|
||||||
server.Ping = "0"
|
server.Ping = "0"
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user