Permalink
Browse files

Add and fix some stuff

  • Loading branch information...
1 parent 8fab50b commit e444b2713b8cd2373991454b1025b317a263ded7 @meh committed Feb 23, 2012
@@ -22,7 +22,7 @@ module IRC; class Server
class Client < EM::Connection
extend Forwardable
- attr_reader :server, :ip, :port, :input, :output
+ attr_reader :server, :ip, :port, :hostname
attr_accessor :host
def_delegators :@server, :dispatcher, :options
@@ -32,7 +32,9 @@ def post_init
@ip = Socket.unpack_sockaddr_in(get_peername).last
@port = Socket.unpack_sockaddr_in(get_sockname).first
- @host = @ip
+ @host = Socket.getnameinfo(get_peername).first
+
+ @hostname = @host
@data = ''
end
@@ -124,7 +126,7 @@ def flush!
alias to_s ip
def ssl!
- next if ssl?
+ return if ssl?
@ssl = true
@@ -17,6 +17,7 @@
# along with failirc. If not, see <http://www.gnu.org/licenses/>.
#++
+require 'failirc/server/modules/base/commands'
require 'failirc/server/modules/base/support'
require 'failirc/server/modules/base/errors'
require 'failirc/server/modules/base/responses'
@@ -35,12 +36,6 @@
version '0.1.0'
identifier 'RFC 1460, 2810, 2811, 2812, 2813;'
-module Base::Commands
- Ignore = [:PING, :PONG, :WHO, :MODE]
- Unregistered = [:PASS, :NICK, :USER]
- Unrepeatable = [:PASS, :USER]
-end
-
on :start do |server|
@mutex = RecursiveMutex.new
@joining = {}
@@ -207,7 +202,7 @@ def check_encoding (string)
@pinged_out.delete(~thing)
}
- if thing.client? && Commands::Ignore.none? { |a| event.alias?(a) }
+ if thing.client? && Commands::NoAction.none? { |a| event.alias?(a) }
thing.last_action = Action.new(thing, event, string)
end
@@ -1808,14 +1803,18 @@ def nick_is_ok? (thing, nick)
observe :whois do |thing, name, target=nil|
unless client = @clients[name]
thing.send_message ERR_NOSUCHNICK, name
+
return
end
thing.send_message RPL_WHOISUSER, client
+ if thing.modes.ircop? || thing.nick == client.nick
+ thing.send_message RPL_WHOISCONNECTING, client
+ end
+
if thing.modes.ircop?
thing.send_message RPL_WHOISMODES, client
- thing.send_message RPL_WHOISCONNECTING, client
end
if !client.channels.empty?
@@ -0,0 +1,40 @@
+#--
+# Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
+#
+# This file is part of failirc.
+#
+# failirc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# failirc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with failirc. If not, see <http://www.gnu.org/licenses/>.
+#++
+
+module IRC; class Server; module Base
+
+module Commands
+ NoAction = [:PING, :PONG, :WHO, :MODE]
+ Unregistered = [:PASS, :NICK, :USER]
+ Unrepeatable = [:PASS, :USER]
+end
+
+def self.command_executable_when_unregistered (name)
+ Commands::Unregistered << name.to_sym
+end
+
+def self.command_is_not_an_action (name)
+ Commands::NoAction << name.to_sym
+end
+
+def self.command_is_unrepeatable (name)
+ Commands::Unrepeatable << name.to_sym
+end
+
+end; end; end
@@ -20,7 +20,7 @@
version '0.0.1'
identifier 'cap'
-Base::Commands::Unregistered << :CAP
+Base.command_executable_when_unregistered :CAP
input {
aliases {
@@ -0,0 +1,28 @@
+# failirc, a fail IRC library.
+#
+# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
+#
+# This file is part of failirc.
+#
+# failirc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# failirc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with failirc. If not, see <http://www.gnu.org/licenses/>.
+
+require 'digest/md5'
+
+version '0.0.1'
+
+on :connect do |client|
+ options[:keys].each {|key|
+ client.host = Digest::MD5.hexdigest(client.host)
+ }
+end
@@ -20,7 +20,7 @@
version '0.0.1'
identifier 'tls'
-Base::Commands::Unregistered << :STARTTLS
+Base.command_executable_when_unregistered :STARTTLS
RPL_STARTTLS = {
code: 670,

0 comments on commit e444b27

Please sign in to comment.