mirror of
https://github.com/mpolden/echoip.git
synced 2025-01-13 03:37:21 +01:00
Use correct method
This commit is contained in:
parent
7ffaf5e9ac
commit
837a32db56
@ -98,7 +98,6 @@ func testPort(ip net.IP, port uint64) error {
|
|||||||
conn, err := net.DialTimeout("tcp", address, 2*time.Second)
|
conn, err := net.DialTimeout("tcp", address, 2*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
return nil
|
return nil
|
||||||
@ -186,7 +185,7 @@ func (a *API) PortHandler(w http.ResponseWriter, r *http.Request) *appError {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return internalServerError(err).AsJSON()
|
return internalServerError(err).AsJSON()
|
||||||
}
|
}
|
||||||
err = testPort(ip, port)
|
err = a.testPort(ip, port)
|
||||||
response := TestPortResponse{
|
response := TestPortResponse{
|
||||||
IP: ip,
|
IP: ip,
|
||||||
Port: port,
|
Port: port,
|
||||||
|
@ -86,7 +86,7 @@ func TestJSONHandlers(t *testing.T) {
|
|||||||
status int
|
status int
|
||||||
}{
|
}{
|
||||||
{s.URL, `{"ip":"127.0.0.1","country":"Elbonia","hostname":"localhost"}`, 200},
|
{s.URL, `{"ip":"127.0.0.1","country":"Elbonia","hostname":"localhost"}`, 200},
|
||||||
{s.URL + "/port/8080", `{"ip":"127.0.0.1","port":8080,"reachable":false}`, 200},
|
{s.URL + "/port/31337", `{"ip":"127.0.0.1","port":31337,"reachable":true}`, 200},
|
||||||
{s.URL + "/foo", `{"error":"404 page not found"}`, 404},
|
{s.URL + "/foo", `{"error":"404 page not found"}`, 404},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user