Skip to content

Add prefer-tcp setting and a public config command - #65

Open
requilence wants to merge 1 commit into
mainfrom
prefer-tcp-transport
Open

requilence wants to merge 1 commit into
mainfrom
prefer-tcp-transport

Conversation

@requilence

Copy link
Copy Markdown
Contributor

Lets users make Anytype connect to sync nodes and peers over TCP before QUIC (UDP), which helps on networks that block or throttle UDP. Heart already supports this through preferYamuxTransport on AccountCreate/AccountSelect, but the CLI never set it. Spec: docs/plans/prefer-tcp-setting.md.

anytype config set prefer-tcp true
anytype service restart

Breaking changes

  • Removed the hidden anytype config get|set accountId|techSpaceId and anytype config reset. They were undocumented, and reset deleted the fallback credentials and the saved listen address. auth status and inspect --json still show the account Id.

Changes

  • Transport preference: every account start sends PreferYamuxTransport: auth login, auth create, the service's auto-login and the automation logins. The value comes from ANYTYPE_PREFER_TCP, then preferTcp in ~/.anytype/config.json, then false. An invalid env value prints a warning and is ignored for normal logins and auto-login. Automation fails with invalid_environment before changing anything. The change applies at the next account start, so service restart picks it up without touching the service definition.
  • anytype config: now public, with list, get, set and unset, and shell completion for keys. Keys live in a small registry in core/config/settings.go. listen-address is read-only there: set points to --listen-address, because the installed service can carry its own address. config list doesn't take the instance lock.
  • Config storage: user settings move into a Settings struct embedded in Config. The file format is unchanged, and logout keeps every setting instead of copying ApiListenAddr by hand. Load now reads into a fresh value, so keys another process removed don't stay in memory in long-running processes like shell.
  • Status: auth status prints Prefer TCP: <value> (<source>). The automation inspection result gets a transport block (prefer_tcp, source, observation: configured).
  • Docs: README Settings section and a troubleshooting entry for networks that block UDP, a SELF-HOSTED troubleshooting entry, AUTOMATION.md, CLAUDE.md.

Testing

  • make build, make test and make lint (0 issues) pass.
  • Unit tests cover the env > config > default order (including invalid and empty env values), the key registry, the flat file format, logout keeping settings, UpdateSettings, Load dropping removed keys, the config commands against a temp HOME, the instance lock for config subcommands, and automation create/login sending the flag. Removing the flag from the automation requests makes the tests fail.
  • Ran the built binary's config commands against a throwaway HOME.
  • Not run live: no server or login was started, so I haven't confirmed that heart dials TCP first. Smoke test on a throwaway account: config set prefer-tcp true, restart, and check heart's debug log (dial addrs ordered yamux before quic).

Known gaps (deferred)

  • Heart doesn't report which transport the running account uses, so status shows the configured value. It can differ from what's running until a restart.
  • No machine (--json) interface for anytype config.

Heart dials QUIC first and only falls back to TCP within each dial, so on
networks that block or throttle UDP every connection waits for QUIC to
fail. AccountCreate/AccountSelect accept preferYamuxTransport, but the CLI
never set it.

- Send PreferYamuxTransport on every account start (auth login, auth
  create, service auto-login, automation). The value comes from
  ANYTYPE_PREFER_TCP, then preferTcp in config.json, then false.
- Group user settings in an embedded Config.Settings so logout keeps all
  of them; the file format is unchanged.
- Make `anytype config` public with list/get/set/unset over a key
  registry (listen-address read-only, prefer-tcp). Drop the hidden
  accountId/techSpaceId keys and `config reset`, which deleted fallback
  credentials.
- Load the config into a fresh value so keys removed by another process
  don't linger in long-running processes.
- Show the setting in `auth status` and the automation `transport` block.

Spec: docs/plans/prefer-tcp-setting.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant