]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircsocket.rb
Urban can now grab the first page of definitions.
[user/henk/code/ruby/rbot.git] / lib / rbot / ircsocket.rb
index 9bdf43a06a4376843a54eb6fdf37612f86bb47b5..2e6ff452d7f47a0685e3e7655f57cb5d8db940ae 100644 (file)
@@ -212,7 +212,7 @@ module Irc
 
   # wrapped TCPSocket for communication with the server.
   # emulates a subset of TCPSocket functionality
-  class IrcSocket
+  class Socket
 
     MAX_IRC_SEND_PENALTY = 10
 
@@ -262,7 +262,7 @@ module Irc
 
     # server_list:: list of servers to connect to
     # host::   optional local host to bind to (ruby 1.7+ required)
-    # create a new IrcSocket
+    # create a new Irc::Socket
     def initialize(server_list, host, sendq_delay=2, sendq_burst=4, opts={})
       @server_list = server_list.dup
       @server_uri = nil
@@ -310,26 +310,26 @@ module Irc
 
       if(@host)
         begin
-          @sock=TCPSocket.new(@server_uri.host, @server_uri.port, @host)
+          sock=TCPSocket.new(@server_uri.host, @server_uri.port, @host)
         rescue ArgumentError => e
           error "Your version of ruby does not support binding to a "
           error "specific local address, please upgrade if you wish "
           error "to use HOST = foo"
           error "(this option has been disabled in order to continue)"
-          @sock=TCPSocket.new(@server_uri.host, @server_uri.port)
+          sock=TCPSocket.new(@server_uri.host, @server_uri.port)
         end
       else
-        @sock=TCPSocket.new(@server_uri.host, @server_uri.port)
+        sock=TCPSocket.new(@server_uri.host, @server_uri.port)
       end
       if(@ssl)
         require 'openssl'
         ssl_context = OpenSSL::SSL::SSLContext.new()
         ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
-        @rawsock = @sock
-        @sock = OpenSSL::SSL::SSLSocket.new(@rawsock, ssl_context)
-        @sock.sync_close = true
-        @sock.connect
+        sock = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
+        sock.sync_close = true
+        sock.connect
       end
+      @sock = sock
       @last_send = Time.new - @sendq_delay
       @flood_send = Time.new
       @last_throttle = Time.new
@@ -404,7 +404,6 @@ module Irc
       rescue Exception => e
         error "error while shutting down: #{e.pretty_inspect}"
       end
-      @rawsock = nil if @ssl
       @sock = nil
       @burst = 0
       @sendq.clear