aboutsummaryrefslogtreecommitdiff
path: root/src/ftp.lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2022-03-18 12:12:39 +0100
committerCaleb Maclennan <caleb@alerque.com>2022-03-19 17:13:15 +0300
commit601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1 (patch)
treee3b9c152b9ff8a431d1431edb0a42d051d256f13 /src/ftp.lua
parent480c05257211b3e566f33fdf8cf051233e2dab30 (diff)
downloadluasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.tar.gz
luasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.tar.bz2
luasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.zip
refactor: Address issues raised by linter
Diffstat (limited to 'src/ftp.lua')
-rw-r--r--src/ftp.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ftp.lua b/src/ftp.lua
index bd528ca..0ebc508 100644
--- a/src/ftp.lua
+++ b/src/ftp.lua
@@ -56,7 +56,7 @@ end
56 56
57function metat.__index:login(user, password) 57function metat.__index:login(user, password)
58 self.try(self.tp:command("user", user or _M.USER)) 58 self.try(self.tp:command("user", user or _M.USER))
59 local code, reply = self.try(self.tp:check{"2..", 331}) 59 local code, _ = self.try(self.tp:check{"2..", 331})
60 if code == 331 then 60 if code == 331 then
61 self.try(self.tp:command("pass", password or _M.PASSWORD)) 61 self.try(self.tp:command("pass", password or _M.PASSWORD))
62 self.try(self.tp:check("2..")) 62 self.try(self.tp:check("2.."))
@@ -66,7 +66,7 @@ end
66 66
67function metat.__index:pasv() 67function metat.__index:pasv()
68 self.try(self.tp:command("pasv")) 68 self.try(self.tp:command("pasv"))
69 local code, reply = self.try(self.tp:check("2..")) 69 local _, reply = self.try(self.tp:check("2.."))
70 local pattern = "(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)" 70 local pattern = "(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)"
71 local a, b, c, d, p1, p2 = socket.skip(2, string.find(reply, pattern)) 71 local a, b, c, d, p1, p2 = socket.skip(2, string.find(reply, pattern))
72 self.try(a and b and c and d and p1 and p2, reply) 72 self.try(a and b and c and d and p1 and p2, reply)
@@ -83,9 +83,9 @@ end
83 83
84function metat.__index:epsv() 84function metat.__index:epsv()
85 self.try(self.tp:command("epsv")) 85 self.try(self.tp:command("epsv"))
86 local code, reply = self.try(self.tp:check("229")) 86 local _, reply = self.try(self.tp:check("229"))
87 local pattern = "%((.)(.-)%1(.-)%1(.-)%1%)" 87 local pattern = "%((.)(.-)%1(.-)%1(.-)%1%)"
88 local d, prt, address, port = string.match(reply, pattern) 88 local _, _, _, port = string.match(reply, pattern)
89 self.try(port, "invalid epsv response") 89 self.try(port, "invalid epsv response")
90 self.pasvt = { 90 self.pasvt = {
91 address = self.tp:getpeername(), 91 address = self.tp:getpeername(),
@@ -102,7 +102,7 @@ end
102function metat.__index:port(address, port) 102function metat.__index:port(address, port)
103 self.pasvt = nil 103 self.pasvt = nil
104 if not address then 104 if not address then
105 address, port = self.try(self.tp:getsockname()) 105 address = self.try(self.tp:getsockname())
106 self.server = self.try(socket.bind(address, 0)) 106 self.server = self.try(socket.bind(address, 0))
107 address, port = self.try(self.server:getsockname()) 107 address, port = self.try(self.server:getsockname())
108 self.try(self.server:settimeout(_M.TIMEOUT)) 108 self.try(self.server:settimeout(_M.TIMEOUT))
@@ -118,7 +118,7 @@ end
118function metat.__index:eprt(family, address, port) 118function metat.__index:eprt(family, address, port)
119 self.pasvt = nil 119 self.pasvt = nil
120 if not address then 120 if not address then
121 address, port = self.try(self.tp:getsockname()) 121 address = self.try(self.tp:getsockname())
122 self.server = self.try(socket.bind(address, 0)) 122 self.server = self.try(socket.bind(address, 0))
123 address, port = self.try(self.server:getsockname()) 123 address, port = self.try(self.server:getsockname())
124 self.try(self.server:settimeout(_M.TIMEOUT)) 124 self.try(self.server:settimeout(_M.TIMEOUT))
@@ -142,7 +142,7 @@ function metat.__index:send(sendt)
142 local command = sendt.command or "stor" 142 local command = sendt.command or "stor"
143 -- send the transfer command and check the reply 143 -- send the transfer command and check the reply
144 self.try(self.tp:command(command, argument)) 144 self.try(self.tp:command(command, argument))
145 local code, reply = self.try(self.tp:check{"2..", "1.."}) 145 local code, _ = self.try(self.tp:check{"2..", "1.."})
146 -- if there is not a pasvt table, then there is a server 146 -- if there is not a pasvt table, then there is a server
147 -- and we already sent a PORT command 147 -- and we already sent a PORT command
148 if not self.pasvt then self:portconnect() end 148 if not self.pasvt then self:portconnect() end