diff options
author | MadCamel <madcamel@gmail.com> | 2010-05-05 07:34:05 -0400 |
---|---|---|
committer | MadCamel <madcamel@gmail.com> | 2010-05-05 07:34:05 -0400 |
commit | 51e87379c9d532cafc98b96178709b8b8c88e1ae (patch) | |
tree | db80f2e1a758b2739ab79218a88a3def501f362d /src/tool/ipcheck.rb | |
parent | ae73f3122063048b3a5a2d1c48f6c13b02fd4e1f (diff) | |
download | tmwa-51e87379c9d532cafc98b96178709b8b8c88e1ae.tar.gz tmwa-51e87379c9d532cafc98b96178709b8b8c88e1ae.tar.bz2 tmwa-51e87379c9d532cafc98b96178709b8b8c88e1ae.tar.xz tmwa-51e87379c9d532cafc98b96178709b8b8c88e1ae.zip |
Fixed up and slightly simplified the build system
It's now possible to run 'make' in any of the src/ subdirs and
have it build properly. Moved some tools including eathena-monitor
to src/tools - run 'make tools' to build. CFLAGS, etc are now in
the 'make.defs' file. Requires GNU make.
Diffstat (limited to 'src/tool/ipcheck.rb')
-rwxr-xr-x | src/tool/ipcheck.rb | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/tool/ipcheck.rb b/src/tool/ipcheck.rb new file mode 100755 index 0000000..7c2e22a --- /dev/null +++ b/src/tool/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.casecmp(character_name) == 0 + 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 |