From 4c9cc92c0a49ec34c8bf00e31d1710450fb533fa Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 10 Feb 2013 08:09:05 +0000 Subject: firewall blacklist model added --- app/models/intruder.rb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/models/intruder.rb (limited to 'app/models/intruder.rb') diff --git a/app/models/intruder.rb b/app/models/intruder.rb new file mode 100644 index 0000000..192d64d --- /dev/null +++ b/app/models/intruder.rb @@ -0,0 +1,3 @@ +class Intruder < ActiveRecord::Base + attr_accessible :list_type, :key, :points, :bans, :ban_last, :ban_end, :contact_ip, :contact_port, :contact_count, :contact_last, :contacts_per_second, :contacts_per_second_max, :user_agent, :to_user, :comment +end -- cgit v1.2.3 From 70a6449fa176059e603a16a21699c8f5c60765e1 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 10 Feb 2013 16:59:57 +0100 Subject: intruder updated --- app/models/intruder.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/models/intruder.rb') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 192d64d..c013ee8 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -1,3 +1,26 @@ class Intruder < ActiveRecord::Base attr_accessible :list_type, :key, :points, :bans, :ban_last, :ban_end, :contact_ip, :contact_port, :contact_count, :contact_last, :contacts_per_second, :contacts_per_second_max, :user_agent, :to_user, :comment + + LIST_TYPES = ['blacklist', 'whitelist'] + + validates :list_type, + :presence => true, + :inclusion => { :in => LIST_TYPES } + + validates :key, + :presence => true, + :uniqueness => true + + validates :contact_ip, + :presence => true, + :uniqueness => true + + before_validation :set_key_if_empty + + private + def set_key_if_empty + if self.key.blank? + self.key = self.contact_ip + end + end end -- cgit v1.2.3 From 62ac01a8ea536718734bd911fc3642c0bd8b6bc7 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 11 Feb 2013 13:04:05 +0100 Subject: ipwhois added --- app/models/intruder.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/intruder.rb') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index c013ee8..db14bf8 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -17,6 +17,17 @@ class Intruder < ActiveRecord::Base before_validation :set_key_if_empty + + def whois + if ! self.contact_ip.blank? + begin + return Whois.whois(self.contact_ip) + rescue + return nil + end + end + end + private def set_key_if_empty if self.key.blank? -- cgit v1.2.3