OXIESEC PANEL
- Current Dir:
/
/
usr
/
share
/
nmap
/
nselib
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
afp.lua
71.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ajp.lua
16.69 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
amqp.lua
10.5 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
anyconnect.lua
4.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
asn1.lua
14.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base32.lua
7.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base64.lua
5.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bin.lua
12.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bit.lua
2.43 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bitcoin.lua
16.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bits.lua
1.82 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bittorrent.lua
40.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bjnp.lua
9.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
brute.lua
50.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cassandra.lua
5.78 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
citrixxml.lua
16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
coap.lua
76.24 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
comm.lua
10.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
creds.lua
18.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cvs.lua
3.13 KB
04/16/2018 01:11:39 AM
rw-r--r--
📁
data
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
datafiles.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
datetime.lua
1.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp.lua
29.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp6.lua
19.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dns.lua
51.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnsbl.lua
19.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnssd.lua
12.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
drda.lua
24.2 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eap.lua
7.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eigrp.lua
14.47 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
formulas.lua
5.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ftp.lua
9.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
geoip.lua
1.71 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
giop.lua
18.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
gps.lua
3.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
http.lua
105.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
httpspider.lua
36.15 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
iax2.lua
9.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ike.lua
15.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
imap.lua
9.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
informix.lua
39.76 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipOps.lua
26.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipmi.lua
10.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipp.lua
12.54 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
irc.lua
757 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
iscsi.lua
21.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
isns.lua
15.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
jdwp.lua
43.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
json.lua
11.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ldap.lua
31.86 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lfs.luadoc
1.68 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2-utility.lua
4.39 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2.luadoc
4.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
listop.lua
4.66 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg-utility.lua
5.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg.luadoc
351 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
ls.lua
10.96 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
match.lua
2.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
membase.lua
9.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mobileme.lua
8.46 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mongodb.lua
21.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mqtt.lua
28.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpc.lua
179.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpcperformance.lua
29.72 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpctypes.lua
167.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mssql.lua
110.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
multicast.lua
6.1 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mysql.lua
17.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
natpmp.lua
5.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ncp.lua
36 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ndmp.lua
11.58 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
netbios.lua
13.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nmap.luadoc
40.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nrpc.lua
4.42 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nsedebug.lua
3.49 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
omp2.lua
4.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
openssl.luadoc
7.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ospf.lua
15.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
packet.lua
36.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pcre.luadoc
6.79 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pgsql.lua
20.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pop3.lua
5.7 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pppoe.lua
29.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
proxy.lua
12.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rdp.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
re.lua
8.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
redis.lua
3.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rmi.lua
47.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpc.lua
106.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpcap.lua
11.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rsync.lua
5.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rtsp.lua
8.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sasl.lua
16.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
shortport.lua
8.01 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sip.lua
30.56 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
slaxml.lua
17.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb.lua
175.85 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb2.lua
16.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smbauth.lua
37.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smtp.lua
19.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
snmp.lua
15.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
socks.lua
8.26 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
srvloc.lua
12.25 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh1.lua
8.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh2.lua
11.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslcert.lua
33.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslv2.lua
9.63 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stdnse.lua
45.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strbuf.lua
4.52 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strict.lua
2.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stun.lua
11.51 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tab.lua
3.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
target.lua
3.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tftp.lua
9.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tls.lua
56.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tn3270.lua
43.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tns.lua
64.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unicode.lua
14.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unittest.lua
12.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unpwdb.lua
10.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
upnp.lua
11.18 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
url.lua
12.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
versant.lua
8.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vnc.lua
23.3 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vulns.lua
76.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vuzedht.lua
16.62 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
wsdd.lua
12.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xdmcp.lua
11.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xmpp.lua
15.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
Editing: vuzedht.lua
Close
--- -- A Vuze DHT protocol implementation based on the following documentation: -- o http://wiki.vuze.com/w/Distributed_hash_table -- -- It currently supports the PING and FIND_NODE requests and parses the -- responses. The following main classes are used by the library: -- -- o Request - the request class containing all of the request classes. It -- currently contains the Header, PING and FIND_NODE classes. -- -- o Response - the response class containing all of the response classes. It -- currently contains the Header, PING, FIND_NODE and ERROR -- class. -- -- o Session - a class containing "session state" such as the transaction- and -- instance ID's. -- -- o Helper - The helper class that serves as the main interface between -- scripts and the library. -- -- @author Patrik Karlsson <patrik@cqure.net> -- local bin = require "bin" local ipOps = require "ipOps" local math = require "math" local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" local table = require "table" local openssl = stdnse.silent_require "openssl" _ENV = stdnse.module("vuzedht", stdnse.seeall) Request = { Actions = { ACTION_PING = 1024, FIND_NODE = 1028, }, -- The request Header class shared by all Requests classes Header = { -- Creates a new Header instance -- @param action number containing the request action -- @param session instance of Session -- @return o new instance of Header new = function(self, action, session) local o = { conn_id = string.char(255) .. openssl.rand_pseudo_bytes(7), -- we need to handle this one like this, due to a bug in nsedoc -- it used to be action = action, but that breaks parsing ["action"] = action, trans_id = session:getTransactionId(), proto_version = 0x32, vendor_id = 0, network_id = 0, local_proto_version = 0x32, address = session:getAddress(), port = session:getPort(), instance_id = session:getInstanceId(), time = os.time(), } setmetatable(o, self) self.__index = self return o end, -- Converts the header to a string __tostring = function(self) local lhost = ipOps.todword(self.address) return bin.pack( ">AIICCICCISIL", self.conn_id, self.action, self.trans_id, self.proto_version, self.vendor_id, self.network_id, self.local_proto_version, 4, lhost, self.port, self.instance_id, self.time ) end, }, -- The PING Request class Ping = { -- Creates a new Ping instance -- @param session instance of Session -- @return o new instance of Ping new = function(self, session) local o = { header = Request.Header:new(Request.Actions.ACTION_PING, session) } setmetatable(o, self) self.__index = self return o end, -- Converts a Ping Request to a string __tostring = function(self) return tostring(self.header) end, }, -- The FIND_NODES Request class FindNode = { -- Creates a new FindNode instance -- @param session instance of Session -- @return o new instance of FindNode new = function(self, session) local o = { header = Request.Header:new(Request.Actions.FIND_NODE, session), id_length = 20, node_id = '\xA7' .. openssl.rand_pseudo_bytes(19), status = 0xFFFFFFFF, dht_size = 0, } setmetatable(o, self) self.__index = self return o end, -- Converts a FindNode Request to a string __tostring = function(self) local data = tostring(self.header) .. bin.pack(">CAII", self.id_length, self.node_id, self.status, self.dht_size) return data end, } } Response = { -- A table of currently supported Actions (Responses) -- It's used in the fromString method to determine which class to create. Actions = { ACTION_PING = 1025, FIND_NODE = 1029, ERROR = 1032, }, -- Creates an address record based on received data -- @param data containing an address record [C][I|H][S] where -- [C] is the length of the address (4 or 16) -- [I|H] is the address as a dword or hex string -- [S] is the port number as a short -- @return o Address instance on success, nil on failure Address = { new = function(self, data) local o = { data = data } setmetatable(o, self) self.__index = self if ( o:parse() ) then return o end end, -- Parses the received data -- @return true on success, false on failure parse = function(self) local pos, addr_len = bin.unpack("C", self.data) if ( addr_len == 4 ) then self.length = 4 + 2 + 1 pos, self.ip = bin.unpack(">I", self.data, pos) self.ip = ipOps.fromdword(self.ip) elseif( addr_len == 16 ) then self.length = 16 + 2 + 1 pos, self.ip = bin.unpack("H16", self.data, pos) else stdnse.debug1("Unknown address type (length: %d)", addr_len) return false, "Unknown address type" end pos, self.port = bin.unpack(">S", self.data, pos) return true end }, -- The response header, present in all packets Header = { Vendors = { [0] = "Azureus", [1] = "ShareNet", [255] = "Unknown", -- to be honest, we report all except 0 and 1 as unknown }, Networks = { [0] = "Stable", [1] = "CVS" }, -- Creates a new Header instance -- @param data string containing the received data -- @return o instance of Header new = function(self, data) local o = { data = data } setmetatable(o, self) self.__index = self o:parse() return o end, -- parses the header parse = function(self) local pos pos, self.action, self.trans_id, self.conn_id, self.proto_version, self.vendor_id, self.network_id, self.instance_id = bin.unpack(">IIH8CCII", self.data) end, -- Converts the header to a suitable string representation __tostring = function(self) local result = {} table.insert(result, ("Transaction id: %d"):format(self.trans_id)) table.insert(result, ("Connection id: 0x%s"):format(self.conn_id)) table.insert(result, ("Protocol version: %d"):format(self.proto_version)) table.insert(result, ("Vendor id: %s (%d)"):format( Response.Header.Vendors[self.vendor_id] or "Unknown", self.vendor_id)) table.insert(result, ("Network id: %s (%d)"):format( Response.Header.Networks[self.network_id] or "Unknown", self.network_id)) table.insert(result, ("Instance id: %d"):format(self.instance_id)) return stdnse.format_output(true, result) end, }, -- The PING response PING = { -- Creates a new instance of PING -- @param data string containing the received data -- @return o new PING instance new = function(self, data) local o = { header = Response.Header:new(data) } setmetatable(o, self) self.__index = self return o end, -- Creates a new PING instance based on received data -- @param data string containing received data -- @return status true on success, false on failure -- @return new instance of PING on success, error message on failure fromString = function(data) local ping = Response.PING:new(data) if ( ping ) then return true, ping end return false, "Failed to parse PING response" end, -- Converts the PING response to a response suitable for script output -- @return result formatted script output __tostring = function(self) return tostring(self.header) end, }, -- A class to process the response from a FIND_NODE query FIND_NODE = { -- Creates a new FIND_NODE instance -- @param data string containing the received data -- @return o new instance of FIND_NODE new = function(self, data) local o = { header = Response.Header:new(data), data = data:sub(27) } setmetatable(o, self) self.__index = self o:parse() return o end, -- Parses the FIND_NODE response parse = function(self) local pos pos, self.spoof_id, self.node_type, self.dht_size, self.network_coords = bin.unpack(">IIIH20", self.data) local contact_count pos, contact_count = bin.unpack("C", self.data, pos) self.contacts = {} for i=1, contact_count do local contact, addr_len, address = {} pos, contact.type, contact.proto_version, addr_len = bin.unpack("CCC", self.data, pos) if ( addr_len == 4 ) then pos, address = bin.unpack(">I", self.data, pos) contact.address = ipOps.fromdword(address) elseif ( addr_len == 16 ) then pos, contact.address = bin.unpack("H16", self.data, pos) end pos, contact.port = bin.unpack(">S", self.data, pos) table.insert(self.contacts, contact) end end, -- Creates a new instance of FIND_NODE based on received data -- @param data string containing received data -- @return status true on success, false on failure -- @return new instance of FIND_NODE on success, error message on failure fromString = function(data) local find = Response.FIND_NODE:new(data) if ( find.header.proto_version < 13 ) then stdnse.debug1("ERROR: Unsupported version %d", find.header.proto_version) return false end return true, find end, -- Convert the FIND_NODE response to formatted string data, suitable -- for script output. -- @return string with formatted FIND_NODE data __tostring = function(self) if ( not(self.contacts) ) then return "" end local result = {} for _, contact in ipairs(self.contacts) do table.insert(result, ("%s:%d"):format(contact.address, contact.port)) end return stdnse.format_output(true, result) end }, -- The ERROR action ERROR = { -- Creates a new ERROR instance based on received socket data -- @return o new ERROR instance on success, nil on failure new = function(self, data) local o = { header = Response.Header:new(data), data = data:sub(27) } setmetatable(o, self) self.__index = self if ( o:parse() ) then return o end end, -- parses the received data and attempts to create an ERROR response -- @return true on success, false on failure parse = function(self) local pos, err_type = bin.unpack(">I", self.data) if ( 1 == err_type ) then self.addr = Response.Address:new(self.data:sub(5)) return true end return false end, -- creates a new ERROR instance based on the received data -- @return true on success, false on failure fromString = function(data) local err = Response.ERROR:new(data) if ( err ) then return true, err end return false end, -- Converts the ERROR action to a formatted response -- @return string containing the formatted response __tostring = function(self) return ("Wrong address, expected: %s"):format(self.addr.ip) end, }, -- creates a suitable Response class based on the Action received -- @return true on success, false on failure -- @return response instance of suitable Response class on success, -- err string error message if status is false fromString = function(data) local pos, action = bin.unpack(">I", data) if ( action == Response.Actions.ACTION_PING ) then return Response.PING.fromString(data) elseif ( action == Response.Actions.FIND_NODE ) then return Response.FIND_NODE.fromString(data) elseif ( action == Response.Actions.ERROR ) then return Response.ERROR.fromString(data) end stdnse.debug1("ERROR: Unknown response received from server") return false, "Failed to parse response" end, } -- The Session Session = { -- Creates a new Session instance to keep track on some of the protocol -- stuff, such as transaction- and instance- identities. -- @param address the local address to pass in the requests to the server -- this could be either the local address or the IP of the router -- depending on if NAT is used or not. -- @param port the local port to pass in the requests to the server -- @return o new instance of Session new = function(self, address, port) local o = { trans_id = math.random(12345678), instance_id = math.random(12345678), address = address, port = port, } setmetatable(o, self) self.__index = self return o end, -- Gets the next transaction ID -- @return trans_id number getTransactionId = function(self) self.trans_id = self.trans_id + 1 return self.trans_id end, -- Gets the next instance ID -- @return instance_id number getInstanceId = function(self) self.instance_id = self.instance_id + 1 return self.instance_id end, -- Gets the stored local address used to create the session -- @return string containing the IP passed to the session getAddress = function(self) return self.address end, -- Get the stored local port used to create the session -- @return number containing the local port getPort = function(self) return self.port end } -- The Helper class, used as main interface between the scripts and the library Helper = { -- Creates a new instance of the Helper class -- @param host table as passed to the action method -- @param port table as passed to the action method -- @param lhost [optional] used if an alternate local address is to be -- passed in the requests to the remote node (ie. NAT is in play). -- @param lport [optional] used if an alternate port is to be passed in -- the requests to the remote node. -- @return o new instance of Helper new = function(self, host, port, lhost, lport) local o = { host = host, port = port, lhost = lhost, lport = lport } setmetatable(o, self) self.__index = self return o end, -- Connects to the remote Vuze Node -- @return true on success, false on failure -- @return err string error message if status is false connect = function(self) local lhost = self.lhost or stdnse.get_script_args('vuzedht.lhost') local lport = self.lport or stdnse.get_script_args('vuzedht.lport') self.socket = nmap.new_socket() if ( lport ) then self.socket:bind(nil, lport) end local status, err = self.socket:connect(self.host, self.port) if ( not(status) ) then return false, "Failed to connect to server" end if ( not(lhost) or not(lport) ) then local status, lh, lp, _, _ = self.socket:get_info() if ( not(status) ) then return false, "Failed to get socket information" end lhost = lhost or lh lport = lport or lp end self.session = Session:new(lhost, lport) return true end, -- Sends a Vuze PING request to the server and parses the response -- @return status true on success, false on failure -- @return response PING response instance on success, -- err string containing the error message on failure ping = function(self) local ping = Request.Ping:new(self.session) local status, err = self.socket:send(tostring(ping)) if ( not(status) ) then return false, "Failed to send PING request to server" end local data status, data = self.socket:receive() if ( not(status) ) then return false, "Failed to receive PING response from server" end local response status, response = Response.fromString(data) if ( not(status) ) then return false, "Failed to parse PING response from server" end return true, response end, -- Requests a list of known nodes by sending the FIND_NODES request -- to the remote node and parses the response. -- @return status true on success, false on failure -- @return response FIND_NODE response instance on success -- err string containing the error message on failure findNodes = function(self) local find = Request.FindNode:new(self.session) local status, err = self.socket:send(tostring(find)) if ( not(status) ) then return false, "Failed to send FIND_NODE request to server" end local data status, data = self.socket:receive() local response status, response = Response.fromString(data) if ( not(status) ) then return false, "Failed to parse FIND_NODE response from server" end return true, response end, -- Closes the socket connect to the remote node close = function(self) self.socket:close() end, } return _ENV;