mirror of
https://github.com/kepler155c/opus
synced 2025-01-17 10:52:53 +00:00
socket update
This commit is contained in:
parent
3c22a872b0
commit
97a442e999
@ -115,7 +115,7 @@ function Socket.connect(host, port)
|
|||||||
type = 'OPEN',
|
type = 'OPEN',
|
||||||
shost = socket.shost,
|
shost = socket.shost,
|
||||||
dhost = socket.dhost,
|
dhost = socket.dhost,
|
||||||
t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, Security.getPublicKey()),
|
t = Crypto.encrypt({ ts = os.time(), seq = socket.seq, nts = os.epoch('utc') }, Security.getPublicKey()),
|
||||||
rseq = socket.wseq,
|
rseq = socket.wseq,
|
||||||
wseq = socket.rseq,
|
wseq = socket.rseq,
|
||||||
})
|
})
|
||||||
@ -170,6 +170,10 @@ local function trusted(msg, port)
|
|||||||
if pubKey then
|
if pubKey then
|
||||||
local data = Crypto.decrypt(msg.t or '', pubKey)
|
local data = Crypto.decrypt(msg.t or '', pubKey)
|
||||||
|
|
||||||
|
if data.nts then -- upgraded security
|
||||||
|
return data.nts and tonumber(data.nts) and math.abs(os.epoch('utc') - data.nts) < 1024
|
||||||
|
end
|
||||||
|
|
||||||
--local sharedKey = modexp(pubKey, exchange.secretKey, public.primeMod)
|
--local sharedKey = modexp(pubKey, exchange.secretKey, public.primeMod)
|
||||||
return data.ts and tonumber(data.ts) and math.abs(os.time() - data.ts) < 24
|
return data.ts and tonumber(data.ts) and math.abs(os.time() - data.ts) < 24
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user