知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
fix(site): a password link locked by wrong guesses opens again after 24 hours
wqugurud51006756b40
diff --git a/server/src/gate.js b/server/src/gate.jsindex 45c045e..461c2d3 100644--- a/server/src/gate.js+++ b/server/src/gate.js@@ -5,8 +5,9 @@import { DurableObject } from "cloudflare:workers";// Wrong passwords for one share: free for the first few, then each waits twice as long; at most-// HOURLY an hour, and LOCK_AT in all locks the link for good (the owner shares it again).-const FREE = 5, HOURLY = 20, LOCK_AT = 100;+// HOURLY an hour, and LOCK_AT in all locks the link for LOCK_FOR seconds. Not for good: anyone with+// the link could otherwise lock it on purpose and leave the people it was meant for shut out.+const FREE = 5, HOURLY = 20, LOCK_AT = 100, LOCK_FOR = 86400;export class Gate extends DurableObject {/** Fixed-window limit: true while fewer than `limit` hits fell in this `window` seconds. */@@ -37,15 +38,20 @@ export class Gate extends DurableObject {}async stats() {- const a = (await this.ctx.storage.get("attempts")) || { fails: 0 };- return { views: (await this.ctx.storage.get("views")) || 0, wrongPasswords: a.fails, locked: a.fails >= LOCK_AT };+ const a = (await this.ctx.storage.get("attempts")) || { fails: 0, last: 0 };+ const locked = a.fails >= LOCK_AT && Date.now() / 1000 - a.last < LOCK_FOR;+ return { views: (await this.ctx.storage.get("views")) || 0, wrongPasswords: a.fails, locked };}/** May a password be tried now? */async mayTry() {const t = Date.now() / 1000;const a = (await this.ctx.storage.get("attempts")) || { fails: 0, last: 0, hour: t, inHour: 0 };- if (a.fails >= LOCK_AT) return { ok: false, locked: true };+ if (a.fails >= LOCK_AT) {+ if (t - a.last < LOCK_FOR) return { ok: false, locked: true, retryAfter: Math.ceil(a.last + LOCK_FOR - t) };+ a.fails = 0;+ await this.ctx.storage.put("attempts", a);+ }if (t - a.hour >= 3600) { a.hour = t; a.inHour = 0; }if (a.inHour >= HOURLY) return { ok: false, retryAfter: Math.ceil(a.hour + 3600 - t) };const wait = a.fails < FREE ? 0 : Math.min(3600, 2 ** (a.fails - FREE));diff --git a/site/i18n/en.json b/site/i18n/en.jsonindex 91a5a9a..95f0d1d 100644--- a/site/i18n/en.json+++ b/site/i18n/en.json@@ -546,7 +546,7 @@"share_js_locked": "Too many wrong passwords: this link is locked","share_js_gone_p": "It has been deleted from the server. Cicada turns any meeting in another language into live bilingual subtitles and notes.","share_js_missing_p": "The link may be incomplete. Cicada turns any meeting in another language into live bilingual subtitles and notes.",- "share_js_locked_p": "Ask the sharer to share it again.",+ "share_js_locked_p": "Try again in 24 hours, or ask the sharer to share it again.","share_js_wrong": "That password is wrong","share_js_wait": "Too many tries: try again in {s} s","share_js_error": "Can't open it right now. Try again later.",diff --git a/site/i18n/ja.json b/site/i18n/ja.jsonindex 7a8266a..ed9809c 100644--- a/site/i18n/ja.json+++ b/site/i18n/ja.json@@ -546,7 +546,7 @@"share_js_locked": "パスワードの誤りが多すぎるため、リンクはロックされました","share_js_gone_p": "サーバーから削除されました。Cicada はどんな外国語の会議もリアルタイムのバイリンガル字幕と議事録にします。","share_js_missing_p": "リンクが不完全かもしれません。Cicada はどんな外国語の会議もリアルタイムのバイリンガル字幕と議事録にします。",- "share_js_locked_p": "共有者にもう一度共有してもらってください。",+ "share_js_locked_p": "24 時間後にもう一度試すか、共有者にもう一度共有してもらってください。","share_js_wrong": "パスワードが違います","share_js_wait": "試行回数が多すぎます。{s} 秒後にもう一度","share_js_error": "今は開けません。しばらくしてからもう一度お試しください。",diff --git a/site/i18n/ko.json b/site/i18n/ko.jsonindex 58af3d4..a9fd419 100644--- a/site/i18n/ko.json+++ b/site/i18n/ko.json@@ -546,7 +546,7 @@"share_js_locked": "비밀번호 오류가 너무 많아 링크가 잠겼습니다","share_js_gone_p": "서버에서 삭제되었습니다. Cicada는 어떤 외국어 회의든 실시간 이중 자막과 회의록으로 바꿔 줍니다.","share_js_missing_p": "링크가 완전하지 않을 수 있습니다. Cicada는 어떤 외국어 회의든 실시간 이중 자막과 회의록으로 바꿔 줍니다.",- "share_js_locked_p": "공유자에게 다시 공유해 달라고 하세요.",+ "share_js_locked_p": "24시간 후에 다시 시도하거나 공유자에게 다시 공유해 달라고 하세요.","share_js_wrong": "비밀번호가 틀렸습니다","share_js_wait": "시도가 너무 많습니다. {s}초 후 다시 시도하세요","share_js_error": "지금은 열 수 없습니다. 잠시 후 다시 시도하세요.",diff --git a/site/i18n/zh.json b/site/i18n/zh.jsonindex da5a660..7a0b67f 100644--- a/site/i18n/zh.json+++ b/site/i18n/zh.json@@ -546,7 +546,7 @@"share_js_locked": "密码试错次数太多,链接已锁定","share_js_gone_p": "内容已从服务器删除。知了能把任何外语会议实时转成双语字幕和纪要。","share_js_missing_p": "链接可能不完整。知了能把任何外语会议实时转成双语字幕和纪要。",- "share_js_locked_p": "请分享者重新分享一次。",+ "share_js_locked_p": "24 小时后再试,或请分享者重新分享。","share_js_wrong": "密码不对","share_js_wait": "试的次数太多,{s} 秒后再试","share_js_error": "暂时打不开,请稍后再试",