Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/alt/ruby27/share/ruby
File: resolv-replace.rb
# frozen_string_literal: true
[0] Fix | Delete
[1] Fix | Delete
require 'socket'
[2] Fix | Delete
require 'resolv'
[3] Fix | Delete
[4] Fix | Delete
class << IPSocket
[5] Fix | Delete
# :stopdoc:
[6] Fix | Delete
alias original_resolv_getaddress getaddress
[7] Fix | Delete
# :startdoc:
[8] Fix | Delete
def getaddress(host)
[9] Fix | Delete
begin
[10] Fix | Delete
return Resolv.getaddress(host).to_s
[11] Fix | Delete
rescue Resolv::ResolvError
[12] Fix | Delete
raise SocketError, "Hostname not known: #{host}"
[13] Fix | Delete
end
[14] Fix | Delete
end
[15] Fix | Delete
end
[16] Fix | Delete
[17] Fix | Delete
class TCPSocket < IPSocket
[18] Fix | Delete
# :stopdoc:
[19] Fix | Delete
alias original_resolv_initialize initialize
[20] Fix | Delete
# :startdoc:
[21] Fix | Delete
def initialize(host, serv, *rest)
[22] Fix | Delete
rest[0] = IPSocket.getaddress(rest[0]) if rest[0]
[23] Fix | Delete
original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
[24] Fix | Delete
end
[25] Fix | Delete
end
[26] Fix | Delete
[27] Fix | Delete
class UDPSocket < IPSocket
[28] Fix | Delete
# :stopdoc:
[29] Fix | Delete
alias original_resolv_bind bind
[30] Fix | Delete
# :startdoc:
[31] Fix | Delete
def bind(host, port)
[32] Fix | Delete
host = IPSocket.getaddress(host) if host != ""
[33] Fix | Delete
original_resolv_bind(host, port)
[34] Fix | Delete
end
[35] Fix | Delete
[36] Fix | Delete
# :stopdoc:
[37] Fix | Delete
alias original_resolv_connect connect
[38] Fix | Delete
# :startdoc:
[39] Fix | Delete
def connect(host, port)
[40] Fix | Delete
original_resolv_connect(IPSocket.getaddress(host), port)
[41] Fix | Delete
end
[42] Fix | Delete
[43] Fix | Delete
# :stopdoc:
[44] Fix | Delete
alias original_resolv_send send
[45] Fix | Delete
# :startdoc:
[46] Fix | Delete
def send(mesg, flags, *rest)
[47] Fix | Delete
if rest.length == 2
[48] Fix | Delete
host, port = rest
[49] Fix | Delete
begin
[50] Fix | Delete
addrs = Resolv.getaddresses(host)
[51] Fix | Delete
rescue Resolv::ResolvError
[52] Fix | Delete
raise SocketError, "Hostname not known: #{host}"
[53] Fix | Delete
end
[54] Fix | Delete
addrs[0...-1].each {|addr|
[55] Fix | Delete
begin
[56] Fix | Delete
return original_resolv_send(mesg, flags, addr, port)
[57] Fix | Delete
rescue SystemCallError
[58] Fix | Delete
end
[59] Fix | Delete
}
[60] Fix | Delete
original_resolv_send(mesg, flags, addrs[-1], port)
[61] Fix | Delete
else
[62] Fix | Delete
original_resolv_send(mesg, flags, *rest)
[63] Fix | Delete
end
[64] Fix | Delete
end
[65] Fix | Delete
end
[66] Fix | Delete
[67] Fix | Delete
class SOCKSSocket < TCPSocket
[68] Fix | Delete
# :stopdoc:
[69] Fix | Delete
alias original_resolv_initialize initialize
[70] Fix | Delete
# :startdoc:
[71] Fix | Delete
def initialize(host, serv)
[72] Fix | Delete
original_resolv_initialize(IPSocket.getaddress(host), port)
[73] Fix | Delete
end
[74] Fix | Delete
end if defined? SOCKSSocket
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function