Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(network): review fixes for the bounds, and a stolen computer after recovery

leepokai8b4e08c06bd0
diff --git a/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx b/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx
index d40494a6..c56785d0 100644
--- a/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx
+++ b/apps/desktop/src/renderer/views/settings/NetworkSheets.tsx
@@ -160,7 +160,7 @@ export function RecoverSheet({ store, net }: { store: BotStore; net: Network })
setBusy(true)
try {
await network.recover(store, net.id, code)
- setResult({ ok: true, text: tr('{name} is the owner now. Remove the lost computer from the list.').replaceAll('{name}', net.computer) })
+ setResult({ ok: true, text: tr('{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.').replaceAll('{name}', net.computer) })
} catch (e) {
setResult({ ok: false, text: errorText(e) })
} finally {
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index 2e9bcd57..1cf1cb05 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "Wähle auf dem anderen Computer unter Netzwerk „Mit Einladung beitreten“.",
"Recover ownership": "Eigentum wiederherstellen",
"Recover": "Wiederherstellen",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste.",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste. Wenn er gestohlen wurde, entferne auch die Computer, die er eingeladen hat.",
"For when the owner is lost: this computer becomes the owner.": "Falls der Eigentümer verloren ist: Dieser Computer wird Eigentümer.",
"Recovery code": "Wiederherstellungscode",
"Refresh": "Aktualisieren",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ fertig · tab nächstes Feld · ←→ Verbindung · esc zurück",
"Recovery code copied": "Wiederherstellungscode kopiert",
"Invite copied": "Einladung kopiert",
- "This computer is the owner now. Remove the lost computer from the list.": "Dieser Computer ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste.",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "Dieser Computer ist jetzt Eigentümer. Entferne den verlorenen Computer aus der Liste. Wenn er gestohlen wurde, entferne auch die Computer, die er eingeladen hat.",
"Removed from the network": "Aus dem Netzwerk entfernt",
"Made an admin": "Zum Admin gemacht",
"Only the owner makes plain members admins": "Nur der Eigentümer macht einfache Mitglieder zu Admins",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index 896a8484..452b55c0 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "En la otra computadora, elige Unirse con una invitación en Red.",
"Recover ownership": "Recuperar la propiedad",
"Recover": "Recuperar",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} es ahora la propietaria. Quita de la lista la computadora perdida.",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} es ahora la propietaria. Quita de la lista la computadora perdida. Si la robaron, quita también las computadoras que invitó.",
"For when the owner is lost: this computer becomes the owner.": "Si se perdió la propietaria: esta computadora pasa a serlo.",
"Recovery code": "Código de recuperación",
"Refresh": "Actualizar",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ listo · tab siguiente campo · ←→ conexión · esc volver",
"Recovery code copied": "Código de recuperación copiado",
"Invite copied": "Invitación copiada",
- "This computer is the owner now. Remove the lost computer from the list.": "Esta computadora es ahora la propietaria. Quita de la lista la computadora perdida.",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "Esta computadora es ahora la propietaria. Quita de la lista la computadora perdida. Si la robaron, quita también las computadoras que invitó.",
"Removed from the network": "Quitada de la red",
"Made an admin": "Ahora es administrador",
"Only the owner makes plain members admins": "Solo la propietaria puede hacer administradores a los miembros",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index 6ed526a9..60ff3355 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "Sur l'autre ordinateur, choisissez Rejoindre avec une invitation dans Réseau.",
"Recover ownership": "Récupérer la propriété",
"Recover": "Récupérer",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} est maintenant propriétaire. Retirez l'ordinateur perdu de la liste.",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} est maintenant propriétaire. Retirez l'ordinateur perdu de la liste. S'il a été volé, retirez aussi ceux qu'il a invités.",
"For when the owner is lost: this computer becomes the owner.": "Si le propriétaire est perdu : cet ordinateur devient propriétaire.",
"Recovery code": "Code de récupération",
"Refresh": "Actualiser",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ terminé · tab champ suivant · ←→ connexion · esc retour",
"Recovery code copied": "Code de récupération copié",
"Invite copied": "Invitation copiée",
- "This computer is the owner now. Remove the lost computer from the list.": "Cet ordinateur est maintenant propriétaire. Retirez l'ordinateur perdu de la liste.",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "Cet ordinateur est maintenant propriétaire. Retirez l'ordinateur perdu de la liste. S'il a été volé, retirez aussi ceux qu'il a invités.",
"Removed from the network": "Retiré du réseau",
"Made an admin": "Nommé admin",
"Only the owner makes plain members admins": "Seul le propriétaire nomme des membres admins",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index eb68c46d..ab386386 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "もう一方のコンピューターで「ネットワーク」の「招待で参加」を選んでください。",
"Recover ownership": "オーナー権を取り戻す",
"Recover": "復旧",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} がオーナーになりました。なくしたコンピューターを一覧から削除してください。",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} がオーナーになりました。なくしたコンピューターを一覧から削除してください。盗まれたのなら、それが招待したコンピューターも削除してください。",
"For when the owner is lost: this computer becomes the owner.": "オーナーをなくしたときに:このコンピューターがオーナーになります。",
"Recovery code": "復旧コード",
"Refresh": "更新",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ 完了 · tab 次の項目 · ←→ 接続方法 · esc 戻る",
"Recovery code copied": "復旧コードをコピーしました",
"Invite copied": "招待をコピーしました",
- "This computer is the owner now. Remove the lost computer from the list.": "このコンピューターがオーナーになりました。なくしたコンピューターを一覧から削除してください。",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "このコンピューターがオーナーになりました。なくしたコンピューターを一覧から削除してください。盗まれたのなら、それが招待したコンピューターも削除してください。",
"Removed from the network": "ネットワークから削除しました",
"Made an admin": "管理者にしました",
"Only the owner makes plain members admins": "一般メンバーを管理者にできるのはオーナーだけです",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 2b423ca2..515d8b2b 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "다른 컴퓨터의 네트워크에서 초대로 참여를 선택하세요.",
"Recover ownership": "소유권 복구",
"Recover": "복구",
- "{name} is the owner now. Remove the lost computer from the list.": "이제 {name}이(가) 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요.",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "이제 {name}이(가) 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요. 도난당했다면 그 컴퓨터가 초대한 컴퓨터도 함께 제거하세요.",
"For when the owner is lost: this computer becomes the owner.": "소유자를 잃어버렸을 때: 이 컴퓨터가 소유자가 됩니다.",
"Recovery code": "복구 코드",
"Refresh": "새로고침",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ 완료 · tab 다음 항목 · ←→ 연결 방식 · esc 뒤로",
"Recovery code copied": "복구 코드를 복사했습니다",
"Invite copied": "초대를 복사했습니다",
- "This computer is the owner now. Remove the lost computer from the list.": "이제 이 컴퓨터가 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요.",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "이제 이 컴퓨터가 소유자입니다. 잃어버린 컴퓨터를 목록에서 제거하세요. 도난당했다면 그 컴퓨터가 초대한 컴퓨터도 함께 제거하세요.",
"Removed from the network": "네트워크에서 제거했습니다",
"Made an admin": "관리자로 지정했습니다",
"Only the owner makes plain members admins": "일반 멤버를 관리자로 지정할 수 있는 건 소유자뿐입니다",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
index 0b0a7316..3ff1f79f 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "在另一台电脑的“网络”里选“用邀请加入”。",
"Recover ownership": "取回所有权",
"Recover": "恢复",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} 现在是所有者。请把丢失的电脑从列表中移除。",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} 现在是所有者。请把丢失的电脑从列表中移除。如果是被偷的,也一并移除它邀请的电脑。",
"For when the owner is lost: this computer becomes the owner.": "所有者丢失时使用:让这台电脑成为所有者。",
"Recovery code": "恢复码",
"Refresh": "刷新",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ 完成 · tab 下一栏 · ←→ 连接方式 · esc 返回",
"Recovery code copied": "已复制恢复码",
"Invite copied": "已复制邀请",
- "This computer is the owner now. Remove the lost computer from the list.": "这台电脑现在是所有者。请把丢失的电脑从列表中移除。",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "这台电脑现在是所有者。请把丢失的电脑从列表中移除。如果是被偷的,也一并移除它邀请的电脑。",
"Removed from the network": "已从网络移除",
"Made an admin": "已设为管理员",
"Only the owner makes plain members admins": "只有所有者能把普通成员设为管理员",
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
index a6934c03..fcd0fcc2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -1296,7 +1296,7 @@
"On the other computer, choose Join with invite under Network.": "在另一臺電腦的「網路」裡選「用邀請加入」。",
"Recover ownership": "取回擁有權",
"Recover": "復原",
- "{name} is the owner now. Remove the lost computer from the list.": "{name} 現在是擁有者。請把遺失的電腦從清單中移除。",
+ "{name} is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "{name} 現在是擁有者。請把遺失的電腦從清單中移除。如果是被偷的,也一併移除它邀請的電腦。",
"For when the owner is lost: this computer becomes the owner.": "擁有者遺失時使用:讓這臺電腦成為擁有者。",
"Recovery code": "復原碼",
"Refresh": "重新整理",
@@ -1326,7 +1326,7 @@
"↵ done · tab next field · ←→ connector · esc back": "↵ 完成 · tab 下一欄 · ←→ 連線方式 · esc 返回",
"Recovery code copied": "已複製復原碼",
"Invite copied": "已複製邀請",
- "This computer is the owner now. Remove the lost computer from the list.": "這臺電腦現在是擁有者。請把遺失的電腦從清單中移除。",
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.": "這臺電腦現在是擁有者。請把遺失的電腦從清單中移除。如果是被偷的,也一併移除它邀請的電腦。",
"Removed from the network": "已從網路移除",
"Made an admin": "已設為管理員",
"Only the owner makes plain members admins": "只有擁有者能把一般成員設為管理員",
diff --git a/host/crates/network/src/bin/codync-network/main.rs b/host/crates/network/src/bin/codync-network/main.rs
index 9a12142b..376156d7 100644
--- a/host/crates/network/src/bin/codync-network/main.rs
+++ b/host/crates/network/src/bin/codync-network/main.rs
@@ -238,8 +238,8 @@ impl Daemon {
}
fn add(&self, local: LocalAgent) -> Result<String> {
- if local.agent.id == TERMINAL || local.agent.id.contains(['/', ' ']) {
- bail!("pick another agent name (not {TERMINAL}, no spaces or /)");
+ if local.agent.id == TERMINAL || local.agent.id.contains(['/', ' ']) || local.agent.id.len() > 64 {
+ bail!("pick another agent name (not {TERMINAL}, at most 64 characters, no spaces or /)");
}
let id = local.agent.id.clone();
let mut agents = self.agents.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
diff --git a/host/crates/network/src/node/endpoint.rs b/host/crates/network/src/node/endpoint.rs
index fff4eb4a..cd07b13e 100644
--- a/host/crates/network/src/node/endpoint.rs
+++ b/host/crates/network/src/node/endpoint.rs
@@ -2,7 +2,7 @@
//! again whenever its addresses change.
use super::{Inner, locked};
-use crate::roster::Change;
+use crate::roster::{Change, bounded_addr};
use crate::types::Connector;
use crate::wire;
use anyhow::{Context, Result, anyhow};
@@ -19,12 +19,14 @@ const ADDR_SETTLE: Duration = Duration::from_secs(2);
impl Inner {
/// Writes where this computer is into the roster when it moved. Returns whether it did.
pub(super) fn locate(&self, addr: EndpointAddr) -> Result<bool> {
+ // As signed: a computer with more addresses than a location holds hasn't moved each time.
+ let addr = bounded_addr(addr);
let mut guard = locked(&self.roster);
let Some(roster) = guard.as_mut() else { return Ok(false) };
if roster.members().get(&self.me()).is_none_or(|m| m.addr == addr) {
return Ok(false);
}
- roster.sign(self.endpoint.secret_key(), wire::now_ms(), Change::locate(addr))?;
+ roster.sign(self.endpoint.secret_key(), wire::now_ms(), Change::Locate { addr })?;
self.save(roster)?;
Ok(true)
}
diff --git a/host/crates/network/src/node/mod.rs b/host/crates/network/src/node/mod.rs
index 0a03bdd1..66321165 100644
--- a/host/crates/network/src/node/mod.rs
+++ b/host/crates/network/src/node/mod.rs
@@ -177,7 +177,11 @@ impl Node {
}
// Where this computer is; nothing to add when it knows no address yet.
let addr = self.inner.endpoint.addr();
- let _ = roster.sign(self.inner.endpoint.secret_key(), wire::now_ms(), Change::locate(addr));
+ let _ = roster.sign(
+ self.inner.endpoint.secret_key(),
+ wire::now_ms(),
+ Change::Locate { addr: roster::bounded_addr(addr) },
+ );
// Held across saving and keeping it, so whoever `changes` wakes sees it.
let mut guard = locked(&self.inner.roster);
self.inner.save(&roster)?;
diff --git a/host/crates/network/src/roster.rs b/host/crates/network/src/roster.rs
index 0f9d7dc5..a340f58d 100644
--- a/host/crates/network/src/roster.rs
+++ b/host/crates/network/src/roster.rs
@@ -27,7 +27,8 @@ const FILE: &str = "network.json";
const MAX_PER_SIGNER: usize = 256;
/// What one entry may hold, so no member can grow the log past what a hello carries.
const MAX_ENTRY: usize = 8 * 1024;
-/// The addresses a location keeps: the relay first, then the direct ones.
+/// The addresses a location keeps: the relay first (`TransportAddr` orders relays before IP
+/// addresses), then the direct ones.
const MAX_ADDRS: usize = 64;
/// A computer's name (`node::check_name`'s 40) with the number `free_name` adds.
const MAX_NAME: usize = 48;
@@ -96,11 +97,10 @@ pub enum Change {
},
}
-impl Change {
- /// Where `addr` is reachable, cut to the addresses a location may hold.
- pub fn locate(addr: EndpointAddr) -> Self {
- Self::Locate { addr: EndpointAddr::from_parts(addr.id, addr.addrs.into_iter().take(MAX_ADDRS)) }
- }
+/// `addr` cut to the addresses a location may hold: what this computer signs, and compares with
+/// the location it signed before.
+pub fn bounded_addr(addr: EndpointAddr) -> EndpointAddr {
+ EndpointAddr::from_parts(addr.id, addr.addrs.into_iter().take(MAX_ADDRS))
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
@@ -156,7 +156,7 @@ impl Roster {
let network = root.public();
let mut roster = Self { network, log: BTreeSet::new(), members: BTreeMap::new(), removed: BTreeSet::new() };
roster.log.insert(Signed::new(&network, &root, at, Change::Owner { id: me.public(), name }));
- roster.log.insert(Signed::new(&network, me, at, Change::locate(addr)));
+ roster.log.insert(Signed::new(&network, me, at, Change::Locate { addr: bounded_addr(addr) }));
roster.rebuild();
(roster, root)
}
diff --git a/host/crates/network/src/roster/tests.rs b/host/crates/network/src/roster/tests.rs
index abeaec25..a65a4f7a 100644
--- a/host/crates/network/src/roster/tests.rs
+++ b/host/crates/network/src/roster/tests.rs
@@ -135,11 +135,14 @@ fn entries_out_of_bounds_dont_count_and_a_removed_computer_has_no_location() {
assert!(!r.merge(&junk), "nothing out of bounds counts");
assert_eq!(r.members().len(), 3);
assert!(serde_json::to_vec(&r).unwrap().len() < size + 1024);
- // Its own location is cut to what one may hold, and counts.
- r.sign(&laptop, 6, Change::locate(huge)).unwrap();
+ // Its own location is cut to what one may hold, and counts; signing the same again changes
+ // nothing, so a computer compares where it is with what it signed, cut the same way.
+ r.sign(&laptop, 6, Change::Locate { addr: bounded_addr(huge.clone()) }).unwrap();
+ assert_eq!(r.members()[&laptop.public()].addr, bounded_addr(huge.clone()));
assert_eq!(r.members()[&laptop.public()].addr.addrs.len(), MAX_ADDRS);
+ assert!(r.sign(&laptop, 7, Change::Locate { addr: bounded_addr(huge) }).is_err());
// Once laptop is removed, where it was goes too.
- r.sign(&desk, 7, Change::Remove { id: laptop.public(), cascade: false }).unwrap();
+ r.sign(&desk, 8, Change::Remove { id: laptop.public(), cascade: false }).unwrap();
assert!(!r.log.iter().any(|s| s.by == laptop.public() && matches!(s.change, Change::Locate { .. })));
}
diff --git a/host/src/tui/manage/network.rs b/host/src/tui/manage/network.rs
index eb2b5578..12696022 100644
--- a/host/src/tui/manage/network.rs
+++ b/host/src/tui/manage/network.rs
@@ -264,7 +264,9 @@ impl App {
KeyCode::Esc => Step::List,
KeyCode::Enter if !code.text.trim().is_empty() => {
n.busy = true;
- let done = NetReply::Done("This computer is the owner now. Remove the lost computer from the list.");
+ let done = NetReply::Done(
+ "This computer is the owner now. Remove the lost computer from the list; if it was stolen, also remove the computers it invited.",
+ );
self.net("networkRecover", json!({"network": n.id(), "code": code.text.trim()}), done);
Step::Recover(code)
}