diff --git a/ircd.rb b/ircd.rb deleted file mode 100644 index 27e4b3a..0000000 --- a/ircd.rb +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env ruby -require 'rubygems' -require 'eventmachine' -require 'thread' - -DIR = File.dirname(__FILE__) -%w(irc_replies net_utils message_server synchronized_store default_stores irc_channel irc_client irc_server).each do |f| - require File.join(f) -end - -include IRCReplies - -$config ||= {} -$config['version'] = '0.1' -$config['timeout'] = 10 -$config['port'] = 6667 -$config['hostname'] = Socket.gethostname.split(/\./).shift -$config['starttime'] = Time.now.to_s -$config['nick-tries'] = 5 - -$verbose = ARGV.shift || false - -CHANNEL = /^[#\$&]+/ -PREFIX = /^:[^ ]+ +(.+)$/ - -if __FILE__ == $0 - begin - $verbose ||= !ARGV.detect { |c| c =~ /-v/ }.nil? - trap("INT") do - $message_server.dump - system("kill -9 #{$$}") - end - - MessageServer.start - - EventMachine::run do - EventMachine::add_periodic_timer(300) { IRCServer.ping_all } - EventMachine::start_server "0.0.0.0", 6667, IRCServer - end - rescue Exception => e - class P; include NetUtils; end - P.new.carp e - end -end diff --git a/default_stores.rb b/lib/default_stores.rb similarity index 100% rename from default_stores.rb rename to lib/default_stores.rb diff --git a/lib/global_channel.rb b/lib/global_channel.rb new file mode 100644 index 0000000..459baa3 --- /dev/null +++ b/lib/global_channel.rb @@ -0,0 +1,41 @@ +class GlobalChannel + include NetUtils + + def privatemsg(msg, client) + # Broadcast to all users + carp "#{msg} from #{client}" + $user_store.each_user do |user| + user.reply :privmsg, client.userprefix, "#all", msg + end + end + + def notice(msg, client) + $user_store.each_user {|user| + user.reply :notice, client.userprefix, @name, msg + } + end + + def each_user(&blk) + $user_store.each_user(&blk) + end + + def name; "#all"; end + + def nicks; $user_store.nicks + ["Steve"]; end + + def topic + "All that is posted on Kookaburra" + end + + def join(client); true; end + + def part(client, msg); true; end + + def is_member?(user); true; end + alias has_nick? is_member? + + def mode(u) + u == "Steve" ? "@" : " " + end + +end \ No newline at end of file diff --git a/irc_channel.rb b/lib/irc_channel.rb similarity index 94% rename from irc_channel.rb rename to lib/irc_channel.rb index 9d73c6c..1254aa6 100644 --- a/irc_channel.rb +++ b/lib/irc_channel.rb @@ -9,7 +9,7 @@ def initialize(name) @topic = "There is no topic" @name = name @oper = [] - carp "create channel:#{@name}" + carp "create channel: #{@name}" end def add(client) @@ -56,6 +56,7 @@ def privatemsg(msg, client) each_user {|user| user.reply :privmsg, client.userprefix, @name, msg if user != client } + $channel_store["#all"].privatemsg "#{msg} - from #{@name}", client end def notice(msg, client) diff --git a/irc_client.rb b/lib/irc_client.rb similarity index 92% rename from irc_client.rb rename to lib/irc_client.rb index 85e4ccd..0f3d270 100644 --- a/irc_client.rb +++ b/lib/irc_client.rb @@ -77,7 +77,7 @@ def handle_nick(s) unless $user_store[s].closed? reply :numeric, ERR_NICKNAMEINUSE,"* #{s} ","Nickname is already in use." @nick_tries += 1 - if @nick_tries > $config['nick-tries'] + if @nick_tries > Kookaburra.max_nick_tries carp "kicking spurious user #{s} after #{@nick_tries} tries" handle_abort end @@ -106,9 +106,9 @@ def mode def handle_newconnect(nick) @alive = true @nick = nick - @host = $config['hostname'] - @ver = $config['version'] - @starttime = $config['starttime'] + @host = Kookaburra.host_name + @ver = Kookaburra.version + @starttime = Kookaburra.started_at send_welcome if !@user.nil? end @@ -120,6 +120,8 @@ def send_welcome repl_myinfo repl_motd repl_mode + # Force the user to join #all + reply :join, @usermsg, "#all" @welcomed = true end end @@ -163,11 +165,11 @@ def repl_nowaway() end def repl_motd() - reply :numeric, RPL_MOTDSTART,'', "- Message of the Day" + reply :numeric, RPL_MOTDSTART,'', "MOTD" File.read("motd.txt").split("\n").each do |l| - reply :numeric, RPL_MOTD,'', "- #{l}" + reply :numeric, RPL_MOTD,'', l end - reply :numeric, RPL_ENDOFMOTD,'', "- End of /MOTD command." + reply :numeric, RPL_ENDOFMOTD,'', "End of /MOTD command." end def repl_mode() @@ -187,7 +189,7 @@ def send_notonchannel(channel) def send_topic(channel) if $channel_store[channel] - reply :numeric, RPL_TOPIC,channel, "#{$channel_store[channel].topic}" + reply :numeric, RPL_TOPIC,channel, $channel_store[channel].topic.to_s else send_notonchannel channel end @@ -212,7 +214,7 @@ def send_nameslist(channel) end def send_ping() - reply :ping, "#{$config['hostname']}" + reply :ping, Kookaburra.host_name end def handle_join(channels) @@ -264,7 +266,7 @@ def handle_privmsg(target, msg) end end begin - #$message_server.append_message(self.nick, target.strip, msg, viewed) + $message_server.append_message(self.nick, target.strip, msg, viewed) rescue Exception => e carp e end @@ -384,7 +386,7 @@ def handle_who(mask, rest) #match against all users $user_store.each_user {|user| reply :numeric, RPL_WHOREPLY , - "#{user.channels[0]} #{user.userprefix} #{user.host} #{$config['hostname']} #{user.nick} H" , + "#{user.channels[0]} #{user.userprefix} #{user.host} #{Kookaburra.host_name} #{user.nick} H" , "#{hopcount} #{user.realname}" if File.fnmatch?(mask, "#{user.host}.#{user.realname}.#{user.nick}") } reply :numeric, RPL_ENDOFWHO, mask, "End of /WHO list." @@ -392,7 +394,7 @@ def handle_who(mask, rest) #get all users in the channel channel.each_user {|user| reply :numeric, RPL_WHOREPLY , - "#{mask} #{user.userprefix} #{user.host} #{$config['hostname']} #{user.nick} H" , + "#{mask} #{user.userprefix} #{user.host} #{Kookaburra.host_name} #{user.nick} H" , "#{hopcount} #{user.realname}" } reply :numeric, RPL_ENDOFWHO, mask, "End of /WHO list." @@ -420,7 +422,7 @@ def handle_abort() end def handle_version() - reply :numeric, RPL_VERSION,"#{$config['version']} Ruby IRCD", "" + reply :numeric, RPL_VERSION, "v#{Kookaburra.version} Kookaburra", "" end def handle_eval(s) @@ -433,7 +435,7 @@ def handle_unknown(s) end def handle_connect - reply :raw, "NOTICE AUTH :#{$config['version']} initialized, welcome." + reply :raw, "NOTICE AUTH :Kookaburra v#{Kookaburra.version} initialized, welcome." end def reply(method, *args) @@ -477,14 +479,14 @@ def reply(method, *args) raw "#{@usermsg} MODE #{nick} :#{rest}" when :numeric numeric,msg,detail = args - server = $config['hostname'] + server = Kookaburra.host_name raw ":#{server} #{'%03d'%numeric} #{@nick} #{msg} :#{detail}" end end def raw(arg, abrt=false) begin - #carp "--> #{arg}" + carp "--> #{arg}" @server.send_data arg.chomp + "\r\n" if !arg.nil? rescue Exception => e carp "<#{self.userprefix}>#{e.message}" diff --git a/lib/irc_logger.rb b/lib/irc_logger.rb new file mode 100644 index 0000000..269d942 --- /dev/null +++ b/lib/irc_logger.rb @@ -0,0 +1,63 @@ +# Logger partially based on Merb logger +class IRCLogger + + LEVELS = { + :fatal => 7, + :error => 6, + :warn => 4, + :info => 3, + :debug => 0 + } + + COLOURS = { + :fatal => 31, # red + :error => 33, # yellow + :warn => 35, # magenta + :info => 32, # green + :debug => 34 # white + } + + attr_accessor :level, :file, :verbose + + def initialize(level = :info, verbose = false) + self.level = level.to_sym + self.verbose = verbose + self.file = File.open(File.join(Kookaburra.root, "log/ircd.log"), "a+") + end + + def close! + self.file.close + end + + LEVELS.each do |name, value| + + define_method(name) do |message| + write "[#{name.to_s.upcase}] #{message}", name if LEVELS[self.level] <= value + end + + define_method(:"#{name}?") do + LEVELS[self.level] <= value + end + end + + def debug_exception(exception) + + debug "Exception: #{exception}" + exception.backtrace.each do |l| + debug ">> #{l}" + end + + end + + private + + def write(message, level = self.level) + self.file.puts message + STDOUT.puts colourize(message, level) if self.verbose + end + + def colourize(message, level) + "\033[1;#{COLOURS[level]}m#{message}\033[0m" + end + +end \ No newline at end of file diff --git a/irc_replies.rb b/lib/irc_replies.rb similarity index 100% rename from irc_replies.rb rename to lib/irc_replies.rb diff --git a/irc_server.rb b/lib/irc_server.rb similarity index 100% rename from irc_server.rb rename to lib/irc_server.rb diff --git a/lib/ircd.rb b/lib/ircd.rb new file mode 100644 index 0000000..e3310c2 --- /dev/null +++ b/lib/ircd.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +require 'rubygems' +require 'eventmachine' +require 'thread' + +DIR = File.dirname(__FILE__) +%w(irc_replies net_utils message_server synchronized_store default_stores + irc_channel irc_client irc_server global_channel irc_logger kookaburra).each do |f| + require File.join(DIR, f) +end + +$channel_store["#all"] = GlobalChannel.new + +include IRCReplies + +CHANNEL = /^[#\$&]+/ +PREFIX = /^:[^ ]+ +(.+)$/ \ No newline at end of file diff --git a/lib/kookaburra.rb b/lib/kookaburra.rb new file mode 100644 index 0000000..54525fb --- /dev/null +++ b/lib/kookaburra.rb @@ -0,0 +1,69 @@ +class Kookaburra + class << self + + def version; "0.1"; end + + def logger + @@logger ||= setup_logger! + end + + def verbose? + @@verbose ||= false + end + + def verbose=(value) + @@verbose = !!value + end + + def root + @@root || File.expand_path(File.join(File.dirname(__FILE__), "..")) + end + + def root=(path) + @@root = path + end + + def host_name + @@host_name ||= Socket.gethostname.split(/\./).shift + end + + def started_at; @@started_at ||= Time.now.to_s; end + + def max_nick_tries; 5; end + + # Initialization + + def setup_logger! + log_level = :debug + if ARGV.detect { |c| c.to_s =~ /^(\-\-log\-level(.*))/i } + cmd = $1 + if cmd.include?("=") + log_level = cmd.split("=", 2)[1].to_sym + else + log_level = ARGV[ARGV.index(cmd) + 1].to_sym + end + end + @@logger ||= IRCLogger.new((log_level || :debug).to_sym, self.verbose?) + end + + def setup_traps! + trap("INT") do + $message_server.dump + system("kill -9 #{$$}") + end + end + + def setup_verbosity! + self.verbose = !ARGV.detect { |c| c =~ /-v/ }.nil? || false + end + + def setup! + @@started_at = Time.now.to_s + setup_verbosity! + setup_logger! + setup_traps! + end + + + end +end \ No newline at end of file diff --git a/message_server.rb b/lib/message_server.rb similarity index 97% rename from message_server.rb rename to lib/message_server.rb index ae7b39a..8ddd07a 100644 --- a/message_server.rb +++ b/lib/message_server.rb @@ -27,7 +27,7 @@ def all_messages(limit = 100) @mutex.synchronize do m = @messages.values.flatten end - return formatted(m)[0..(limit - 1)] + return formatted(m)[-limit..-1] end def messages_for(chan) @@ -41,7 +41,7 @@ def messages_for(chan) def append_message(from, to, contents, viewed = true) @mutex.synchronize do messages = (@messages[to.downcase] ||= []) - messages.shift if messages.length == 250 + messages.shift if messages.length >= MESSAGE_LIMIT messages << ::MessageServer::Message.new(MessageServer.next_id, from, to, contents, Time.now, viewed) end end diff --git a/lib/net_utils.rb b/lib/net_utils.rb new file mode 100644 index 0000000..92d38be --- /dev/null +++ b/lib/net_utils.rb @@ -0,0 +1,9 @@ +module NetUtils + def carp(arg) + if arg.kind_of?(Exception) + Kookaburra.logger.debug_exception arg + else + Kookaburra.logger.debug arg + end + end +end diff --git a/synchronized_store.rb b/lib/synchronized_store.rb similarity index 100% rename from synchronized_store.rb rename to lib/synchronized_store.rb diff --git a/log/ircd.log b/log/ircd.log new file mode 100644 index 0000000..f8e38e1 --- /dev/null +++ b/log/ircd.log @@ -0,0 +1,156 @@ +[INFO] Starting Kookaburra +[DEBUG] Loading data +[DEBUG] Messages: Hash => 11 +[DEBUG] Data loaded! +[DEBUG] Base id: 482 +[DEBUG] initializing connection from rumble.dev +[DEBUG] --> NOTICE AUTH :Kookaburra v0.1 initialized, welcome. +[DEBUG] initializing connection from rumble.dev +[DEBUG] --> NOTICE AUTH :Kookaburra v0.1 initialized, welcome. +[DEBUG] Recieved line: NICK SuttoL +[DEBUG] <-- NICK SuttoL +[DEBUG] Processing line +[DEBUG] nick => SuttoL +[DEBUG] Handled +[DEBUG] Line processed in 0.000926971435546875 seconds +[DEBUG] Recieved line: NICK jesus +[DEBUG] <-- NICK jesus +[DEBUG] Processing line +[DEBUG] nick => jesus +[DEBUG] Handled +[DEBUG] Line processed in 0.000729084014892578 seconds +[DEBUG] Recieved line: USER SuttoL 8 * :Darcy Laycock +[DEBUG] <-- USER SuttoL 8 * :Darcy Laycock +[DEBUG] Processing line +[DEBUG] --> :0xDEADBEEF 001 SuttoL SuttoL :Welcome to Cockatoo - SuttoL!SuttoL@rumble.dev +[DEBUG] --> :0xDEADBEEF 002 SuttoL SuttoL :Your host is 0xDEADBEEF, running version 0.1 +[DEBUG] --> :0xDEADBEEF 003 SuttoL SuttoL :This server was created Tue Nov 04 21:01:35 +0900 2008 +[DEBUG] --> :0xDEADBEEF 004 SuttoL SuttoL :0xDEADBEEF 0.1 aAbBcCdDeEfFGhHiIjkKlLmMnNopPQrRsStUvVwWxXyYzZ0123459*@ bcdefFhiIklmnoPqstv +[DEBUG] --> :0xDEADBEEF 375 SuttoL :MOTD +[DEBUG] --> :0xDEADBEEF 372 SuttoL :Welcome to Kookaburra 0.1 +[DEBUG] --> :0xDEADBEEF 372 SuttoL : +[DEBUG] --> :0xDEADBEEF 372 SuttoL : )/_ +[DEBUG] --> :0xDEADBEEF 372 SuttoL : <' \ +[DEBUG] --> :0xDEADBEEF 372 SuttoL : /) ) +[DEBUG] --> :0xDEADBEEF 372 SuttoL : ---/'-""--- +[DEBUG] --> :0xDEADBEEF 372 SuttoL : +[DEBUG] --> :0xDEADBEEF 372 SuttoL :Cockatoo is build on ruby-ircd +[DEBUG] --> :0xDEADBEEF 372 SuttoL :w/ a few customization +[DEBUG] --> :0xDEADBEEF 372 SuttoL : +[DEBUG] --> :0xDEADBEEF 372 SuttoL :ascii art from the intarwebs! +[DEBUG] --> :0xDEADBEEF 376 SuttoL :End of /MOTD command. +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev JOIN :#all +[DEBUG] Handled +[DEBUG] Line processed in 0.00223398208618164 seconds +[DEBUG] Recieved line: USER jesus 8 * :Darcy Laycock +[DEBUG] <-- USER jesus 8 * :Darcy Laycock +[DEBUG] Processing line +[DEBUG] --> :0xDEADBEEF 001 jesus jesus :Welcome to Cockatoo - jesus!jesus@rumble.dev +[DEBUG] --> :0xDEADBEEF 002 jesus jesus :Your host is 0xDEADBEEF, running version 0.1 +[DEBUG] --> :0xDEADBEEF 003 jesus jesus :This server was created Tue Nov 04 21:01:35 +0900 2008 +[DEBUG] --> :0xDEADBEEF 004 jesus jesus :0xDEADBEEF 0.1 aAbBcCdDeEfFGhHiIjkKlLmMnNopPQrRsStUvVwWxXyYzZ0123459*@ bcdefFhiIklmnoPqstv +[DEBUG] --> :0xDEADBEEF 375 jesus :MOTD +[DEBUG] --> :0xDEADBEEF 372 jesus :Welcome to Kookaburra 0.1 +[DEBUG] --> :0xDEADBEEF 372 jesus : +[DEBUG] --> :0xDEADBEEF 372 jesus : )/_ +[DEBUG] --> :0xDEADBEEF 372 jesus : <' \ +[DEBUG] --> :0xDEADBEEF 372 jesus : /) ) +[DEBUG] --> :0xDEADBEEF 372 jesus : ---/'-""--- +[DEBUG] --> :0xDEADBEEF 372 jesus : +[DEBUG] --> :0xDEADBEEF 372 jesus :Cockatoo is build on ruby-ircd +[DEBUG] --> :0xDEADBEEF 372 jesus :w/ a few customization +[DEBUG] --> :0xDEADBEEF 372 jesus : +[DEBUG] --> :0xDEADBEEF 372 jesus :ascii art from the intarwebs! +[DEBUG] --> :0xDEADBEEF 376 jesus :End of /MOTD command. +[DEBUG] --> :jesus!~jesus@rumble.dev JOIN :#all +[DEBUG] Handled +[DEBUG] Line processed in 0.00167489051818848 seconds +[DEBUG] Recieved line: JOIN #wootsicles,#eotw,#all,#general +[DEBUG] <-- JOIN #wootsicles,#eotw,#all,#general +[DEBUG] Processing line +[DEBUG] create channel: #wootsicles +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev JOIN :#wootsicles +[DEBUG] --> :0xDEADBEEF 332 SuttoL #wootsicles :There is no topic +[DEBUG] --> :0xDEADBEEF 353 SuttoL = #wootsicles :@SuttoL +[DEBUG] --> :0xDEADBEEF 366 SuttoL #wootsicles :End of /NAMES list. +[DEBUG] create channel: #eotw +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev JOIN :#eotw +[DEBUG] --> :0xDEADBEEF 332 SuttoL #eotw :There is no topic +[DEBUG] --> :0xDEADBEEF 353 SuttoL = #eotw :@SuttoL +[DEBUG] --> :0xDEADBEEF 366 SuttoL #eotw :End of /NAMES list. +[DEBUG] --> :0xDEADBEEF 332 SuttoL #all :All that is posted on Kookaburra +[DEBUG] --> :0xDEADBEEF 353 SuttoL = #all : SuttoL jesus +[DEBUG] --> :0xDEADBEEF 366 SuttoL #all :End of /NAMES list. +[DEBUG] create channel: #general +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev JOIN :#general +[DEBUG] --> :0xDEADBEEF 332 SuttoL #general :There is no topic +[DEBUG] --> :0xDEADBEEF 353 SuttoL = #general :@SuttoL +[DEBUG] --> :0xDEADBEEF 366 SuttoL #general :End of /NAMES list. +[DEBUG] Handled +[DEBUG] Line processed in 0.00291204452514648 seconds +[DEBUG] Recieved line: JOIN #eotw,#all +[DEBUG] <-- JOIN #eotw,#all +[DEBUG] Processing line +[DEBUG] --> :jesus!~jesus@rumble.dev JOIN :#eotw +[DEBUG] --> :jesus!~jesus@rumble.dev JOIN :#eotw +[DEBUG] --> :0xDEADBEEF 332 jesus #eotw :There is no topic +[DEBUG] --> :0xDEADBEEF 353 jesus = #eotw :@SuttoL jesus +[DEBUG] --> :0xDEADBEEF 366 jesus #eotw :End of /NAMES list. +[DEBUG] --> :0xDEADBEEF 332 jesus #all :All that is posted on Kookaburra +[DEBUG] --> :0xDEADBEEF 353 jesus = #all : SuttoL jesus +[DEBUG] --> :0xDEADBEEF 366 jesus #all :End of /NAMES list. +[DEBUG] Handled +[DEBUG] Line processed in 0.00154495239257812 seconds +[DEBUG] Recieved line: MODE #wootsicles +sn +[DEBUG] <-- MODE #wootsicles +sn +[DEBUG] Processing line +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev MODE #wootsicles :+sn +[DEBUG] Handled +[DEBUG] Line processed in 0.000558853149414062 seconds +[DEBUG] Recieved line: MODE #eotw +[DEBUG] <-- MODE #eotw +[DEBUG] Processing line +[DEBUG] --> :jesus!~jesus@rumble.dev MODE #eotw : +[DEBUG] Handled +[DEBUG] Line processed in 0.000540971755981445 seconds +[DEBUG] Recieved line: MODE #all +[DEBUG] <-- MODE #all +[DEBUG] Processing line +[DEBUG] --> :jesus!~jesus@rumble.dev MODE #all : +[DEBUG] Handled +[DEBUG] Line processed in 0.0031120777130127 seconds +[DEBUG] Recieved line: WHO #eotw +[DEBUG] <-- WHO #eotw +[DEBUG] Processing line +[DEBUG] --> :0xDEADBEEF 352 jesus #eotw :SuttoL!~SuttoL@rumble.dev rumble.dev 0xDEADBEEF SuttoL H :0 Darcy Laycock +[DEBUG] --> :0xDEADBEEF 352 jesus #eotw :jesus!~jesus@rumble.dev rumble.dev 0xDEADBEEF jesus H :0 Darcy Laycock +[DEBUG] --> :0xDEADBEEF 315 jesus #eotw :End of /WHO list. +[DEBUG] Handled +[DEBUG] Line processed in 0.00125408172607422 seconds +[DEBUG] Recieved line: MODE #eotw +sn +[DEBUG] <-- MODE #eotw +sn +[DEBUG] Processing line +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev MODE #eotw :+sn +[DEBUG] Handled +[DEBUG] Line processed in 0.000352144241333008 seconds +[DEBUG] Recieved line: MODE #all +[DEBUG] <-- MODE #all +[DEBUG] Processing line +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev MODE #all : +[DEBUG] Handled +[DEBUG] Line processed in 0.000772953033447266 seconds +[DEBUG] Recieved line: WHO #all +[DEBUG] <-- WHO #all +[DEBUG] Processing line +[DEBUG] --> :0xDEADBEEF 352 jesus #all :SuttoL!~SuttoL@rumble.dev rumble.dev 0xDEADBEEF SuttoL H :0 Darcy Laycock +[DEBUG] --> :0xDEADBEEF 352 jesus #all :jesus!~jesus@rumble.dev rumble.dev 0xDEADBEEF jesus H :0 Darcy Laycock +[DEBUG] --> :0xDEADBEEF 315 jesus #all :End of /WHO list. +[DEBUG] Handled +[DEBUG] Line processed in 0.00217700004577637 seconds +[DEBUG] Recieved line: MODE #general +sn +[DEBUG] <-- MODE #general +sn +[DEBUG] Processing line +[DEBUG] --> :SuttoL!~SuttoL@rumble.dev MODE #general :+sn +[DEBUG] Handled +[DEBUG] Line processed in 0.00123405456542969 seconds +[DEBUG] Dumping Data diff --git a/net_utils.rb b/net_utils.rb deleted file mode 100644 index f9e783f..0000000 --- a/net_utils.rb +++ /dev/null @@ -1,14 +0,0 @@ -module NetUtils - def carp(arg) - if $verbose - case true - when arg.kind_of?(Exception) - puts "Error:" + arg.message - puts "#{self.class.to_s}: " + arg.message - puts arg.backtrace.collect{|s| "#{self.class.to_s.downcase}:" + s}.join("\n") - else - puts "#{self.class.to_s}: " + arg - end - end - end -end diff --git a/script/server b/script/server new file mode 100755 index 0000000..dee3973 --- /dev/null +++ b/script/server @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +base_path = File.expand_path(File.join(File.dirname(__FILE__), "..")) +require File.join(base_path, "lib/ircd") + +Kookaburra.root = base_path + +Kookaburra.setup! +Kookaburra.logger.info "Starting Kookaburra" + +MessageServer.start + +begin + + EventMachine::run do + EventMachine::add_periodic_timer(300) { IRCServer.ping_all } + EventMachine::start_server "0.0.0.0", 6667, IRCServer + end +rescue Exception => e + Kookaburra.logger.debug_exception e +end \ No newline at end of file