From fb5fac92d2173c2a5b07ed4ecc7b5fefe8484ed2 Mon Sep 17 00:00:00 2001 From: Sam B Date: Fri, 12 Jul 2019 16:00:38 +0200 Subject: [PATCH] Add Mikrotik as CLI client (#69) --- http/http.go | 2 +- http/http_test.go | 1 + useragent/useragent_test.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/http/http.go b/http/http.go index 663effd..023b667 100644 --- a/http/http.go +++ b/http/http.go @@ -274,7 +274,7 @@ func NotFoundHandler(w http.ResponseWriter, r *http.Request) *appError { func cliMatcher(r *http.Request) bool { ua := useragent.Parse(r.UserAgent()) switch ua.Product { - case "curl", "HTTPie", "Wget", "fetch libfetch", "Go", "Go-http-client", "ddclient": + case "curl", "HTTPie", "Wget", "fetch libfetch", "Go", "Go-http-client", "ddclient", "Mikrotik": return true } return false diff --git a/http/http_test.go b/http/http_test.go index cca5e9b..b4207e2 100644 --- a/http/http_test.go +++ b/http/http_test.go @@ -208,6 +208,7 @@ func TestCLIMatcher(t *testing.T) { {"Go-http-client/1.1", true}, {"Go-http-client/2.0", true}, {"ddclient/3.8.3", true}, + {"Mikrotik/6.x Fetch", true}, {browserUserAgent, false}, } for _, tt := range tests { diff --git a/useragent/useragent_test.go b/useragent/useragent_test.go index b96acb7..19b6e45 100644 --- a/useragent/useragent_test.go +++ b/useragent/useragent_test.go @@ -17,6 +17,7 @@ func TestParse(t *testing.T) { {"Wget", UserAgent{Product: "Wget"}}, {"fetch libfetch/2.0", UserAgent{Product: "fetch libfetch", Version: "2.0"}}, {"Go 1.1 package http", UserAgent{Product: "Go", Comment: "1.1 package http"}}, + {"Mikrotik/6.x Fetch", UserAgent{Product: "Mikrotik", Version: "6.x", Comment: "Fetch"}}, {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) " + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.28 " + "Safari/537.36", UserAgent{Product: "Mozilla", Version: "5.0", Comment: "(Macintosh; Intel Mac OS X 10_8_4) " +