1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-28 17:19:05 +00:00

Remove trailing whitespace in lua files

Whitespace is not significant, so this should not be a problem.
https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-23 21:51:58 +00:00
parent 86ac3c0a19
commit 620f9fdb34
499 changed files with 11134 additions and 11134 deletions

View File

@@ -17,11 +17,11 @@ _ENV = stdnse.module("iax2", stdnse.seeall)
IAX2 = {
FrameType = {
IAX = 6,
IAX = 6,
},
SubClass = {
ACK = 0x04,
REGACK = 0x0f,
@@ -29,21 +29,21 @@ IAX2 = {
REGREL = 0x11,
CALLTOKEN = 0x28,
},
InfoElement = {
USERNAME = 0x06,
USERNAME = 0x06,
CHALLENGE = 0x0f,
MD5_RESULT = 0x10,
CALLTOKEN = 0x36,
},
PacketType = {
FULL = 1,
},
-- The IAX2 Header
Header = {
-- Creates a new Header instance
-- @param src_call number containing the source call
-- @param dst_call number containing the dest call
@@ -68,9 +68,9 @@ IAX2 = {
self.__index = self
return o
end,
-- Parses data, a byte string, and creates a new Header instance
-- @return header instance of Header
-- @return header instance of Header
parse = function(data)
local header = IAX2.Header:new()
local pos, frame_type = bin.unpack("C", data)
@@ -90,13 +90,13 @@ IAX2 = {
end
pos, header.dst_call = bin.unpack(">S", data, pos - 1)
header.dst_call = bit.band(header.dst_call, 0x7FFF)
pos, header.timestamp, header.oseqno,
pos, header.timestamp, header.oseqno,
header.iseqno, header.frametype, header.subclass = bin.unpack(">ICCCC", data, pos)
return header
end,
-- Converts the instance to a string
-- @return str containing the instance
__tostring = function(self)
@@ -114,10 +114,10 @@ IAX2 = {
self.oseqno, self.iseqno, self.frametype, self.subclass)
end,
},
-- The IAX2 Request class
Request = {
-- Creates a new instance
-- @param header instance of Header
new = function(self, header)
@@ -127,9 +127,9 @@ IAX2 = {
}
setmetatable(o, self)
self.__index = self
return o
return o
end,
-- Sets an Info Element or adds one, in case it's missing
-- @param key the key value of the IE to add
-- @param value string containing the value to set or add
@@ -141,7 +141,7 @@ IAX2 = {
end
table.insert(self.ies, { type = key, value = value } )
end,
-- Gets an information element
-- @param key number containing the element number to retrieve
-- @return ie table containing the info element if it exists
@@ -160,24 +160,24 @@ IAX2 = {
for _, ie in ipairs(self.ies) do
data = data .. bin.pack("Cp", ie.type, ie.value )
end
return tostring(self.header) .. data
end,
},
-- The IAX2 Response
Response = {
-- Creates a new instance
new = function(self)
local o = { ies = {} }
setmetatable(o, self)
self.__index = self
return o
return o
end,
-- Sets an Info Element or adds one, in case it's missing
-- @param key the key value of the IE to add
-- @param value string containing the value to set or add
@@ -189,7 +189,7 @@ IAX2 = {
end
table.insert(self.ies, { type = key, value = value } )
end,
-- Gets an information element
-- @param key number containing the element number to retrieve
-- @return ie table containing the info element if it exists
@@ -200,16 +200,16 @@ IAX2 = {
end
end
end,
-- Parses data, a byte string, and creates a response
-- @return resp instance of response
-- @return resp instance of response
parse = function(data)
local resp = IAX2.Response:new()
if ( not(resp) ) then return end
resp.header = IAX2.Header.parse(data)
if ( not(resp.header) ) then return end
local pos = 13
resp.ies = {}
repeat
@@ -219,14 +219,14 @@ IAX2 = {
until( pos > #data )
return resp
end,
}
}
Helper = {
-- Creates a new Helper instance
-- @param host table as received by the action method
-- @param port table as received by the action method
@@ -237,9 +237,9 @@ Helper = {
local o = { host = host, port = port, options = options or {} }
setmetatable(o, self)
self.__index = self
return o
return o
end,
-- Connects the UDP socket to the server
-- @return status true on success, false on failure
-- @return err message containing error if status is false
@@ -248,7 +248,7 @@ Helper = {
self.socket:set_timeout(self.options.timeout or 5000)
return self.socket:connect(self.host, self.port)
end,
-- Sends a request to the server and receives the response
-- @param req instance containing the request to send to the server
-- @return status true on success, false on failure
@@ -263,11 +263,11 @@ Helper = {
if ( not(status) ) then
return false, "Failed to receive response from server"
end
local resp = IAX2.Response.parse(data)
return true, resp
end,
-- Request a session release
-- @param username string containing the extention (username)
-- @param password string containing the password
@@ -299,45 +299,45 @@ Helper = {
if ( not(status) ) then
return false, resp
end
local challenge = resp:getIE(IAX2.InfoElement.CHALLENGE)
if ( not(challenge) ) then
return false, "Failed to retrieve challenge from server"
end
regrel.header.iseqno = 1
regrel.header.oseqno = 1
regrel.header.dst_call = resp.header.src_call
regrel.ies = {}
local hash = stdnse.tohex(openssl.md5(challenge.value .. password))
regrel:setIE(IAX2.InfoElement.USERNAME, username)
regrel:setIE(IAX2.InfoElement.MD5_RESULT, hash)
status, resp = self:exch(regrel)
if ( not(status) ) then
return false, resp
end
if ( IAX2.SubClass.ACK == resp.header.subclass ) then
local data
status, data = self.socket:receive()
status, data = self.socket:receive()
resp = IAX2.Response.parse(data)
end
if ( status and IAX2.SubClass.REGACK == resp.header.subclass ) then
return true
end
return false, "Release failed"
end,
-- Close the connection with the server
-- @return true on success, false on failure
close = function(self)
return self.socket:close()
end,
}
return _ENV;