shugoi 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/shugoi/core.rb +7 -6
- data/lib/shugoi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c1cc48590ec64ab1cd428412be9c433254941c76889714824b0bf890c089bc7
|
|
4
|
+
data.tar.gz: 248ef9edf7a911da8a8e599c8b33aacb856b1947eb39eda08637b6029dfa8f60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6039c75a4545db93ae574b201f1a0f5593284a8ee996b9faaadb091fbec8ab7571ab275e1780374be5af5cbd59116e9dd497c07a5ef6d7d3e32854603c717297
|
|
7
|
+
data.tar.gz: 0e26ba289183b2751e163ced12d650d3456e7bbb74baab0dccfaa8baee8de61c8bb0b290b5c8bad6e0d5e26331ff1fd34cacecbb3290d84b92de542aa7c33b40
|
data/lib/shugoi/core.rb
CHANGED
|
@@ -61,7 +61,7 @@ module Shugoi
|
|
|
61
61
|
# pre-flight PoW. Posé APRÈS une première résolution réussie (middleware).
|
|
62
62
|
valid_cookie = !ctx[:sg_ok].to_s.empty? && @pow.sg_ok_valid?(ctx[:sg_ok], ctx[:ip].to_s, ua)
|
|
63
63
|
# Round 16 (R2) : la preuve est SINGLE-USE (par IP) — un rejeu → 307.
|
|
64
|
-
proof_fresh = valid_proof ? consume_proof(proof
|
|
64
|
+
proof_fresh = valid_proof ? consume_proof(proof) : false
|
|
65
65
|
unless valid_cookie || proof_fresh
|
|
66
66
|
return pow_challenge_307(ctx) if allow_challenge?(ctx[:ip].to_s)
|
|
67
67
|
|
|
@@ -218,12 +218,13 @@ module Shugoi
|
|
|
218
218
|
end
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
-
# Preuve PoW single-use (
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
# Preuve PoW single-use GLOBAL (round 17) — clé = preuve seule (le nonce aléatoire
|
|
222
|
+
# la rend unique) → rejeu depuis N'IMPORTE QUEL IP → 307 (round 16 : clé ip:proof
|
|
223
|
+
# laissait le rejeu cross-IP → 200). Entrées purgées après POW_TTL_MS.
|
|
224
|
+
def consume_proof(proof)
|
|
224
225
|
@mutex.synchronize do
|
|
225
|
-
return false if @used_proofs.key?(
|
|
226
|
-
@used_proofs[
|
|
226
|
+
return false if @used_proofs.key?(proof)
|
|
227
|
+
@used_proofs[proof] = Utils.now_ms
|
|
227
228
|
now = Utils.now_ms
|
|
228
229
|
@used_proofs.delete_if { |_k, t| now - t > POW_TTL_MS }
|
|
229
230
|
true
|
data/lib/shugoi/version.rb
CHANGED