From b1014d5647810894882d588c5a1658980bc181da Mon Sep 17 00:00:00 2001 From: Azareal Date: Sat, 7 Mar 2020 13:49:44 +1000 Subject: [PATCH] add archive.org user agent --- gen_router.go | 61 ++++++++++++++++++++++++---------------------- langs/english.json | 1 + router_gen/main.go | 3 +++ 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/gen_router.go b/gen_router.go index 0aae6bd4..3bd7f95e 100644 --- a/gen_router.go +++ b/gen_router.go @@ -596,19 +596,20 @@ var agentMapEnum = map[string]int{ "twitter": 22, "facebook": 23, "cloudflare": 24, - "uptimebot": 25, - "slackbot": 26, - "apple": 27, - "discourse": 28, - "alexa": 29, - "lynx": 30, - "blank": 31, - "malformed": 32, - "suspicious": 33, - "semrush": 34, - "dotbot": 35, - "aspiegel": 36, - "zgrab": 37, + "archive_org": 25, + "uptimebot": 26, + "slackbot": 27, + "apple": 28, + "discourse": 29, + "alexa": 30, + "lynx": 31, + "blank": 32, + "malformed": 33, + "suspicious": 34, + "semrush": 35, + "dotbot": 36, + "aspiegel": 37, + "zgrab": 38, } var reverseAgentMapEnum = map[int]string{ 0: "unknown", @@ -636,19 +637,20 @@ var reverseAgentMapEnum = map[int]string{ 22: "twitter", 23: "facebook", 24: "cloudflare", - 25: "uptimebot", - 26: "slackbot", - 27: "apple", - 28: "discourse", - 29: "alexa", - 30: "lynx", - 31: "blank", - 32: "malformed", - 33: "suspicious", - 34: "semrush", - 35: "dotbot", - 36: "aspiegel", - 37: "zgrab", + 25: "archive_org", + 26: "uptimebot", + 27: "slackbot", + 28: "apple", + 29: "discourse", + 30: "alexa", + 31: "lynx", + 32: "blank", + 33: "malformed", + 34: "suspicious", + 35: "semrush", + 36: "dotbot", + 37: "aspiegel", + 38: "zgrab", } var markToAgent = map[string]string{ "OPR": "opera", @@ -672,6 +674,7 @@ var markToAgent = map[string]string{ "Exabot": "exabot", "SeznamBot": "seznambot", "CloudFlare": "cloudflare", + "archive.org_bot": "archive_org", "Uptimebot": "uptimebot", "Slackbot": "slackbot", "Discordbot": "discord", @@ -809,7 +812,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, prepend string) { prepend += "\n" } r.DumpRequest(req,prepend+"Suspicious Request") - co.AgentViewCounter.Bump(33) + co.AgentViewCounter.Bump(34) } func isLocalHost(h string) bool { @@ -824,7 +827,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { w.WriteHeader(200) // 400 w.Write([]byte("")) r.DumpRequest(req,"Malformed Request T"+strconv.Itoa(typ)) - co.AgentViewCounter.Bump(32) + co.AgentViewCounter.Bump(33) } // Split the Host and Port string @@ -966,7 +969,7 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { ua := strings.TrimSpace(strings.Replace(strings.TrimPrefix(req.UserAgent(),"Mozilla/5.0 ")," Safari/537.36","",-1)) // Noise, no one's going to be running this and it would require some sort of agent ranking system to determine which identifier should be prioritised over another if ua == "" { - co.AgentViewCounter.Bump(31) + co.AgentViewCounter.Bump(32) if c.Dev.DebugMode { var prepend string for _, char := range req.UserAgent() { diff --git a/langs/english.json b/langs/english.json index 6abf5d96..03acb5f4 100644 --- a/langs/english.json +++ b/langs/english.json @@ -209,6 +209,7 @@ "discord":"Discord", "twitter":"Twitterbot", "cloudflare":"Cloudflare Alwayson", + "archive_org":"Archive.org", "uptimebot":"Uptimebot", "slackbot":"Slackbot", "facebook":"FacebookBot", diff --git a/router_gen/main.go b/router_gen/main.go index 28327e61..7807cf09 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -255,6 +255,7 @@ func main() { "twitter", "facebook", "cloudflare", + "archive_org", "uptimebot", "slackbot", "apple", @@ -298,6 +299,7 @@ func main() { "Exabot", "SeznamBot", "CloudFlare", + "archive.org_bot", "Uptimebot", "Slackbot", "Discordbot", @@ -337,6 +339,7 @@ func main() { "Exabot": "exabot", "SeznamBot": "seznambot", "CloudFlare": "cloudflare", // Track alwayson specifically in case there are other bots? + "archive.org_bot": "archive_org", "Uptimebot": "uptimebot", "Slackbot": "slackbot", "Discordbot": "discord",