2003-09-26 05:35:44 -04:00
|
|
|
require 'socket'
|
2001-05-30 05:10:30 -04:00
|
|
|
require 'resolv'
|
|
|
|
|
|
|
|
class BasicSocket
|
|
|
|
alias original_resolv_send send
|
|
|
|
def send(mesg, flags, *rest)
|
2003-09-26 05:35:44 -04:00
|
|
|
rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty?
|
2001-05-30 05:10:30 -04:00
|
|
|
original_resolv_send(mesg, flags, *rest)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class << IPSocket
|
|
|
|
alias original_resolv_getaddress getaddress
|
|
|
|
def getaddress(host)
|
|
|
|
return Resolv.getaddress(host).to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-09-26 05:35:44 -04:00
|
|
|
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)
|
2001-05-30 05:10:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class UDPSocket
|
2003-09-26 05:35:44 -04:00
|
|
|
alias original_resolv_bind bind
|
|
|
|
def bind(host, port)
|
|
|
|
original_resolv_bind(Resolv.getaddress(host).to_s, port)
|
|
|
|
end
|
|
|
|
|
2001-05-30 05:10:30 -04:00
|
|
|
alias original_resolv_connect connect
|
|
|
|
def connect(host, port)
|
|
|
|
original_resolv_connect(Resolv.getaddress(host).to_s, port)
|
|
|
|
end
|
|
|
|
|
|
|
|
alias original_resolv_send send
|
|
|
|
def send(mesg, flags, *rest)
|
2003-09-26 05:35:44 -04:00
|
|
|
rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty?
|
2001-05-30 05:10:30 -04:00
|
|
|
original_resolv_send(mesg, flags, *rest)
|
|
|
|
end
|
|
|
|
end
|
2003-09-26 05:35:44 -04:00
|
|
|
|
|
|
|
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
|