- Go 94.3%
- Shell 4.1%
- Dockerfile 1.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
CI / lint (pull_request) Successful in 1m47s
CI / test (pull_request) Successful in 6m15s
CI / CI (pull_request) Successful in 15s
CI / lint (push) Successful in 57s
Release / Release (push) Successful in 20s
CI / test (push) Successful in 2m7s
CI / CI (push) Successful in 15s
|
||
| .forgejo/workflows | ||
| cmd/xbrowsersyncgo | ||
| internal | ||
| scripts | ||
| .dockerignore | ||
| .gitignore | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| mise.toml | ||
| README.md | ||
| releasaurus.toml | ||
| renovate.json | ||
xBrowserSyncGo
xBrowserSyncGo is a bookmark sync server for the xBrowserSync browser extensions. It uses the wire format (the exact requests and replies) of the xBrowserSync API 1.1.13, so the stock extensions work with it unchanged. It stores data in PostgreSQL or SQLite and ships as one static binary. It never sees your bookmarks, because the extension encrypts them before upload.
Run it
docker run -p 8080:8080 -v xbrowsersyncgo:/data git.dcunha.io/exikle/xbrowsersyncgo:0.2.0
Then set the service URL of the extension to the address of the server.
The image runs as uid 65532 and works with a read-only root filesystem.
The SQLite database is at /data/xbrowsersyncgo.db, unless XBROWSERSYNCGO_DATABASE_URL sets a different location.
Configuration
You set every option with an environment variable. xbrowsersyncgo help prints the full list.
| Variable | Default | Meaning |
|---|---|---|
XBROWSERSYNCGO_DATABASE_URL |
sqlite:///data/xbrowsersyncgo.db |
postgres://… or sqlite://… (a bare path also means SQLite) |
XBROWSERSYNCGO_HTTP_PORT |
8080 |
The port of the API. It replaces XBROWSERSYNCGO_LISTEN (0.2.0). The server now stops at startup if XBROWSERSYNCGO_LISTEN is set |
XBROWSERSYNCGO_METRICS_ENABLED |
true |
Serve Prometheus metrics on their own port |
XBROWSERSYNCGO_METRICS_PORT |
8081 |
The metrics port: GET /metrics |
XBROWSERSYNCGO_SHUTDOWN_TIMEOUT |
15s |
How long a stop waits for requests that are in progress |
XBROWSERSYNCGO_ALLOW_NEW_SYNCS |
true |
Accept new syncs. Set false after everyone has signed up |
XBROWSERSYNCGO_MAX_SYNCS |
5242 |
The maximum number of stored syncs. 0 means no maximum |
XBROWSERSYNCGO_MAX_SYNC_SIZE |
512000 |
The size limit of a request body, in bytes |
XBROWSERSYNCGO_DAILY_NEW_SYNCS_LIMIT |
3 |
New syncs for each client IP each day. 0 turns it off |
XBROWSERSYNCGO_TRUST_PROXY |
false |
Take the client IP from the last X-Forwarded-For entry. Set it only behind exactly one reverse proxy |
XBROWSERSYNCGO_THROTTLE_REQUESTS |
1000 |
Requests for each IP in each window. 0 turns it off |
XBROWSERSYNCGO_THROTTLE_WINDOW |
5m |
The length of the throttle window |
XBROWSERSYNCGO_SYNC_EXPIRY |
0 |
Delete syncs that nobody read for this time, for example 504h. 0 keeps them forever |
XBROWSERSYNCGO_ONLINE |
true |
false answers sync requests with 503 |
XBROWSERSYNCGO_MESSAGE / XBROWSERSYNCGO_LOCATION |
empty | /info shows these values |
XBROWSERSYNCGO_LOG_LEVEL |
info |
debug, info, warn or error |
/healthz answers {"status":"ok"} when the process is up.
/readyz gives the same answer, and it also checks the database. It answers 503 when the database is unreachable.
The server writes logs as JSON lines on stdout.
xbrowsersyncgo --version prints xbrowsersyncgo <version>.
Moving from xBrowserSync
Export the bookmarks collection as Extended JSON, with one document on each line. Then give the file to xbrowsersyncgo import.
The import copies IDs, blobs, and timestamps exactly.
The sync ID is the salt for the encryption key of the extension, so the browsers keep working with no change.
mongosh "$MONGO_URL" --quiet --eval \
'db.getSiblingDB("xbrowsersync").bookmarks.find().forEach(d => print(EJSON.stringify(d)))' \
> syncs.jsonl
xbrowsersyncgo import syncs.jsonl
xbrowsersyncgo import - reads standard input.
You can run the import again safely. If a sync on xBrowserSyncGo is newer than the export, the import skips it. An old export cannot undo pushes that happened since.
The import stamps each imported sync as just read. Then XBROWSERSYNCGO_SYNC_EXPIRY cannot delete a sync before a browser reaches it.
The extension switches sync off when it gets a 429 response.
If many clients share one proxy IP, set XBROWSERSYNCGO_TRUST_PROXY or XBROWSERSYNCGO_THROTTLE_REQUESTS=0.
Where it differs from xBrowserSync 1.1.13
Clients cannot see these differences. They are fixes on the server:
- The server checks and writes a conflicting
PUTin one statement, so two writers that race cannot both win. A write also always moveslastUpdatedforward, even within the same millisecond. - The daily new-sync limit resets each day. Upstream resets it only if the operator adds a MongoDB TTL index by hand.
- Expiry of stale syncs is a setting (
XBROWSERSYNCGO_SYNC_EXPIRY). Upstream needs a manual index. - With
XBROWSERSYNCGO_TRUST_PROXY, the client IP is the lastX-Forwarded-Forhop. Upstream uses the first hop, which a caller can forge. - Error responses also carry the CORS header, so the browser sees the real status.
/favicon.icoanswers instead of hanging, and health endpoints exist.GET /is a 404, not the docs page of upstream. There is no path-prefix setting.- Malformed JSON still returns 500
UnspecifiedException, as upstream does.
Develop
mise run ci
This command runs the format check, go vet, the layer rules, and the tests, as CI runs them.
The database tests run against SQLite. They also run against a PostgreSQL that the tests start themselves. You need no setup, but the first run downloads PostgreSQL.
Releases
Releasaurus opens a release PR from the commit titles. When you merge it, it tags vX.Y.Z.
Exikle/containers (apps/xbrowsersyncgo) builds and signs the image. It pushes the image to git.dcunha.io/exikle/xbrowsersyncgo and registry.dcunha.io/exikle/xbrowsersyncgo.
Renovate picks up the new tag there.
Licence
GPL-3.0. The wire format and the behavior follow xbrowsersync/api (GPL-3.0).