Do not look up blank ips

Do not look up blank ips

No point attempting any kind of lookup on blank ip addresses
this simply adds log noise

Also … freeze strings

From d1e3c213a7fc1c60fa00c8fc99b1b501dd200936 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Mon, 19 Nov 2018 15:50:21 +1100
Subject: [PATCH] Do not look up blank ips

No point attempting any kind of lookup on blank ip addresses
this simply adds log noise

Also ... freeze strings

diff --git a/lib/discourse_ip_info.rb b/lib/discourse_ip_info.rb
index e2eb432..cefeaa6 100644
--- a/lib/discourse_ip_info.rb
+++ b/lib/discourse_ip_info.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'maxminddb'
 require 'resolv'
 
@@ -28,6 +30,7 @@ class DiscourseIpInfo
 
   def lookup(ip, locale: :en, resolve_hostname: false)
     ret = {}
+    return ret if ip.blank?
 
     if @loc_mmdb
       begin

GitHub

1 Like