diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-26 09:35:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-26 09:35:44 +0000 |
commit | dfe0aab04f7039660f4f567988accbf8ce0d6e7b (patch) | |
tree | 840d09993ccfa2e333ac27eeb5ab1979dbe495d8 /lib/resolv-replace.rb | |
parent | 13391b4047d4bddd6d0447265e46a45c3ec9d851 (diff) |
* lib/resolv-replace.rb: 1.8 compliance. [ruby-talk:82946]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/resolv-replace.rb')
-rw-r--r-- | lib/resolv-replace.rb | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/resolv-replace.rb b/lib/resolv-replace.rb index ad5c97bfdf..560a813d66 100644 --- a/lib/resolv-replace.rb +++ b/lib/resolv-replace.rb @@ -1,9 +1,10 @@ +require 'socket' require 'resolv' class BasicSocket alias original_resolv_send send def send(mesg, flags, *rest) - rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? original_resolv_send(mesg, flags, *rest) end end @@ -15,19 +16,20 @@ class << IPSocket end end -class << TCPSocket - alias original_resolv_new new - def new(host, service) - original_resolv_new(Resolv.getaddress(host).to_s, service) - end - - alias original_resolv_open open - def open(host, service) - original_resolv_open(Resolv.getaddress(host).to_s, service) +class TCPSocket + alias original_resolv_initialize initialize + def initialize(host, serv, *rest) + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? + original_resolv_initialize(Resolv.getaddress(host).to_s, serv, *rest) end end class UDPSocket + alias original_resolv_bind bind + def bind(host, port) + original_resolv_bind(Resolv.getaddress(host).to_s, port) + end + alias original_resolv_connect connect def connect(host, port) original_resolv_connect(Resolv.getaddress(host).to_s, port) @@ -35,7 +37,14 @@ class UDPSocket alias original_resolv_send send def send(mesg, flags, *rest) - rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length + rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty? original_resolv_send(mesg, flags, *rest) end end + +class SOCKSSocket + alias original_resolv_initialize initialize + def initialize(host, serv) + original_resolv_initialize(Resolv.getaddress(host).to_s, port) + end +end if defined? SOCKSSocket |