mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Remove CLI flags; always use env vars
Provides a consistent public-facing API for Docker and direct usage.
This commit is contained in:
parent
c145bec508
commit
1f5d52fef9
14
README.md
14
README.md
@ -12,7 +12,7 @@ Proxy version to MSC API specification:
|
||||
- Version 0.1.x: [2022/04/01](https://github.com/matrix-org/matrix-spec-proposals/blob/615e8f5a7bfe4da813bc2db661ed0bd00bccac20/proposals/3575-sync.md)
|
||||
- First release
|
||||
- Version 0.2.x: [2022/06/09](https://github.com/matrix-org/matrix-spec-proposals/blob/3b2b3d547b41e4aeebbde2ad6e89606dd684a86c/proposals/3575-sync.md)
|
||||
- Reworked where lists and ops are situated in the response JSON. Added new filters like `room_name_like`. Added `slow_get_all_rooms`.
|
||||
- Reworked where lists and ops are situated in the response JSON. Added new filters like `room_name_like`. Added `slow_get_all_rooms`. Standardised on env vars for configuring the proxy.
|
||||
|
||||
## Usage
|
||||
|
||||
@ -21,7 +21,7 @@ Requires Postgres 13+.
|
||||
```bash
|
||||
$ createdb syncv3
|
||||
$ go build ./cmd/syncv3
|
||||
$ ./syncv3 -server "https://matrix-client.matrix.org" -db "user=$(whoami) dbname=syncv3 sslmode=disable"
|
||||
$ SYNCV3_SERVER="https://matrix-client.matrix.org" SYNCV3_DB="user=$(whoami) dbname=syncv3 sslmode=disable" SYNCV3_BINDADDR=0.0.0.0:8008 ./syncv3
|
||||
```
|
||||
|
||||
Then visit http://localhost:8008/client/ (with trailing slash) and paste in the `access_token` for any account on `-server`.
|
||||
@ -34,16 +34,6 @@ INF Poller: v2 poll loop started ip=::1 since= user_id=@kegan:matrix.org
|
||||
|
||||
Wait for the first initial v2 sync to be processed (this can take minutes!) and then v3 APIs will be responsive.
|
||||
|
||||
### Docker
|
||||
|
||||
When running using the official docker container, these environment variables can be set:
|
||||
|
||||
```
|
||||
SYNCV3_SERVER equivalent of -server
|
||||
SYNCV3_DB equivalent of -db
|
||||
SYNCV3_BINDADDR equivalent of -port, default: 0.0.0.0:8008
|
||||
```
|
||||
|
||||
### How can I help?
|
||||
|
||||
At present, the best way to help would be to run a local v3 server pointed at a busy account and just leave it and a client running in the background. Look at it occasionally and submit any issues you notice. You can save console logs by right-clicking -> Save As.
|
||||
|
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
@ -17,17 +16,34 @@ var GitCommit string
|
||||
|
||||
const version = "0.2.0rc2"
|
||||
|
||||
var (
|
||||
flagDestinationServer = flag.String("server", "", "The destination v2 matrix server")
|
||||
flagBindAddr = flag.String("port", ":8008", "Bind address")
|
||||
flagPostgres = flag.String("db", "user=postgres dbname=syncv3 sslmode=disable", "Postgres DB connection string (see lib/pq docs)")
|
||||
const (
|
||||
EnvServer = "SYNCV3_SERVER"
|
||||
EnvDB = "SYNCV3_DB"
|
||||
EnvBindAddr = "SYNCV3_BINDADDR"
|
||||
)
|
||||
|
||||
var helpMsg = fmt.Sprintf(`
|
||||
Environment var
|
||||
%s Required. The destination homeserver to talk to (CS API HTTPS URL) e.g 'https://matrix-client.matrix.org'
|
||||
%s Required. The postgres connection string: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
||||
%s (Default: 0.0.0.0:8008) The interface and port to listen on.
|
||||
`, EnvServer, EnvDB, EnvBindAddr)
|
||||
|
||||
func defaulting(in, dft string) string {
|
||||
if in == "" {
|
||||
return dft
|
||||
}
|
||||
return in
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Sync v3 [%s] (%s)\n", version, GitCommit)
|
||||
flag.Parse()
|
||||
if *flagDestinationServer == "" {
|
||||
flag.Usage()
|
||||
flagDestinationServer := os.Getenv(EnvServer)
|
||||
flagPostgres := os.Getenv(EnvDB)
|
||||
flagBindAddr := defaulting(os.Getenv(EnvBindAddr), "0.0.0.0:8008")
|
||||
if flagDestinationServer == "" || flagPostgres == "" {
|
||||
fmt.Print(helpMsg)
|
||||
fmt.Printf("\n%s and %s must be set\n", EnvServer, EnvBindAddr)
|
||||
os.Exit(1)
|
||||
}
|
||||
// pprof
|
||||
@ -40,10 +56,10 @@ func main() {
|
||||
Client: &http.Client{
|
||||
Timeout: 5 * time.Minute,
|
||||
},
|
||||
DestinationServer: *flagDestinationServer,
|
||||
}, *flagPostgres, os.Getenv("SYNCV3_DEBUG") == "1")
|
||||
DestinationServer: flagDestinationServer,
|
||||
}, flagPostgres, os.Getenv("SYNCV3_DEBUG") == "1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
syncv3.RunSyncV3Server(h, *flagBindAddr, *flagDestinationServer)
|
||||
syncv3.RunSyncV3Server(h, flagBindAddr, flagDestinationServer)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user