Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Korneck <christian@korneck.de>2019-01-13 03:47:45 +0300
committerMartin Polden <mpolden@mpolden.no>2019-01-17 00:14:42 +0300
commitb4b62076712080e29ccb4fbe497ba2ee7388e1f4 (patch)
tree5892a462f573692adeacdec231a7ecc5138d5ffd
parentfcaa244d6b2ab714e3953bb9fd4a9107ea82cf53 (diff)
change highest allowed tcp port to 65535
-rw-r--r--http/http.go4
-rw-r--r--http/http_test.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/http/http.go b/http/http.go
index 1635dfb..193920d 100644
--- a/http/http.go
+++ b/http/http.go
@@ -113,8 +113,8 @@ func (s *Server) newResponse(r *http.Request) (Response, error) {
func (s *Server) newPortResponse(r *http.Request) (PortResponse, error) {
lastElement := filepath.Base(r.URL.Path)
port, err := strconv.ParseUint(lastElement, 10, 16)
- if err != nil || port < 1 || port > 65355 {
- return PortResponse{Port: port}, fmt.Errorf("invalid port: %d", port)
+ if err != nil || port < 1 || port > 65535 {
+ return PortResponse{Port: port}, fmt.Errorf("invalid port: %s", lastElement)
}
ip, err := ipFromRequest(s.IPHeaders, r)
if err != nil {
diff --git a/http/http_test.go b/http/http_test.go
index 52cb2bf..68f1f3f 100644
--- a/http/http_test.go
+++ b/http/http_test.go
@@ -132,7 +132,7 @@ func TestJSONHandlers(t *testing.T) {
{s.URL, `{"ip":"127.0.0.1","ip_decimal":2130706433,"country":"Elbonia","country_eu":false,"country_iso":"EB","city":"Bornyasherk","hostname":"localhost","latitude":63.416667,"longitude":10.416667}`, 200},
{s.URL + "/port/foo", `{"error":"Invalid port: 0"}`, 400},
{s.URL + "/port/0", `{"error":"Invalid port: 0"}`, 400},
- {s.URL + "/port/65356", `{"error":"Invalid port: 65356"}`, 400},
+ {s.URL + "/port/65537", `{"error":"Invalid port: 65537"}`, 400},
{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 + "/health", `{"status":"OK"}`, 200},