Parley: Federated, decentralised chat that speaks plain IRC

Parley: Federated, decentralised chat that speaks plain IRC

Parley:支持原生 IRC 协议的联邦式去中心化聊天系统

Federation: know a peer’s version when it said hello first (#42)

联邦机制:当对端节点发起握手时,正确识别其版本号 (#42)

A peer that links by saying hello to us first shows no version on the landing page or the admin peers page for a while, often ten minutes or more. 当一个对端节点通过主动向我们发送“hello”来建立连接时,其版本号在登录页或管理员对端页面上会长时间(通常为十分钟或更久)无法显示。

Cause

原因

p.software was set only in hello(), our outbound handshake. When the peer said hello first, applyHello() marked it linked but never read its instance document, so the version stayed empty until our own next hello(). That relink waits for relinkEvery (10 minutes) with no contact from the peer. Every inbound event, successful push and hello from the peer resets that clock, so on a busy link the version could stay blank indefinitely. p.software 仅在我们的出站握手函数 hello() 中被设置。当对端先发送“hello”时,applyHello() 虽然将其标记为已连接,但并未读取其实例文档,因此版本号会一直为空,直到我们下一次执行 hello()。该重连机制需要等待 relinkEvery(10 分钟)且期间无对端通信才会触发。由于对端的每一次入站事件、成功推送和“hello”都会重置计时器,因此在繁忙的连接中,版本号可能会无限期地保持空白。

Change

变更

  • The inbound TypeHello case reads the peer’s version and passes it to applyHello, which records it. The inbox has just verified that hello against the peer’s instance document, so s.disc.Instance answers from the cache. It is read before taking s.mu, as hello() does.

  • 入站的 TypeHello 情况现在会读取对端的版本并将其传递给 applyHello 进行记录。由于收件箱刚刚根据对端的实例文档验证了该“hello”请求,因此 s.disc.Instance 会从缓存中获取响应。与 hello() 一样,该读取操作在获取 s.mu 锁之前完成。

  • peerSoftware and setSoftwareLocked are shared by both paths, so the peer upgraded log line and the rule that an unreadable document keeps the old value stay in one place.

  • peerSoftware 和 setSoftwareLocked 在两条路径中共享,因此“peer upgraded”(对端已升级)的日志行以及“无法读取文档时保留旧值”的规则被统一管理。

  • TestPeerSoftwareKnownToTheSideThatWasGreeted links two instances with the default intervals, so no relink happens during the test, and checks that both show the other’s version.

  • TestPeerSoftwareKnownToTheSideThatWasGreeted 测试用例在默认间隔下连接两个实例(确保测试期间不会触发重连),并验证双方是否都能显示对方的版本号。


README.md: Parley

README.md:Parley

Parley is a chat network with no centre. Every person (or team) runs a small instance for their own domain. Instances find each other through DNS and well-known identity documents, exchange signed messages over HTTPS, and present the whole federated network to ordinary IRC clients such as irssi, WeeChat or Textual, with no plugins. Parley 是一个没有中心节点的聊天网络。每个人(或团队)都可以为自己的域名运行一个小型的实例。实例通过 DNS 和众所周知的身份文档相互发现,通过 HTTPS 交换签名消息,并将整个联邦网络呈现给普通的 IRC 客户端(如 irssi、WeeChat 或 Textual),无需任何插件。

Identities look like email: alice@foo.com runs on foo.com, bob@bar.com on bar.com. Bob types /msg alice@foo.com hi and it just works, even if the two instances have never heard of each other before. 身份标识看起来就像电子邮件:alice@foo.com 运行在 foo.com 上,bob@bar.com 运行在 bar.com 上。Bob 输入 /msg alice@foo.com hi 即可直接发送,即使这两个实例之前从未建立过联系。

Status: working proof of concept. It demonstrates the design end to end and runs a real instance, but it is not hardened yet. 状态:工作中的概念验证(PoC)。它展示了端到端的完整设计并运行着一个真实实例,但尚未进行安全加固。