summaryrefslogtreecommitdiff
path: root/ipcheck.rb
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-09 17:39:39 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-09 17:39:39 +0200
commitcf4c883cd7529810bece6cb0037c9f82a1527d8f (patch)
tree314f58e30359f21d9b83669623d1359a68878f0f /ipcheck.rb
parent0db8e5ffab4c7afbed076f4f7ecfb6354952c205 (diff)
downloadtmwa-cf4c883cd7529810bece6cb0037c9f82a1527d8f.tar.gz
tmwa-cf4c883cd7529810bece6cb0037c9f82a1527d8f.tar.bz2
tmwa-cf4c883cd7529810bece6cb0037c9f82a1527d8f.tar.xz
tmwa-cf4c883cd7529810bece6cb0037c9f82a1527d8f.zip
Added a tool for checking who plays from the same IP address
Use at your own risk!
Diffstat (limited to 'ipcheck.rb')
-rwxr-xr-xipcheck.rb82
1 files changed, 82 insertions, 0 deletions
diff --git a/ipcheck.rb b/ipcheck.rb
new file mode 100755
index 0000000..20ef57b
--- /dev/null
+++ b/ipcheck.rb
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+# A script to check which characters play from the same IP address
+# (c) 2009 Bjorn Lindeijer
+#
+# Summary of how it works:
+#
+# Character -> Account
+# Account -> IP
+# IP -> Accounts
+# Accounts -> Characters
+#
+
+if ARGV.length != 1
+ puts "Usage: ipcheck.rb character_name"
+ exit 1
+else
+ $search_character = ARGV[0]
+ puts "Searching for character #{$search_character}"
+end
+
+class Character
+ attr_reader :name, :account_id
+
+ def initialize(name, account_id)
+ @name = name
+ @account_id = account_id
+ end
+end
+
+class Account
+ attr_reader :id, :ip, :last_login
+
+ def initialize(id, ip, last_login)
+ @id = id
+ @ip = ip
+ @last_login = last_login
+ end
+end
+
+accounts = Array.new
+characters = Array.new
+
+File.open("save/athena.txt", "r") do |f|
+ f.each_line do |line|
+ split = line.split("\t")
+ if split.length >= 3
+ account_id, char_index = split[1].split(',')
+ character_name = split[2]
+ characters.push(Character.new(character_name, account_id))
+ if $search_character == character_name
+ puts "Searching for account #{account_id}"
+ $search_account_id = account_id
+ end
+ end
+ end
+end
+
+if not $search_account_id
+ puts "Error: character #{$search_character} not found!"
+ exit 1
+end
+
+File.open("save/account.txt", "r") do |f|
+ f.each_line do |line|
+ split = line.split("\t")
+ if split.length >= 11
+ account_id, last_login, ip = split[0], split[3], split[10]
+ accounts.push(Account.new(account_id, ip, last_login))
+ if $search_account_id == account_id
+ puts "Searching for IP #{ip}"
+ $search_ip = ip
+ end
+ end
+ end
+end
+
+accounts.find_all { |a| a.ip == $search_ip }.each do |a|
+ puts "Characters for account #{a.id} (last login #{a.last_login}):"
+ characters.find_all { |c| c.account_id == a.id }.each do |c|
+ puts " #{c.name}"
+ end
+end