Migrate to ssbc urls (#336)

* fix: ssbc urls

Closes https://github.com/ssbc/go-ssb-room/issues/332

* fix: go-ssb-refs API changes

* test: go-ssb-refs API changes

Co-authored-by: decentral1se <cellarspoon@riseup.net>
Co-authored-by: André Staltz <andre@staltz.com>
This commit is contained in:
decentral1se 2022-11-07 10:18:13 +01:00 committed by GitHub
parent e3afd943c9
commit 00a1452cfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
143 changed files with 1004 additions and 773 deletions

View File

@ -5,12 +5,12 @@ SPDX-License-Identifier: CC0-1.0
-->
# Go-SSB Room
[![REUSE status](https://api.reuse.software/badge/github.com/ssb-ngi-pointer/go-ssb-room)](https://api.reuse.software/info/github.com/ssb-ngi-pointer/go-ssb-room)
[![REUSE status](https://api.reuse.software/badge/github.com/ssbc/go-ssb-room)](https://api.reuse.software/info/github.com/ssbc/go-ssb-room)
This repository implements the [Room (v1+v2) server spec](https://github.com/ssbc/rooms2), in Go.
It includes:
* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/cryptoscope/secretstream)
* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/ssbc/go-secretstream)
* muxrpc handlers for tunneling connections
* a fully embedded HTTP server & HTML frontend, for administering the room
@ -45,4 +45,3 @@ For an in-depth codebase walkthrough, see the [development.md](./docs/developmen
## License
MIT

View File

@ -19,10 +19,10 @@ import (
_ "github.com/mattn/go-sqlite3"
"golang.org/x/crypto/ssh/terminal"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
)
func main() {
@ -90,7 +90,7 @@ func main() {
}
ctx := context.Background()
mid, err := db.Members.Add(ctx, *pubKey, role)
mid, err := db.Members.Add(ctx, pubKey, role)
check(err)
err = db.AuthFallback.SetPassword(ctx, mid, string(bytePassword))

View File

@ -26,21 +26,21 @@ import (
_ "net/http/pprof"
_ "github.com/mattn/go-sqlite3"
"github.com/ssbc/go-muxrpc/v2/debug"
"github.com/throttled/throttled/v2"
"github.com/throttled/throttled/v2/store/memstore"
"github.com/unrolled/secure"
"go.cryptoscope.co/muxrpc/v2/debug"
kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
mksrv "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
"github.com/ssbc/go-ssb-room/v2/roomsrv"
mksrv "github.com/ssbc/go-ssb-room/v2/roomsrv"
"github.com/ssbc/go-ssb-room/v2/web/handlers"
)
// Version and Build are set by ldflags
@ -375,7 +375,7 @@ func runroomsrv() error {
// all init was successfull
level.Info(log).Log(
"event", "serving",
"ID", roomsrv.Whoami().Ref(),
"ID", roomsrv.Whoami().String(),
"shsmuxaddr", listenAddrShsMux,
"httpaddr", listenAddrHTTP,
"version", version, "commit", commit,

View File

@ -9,9 +9,9 @@ SPDX-License-Identifier: CC0-1.0
## Invite flow
This implementation of Rooms 2.0 is compliant with the [Rooms 2.0
specification](https://github.com/ssb-ngi-pointer/rooms2), but we add a few additional features
specification](https://github.com/ssbc/rooms2), but we add a few additional features
and pages in order to improve user experience when their SSB app does not support [SSB
URIs](https://github.com/ssb-ngi-pointer/ssb-uri-spec).
URIs](https://github.com/ssbc/ssb-uri-spec).
A summary can be seen in the following chart:
@ -25,7 +25,7 @@ in a form.
## Sign-in flow
This implementation is compliant with [SSB HTTP
Authentication](https://github.com/ssb-ngi-pointer/ssb-http-auth-spec), but we add a few
Authentication](https://github.com/ssbc/ssb-http-auth-spec), but we add a few
additional features and pages in order to improve user experience. For instance, besides
conventional SSB HTTP Auth, we also render a QR code to sign-in with a remote SSB app (an SSB
identity not on the device that has the browser open). We also support sign-in with
@ -33,4 +33,4 @@ username/password, what we call "fallback authentication".
A summary can be seen in the following chart:
![Chart](./images/login-chart.png)
![Chart](./images/login-chart.png)

View File

@ -5,15 +5,16 @@ SPDX-License-Identifier: CC0-1.0
-->
# Getting Started
There are two paths to starting your own room: creating a build from source, or downloading one
of the premade releases.
## Premade builds
See the [releases page](https://github.com/ssb-ngi-pointer/go-ssb-room/releases) for packaged linux releases.
See the [releases page](https://github.com/ssbc/go-ssb-room/releases) for packaged linux releases.
We currently only distributed pre-packaged releases for Debian-compatible distributions.
See [Issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) for the details.
See [Issue #79](https://github.com/ssbc/go-ssb-room/issues/79) for the details.
If this doesn't work for you, read the "Creating a build" section below.
After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special attention to the
@ -22,7 +23,7 @@ After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special att
## Creating a build
* [Download Go](https://golang.org/doc/install) & [set up your Go environment](https://golang.org/doc/install#install). You will need at least Go v1.16.
* Download the repository `git clone git@github.com:ssb-ngi-pointer/go-ssb-room.git && cd go-ssb-room`
* Download the repository `git clone git@github.com:ssbc/go-ssb-room.git && cd go-ssb-room`
* [Follow the development instructions](./development.md)
* You should now have a working go-ssb-room binary! Read the HTTP Hosting section below and admin
user sections below, for more instructions on the last mile.
@ -32,7 +33,7 @@ After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special att
This project includes a docker-compose.yml file as well as a Docker file. Using
it should be fairly straight forward.
Start off by making a copy of `.env_example` called `.env` and insert your
Start off by making a copy of `.env_example` called `.env` and insert your
website domain there. With that done execute
```
@ -78,7 +79,7 @@ Two bits of rationale:
1. People usually want to have more than one site on their server. Put differently, we could
have [LetsEncrypt](https://letsencrypt.org/) inside the go-ssb-room server but it would have to
listen on port :443—blocking the use of other domains on the same IP.
listen on port :443—blocking the use of other domains on the same IP.
2. Listening on :443 can be pretty annoying (you might need root privileges or similar capabilities).
go-ssb-room needs three headers to function properly, which need to be forwarded by the
@ -111,7 +112,7 @@ is often added automatically by your provider.
When the process is complete with `certbot`, pay attention to where the certificate has been placed
in the filesystem. If it's at `/etc/letsencrypt/live/hermies.club`, it's correct, otherwise you may
need to rename it e.g. `hermies.club-0001` to `hermies.club`.
need to rename it e.g. `hermies.club-0001` to `hermies.club`.
The example nginx configuration uses prebuilt Diffie-Hellman parameters. You can generate these
with the following command:
@ -184,5 +185,4 @@ Or if you installed go-ssb-room using the Debian package:
sudo ./insert-user -repo "/var/lib/go-ssb-room" "@Bp5Z5TQKv6E/Y+QZn/3LiDWMPi63EP8MHsXZ4tiIb2w=.ed25519"
```
It will ask you to create a password to access the web-front-end. You can now login in the web-front-end using these credentials
It will ask you to create a password to access the web-front-end. You can now login in the web-front-end using these credentials.

View File

@ -69,8 +69,8 @@ go generate ./...
cd cmd/server && go build && ./server -htts-domain=my.room.example
```
## Tooling
### Mocks
[`counterfeiter`](https://github.com/maxbrunsfeld/counterfeiter) enables generating mocks for defined interfaces. To update the mocks, run `go generate` in package roomdb.
@ -126,7 +126,7 @@ See the [testing.md](./testing.md) for a thorough walkthorugh of the different t
## Release packaging
Because of [issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows:
Because of [issue #79](https://github.com/ssbc/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows:
1) Install a recent debian stable version onto a dedicated machine or VM for instance (docker might also be possible).
2) Install [Go](https://golang.org/doc/install).

View File

@ -16,12 +16,12 @@ It will store it's files (roomdb and cookie secrets) under /var/lib/go-ssb-room.
This is also where you would put custom translations.
For more configuration background see /usr/share/go-ssb-room/README.md
or visit the code repo at https://github.com/ssb-ngi-pointer/go-ssb-room/tree/master/docs
or visit the code repo at https://github.com/ssbc/go-ssb-room/tree/master/docs
Like outlined in that document, we highly encourage using nginx with certbot for TLS termination.
We also supply an example config for this. You can find it under /usr/share/go-ssb-room/nginx-example.conf
> Important
> Important
Before you start using room server via the systemd service, you need to at least change the https domain in the systemd service.

View File

@ -37,21 +37,25 @@ The frontend tests—tests that check for the presence of various elements on se
the module [`goquery`](https://github.com/PuerkitoBio/goquery) for querying the returned HTML.
## Snippets
#### Print the raw html of the corresponding page
```
html, _ := ts.Client.GetHTML(url)
fmt.Println(html.Html())
html, _ := ts.Client.GetHTML(url)
fmt.Println(html.Html())
```
#### Find and print the `title` element of a page
```
html, _ := ts.Client.GetHTML(url)
title := html.Find("title")
// print the title string
fmt.Println(title.Text())
html, _ := ts.Client.GetHTML(url)
title := html.Find("title")
// print the title string
fmt.Println(title.Text())
```
## Filling the mockdb
`go-ssb-room` uses database mocks for performing tests against the backend database logic. This
means prefilling a route with the data you expect to be returned when the route is queried.
This type of testing is an alternative to using an entire pre-filled sqlite database of test
@ -59,7 +63,7 @@ data.
As such, there is no command you run first to generate your fake database, but
functions you have to call in a kind of pre-test setup, inside each testing
block you are authoring.
block you are authoring.
> [counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) generates a bunch of methods for each function, so you have
> XXXXReturns, XXXCallCount XXXArgsForCall(i) etc
@ -72,6 +76,7 @@ That is, for a function `GetUID` there is a corresponding mock-filling function
The following examples show more concretely what mocking the data looks like.
**Having the List() function return a static list of three items:**
```go
// go-ssb-room/web/handlers/admin/allow_list_test.go:113
lst := roomdb.ListEntries{
@ -80,10 +85,10 @@ lst := roomdb.ListEntries{
{ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}},
}
ts.MembersDB.ListReturns(lst, nil)
```
**Checking how often RemoveID was called and with what arguments:**
```go
// go-ssb-room/web/handlers/admin/allow_list_test.go:210
a.Equal(1, ts.MembersDB.RemoveIDCallCount())
@ -91,8 +96,8 @@ ts.MembersDB.ListReturns(lst, nil)
a.EqualValues(666, theID)
```
## Example test
```go
package handlers
@ -144,4 +149,3 @@ cd muxrpc/test/nodejs
npm ci
go test
```

17
go.mod
View File

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: Unlicense
module github.com/ssb-ngi-pointer/go-ssb-room/v2
module github.com/ssbc/go-ssb-room/v2
go 1.16
@ -20,30 +20,29 @@ require (
github.com/mattevans/pwned-passwords v0.3.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
github.com/mileusna/useragent v1.0.2 // indirect
github.com/mileusna/useragent v1.0.2
github.com/nicksnyder/go-i18n/v2 v2.1.2
github.com/pkg/errors v0.9.1
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
github.com/russross/blackfriday/v2 v2.1.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/stretchr/testify v1.7.0
github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f
github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d
github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe
github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de
github.com/stretchr/testify v1.8.0
github.com/throttled/throttled/v2 v2.7.1
github.com/unrolled/secure v1.0.8
github.com/vcraescu/go-paginator/v2 v2.0.0
github.com/volatiletech/sqlboiler/v4 v4.5.0
github.com/volatiletech/strmangle v0.0.1
go.cryptoscope.co/muxrpc/v2 v2.0.6
go.cryptoscope.co/netwrap v0.1.1
go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810
go.cryptoscope.co/secretstream v1.2.8
go.mindeco.de v1.12.0
go.mindeco.de/ssb-refs v0.2.0
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.5
golang.org/x/tools v0.1.1
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
exclude go.cryptoscope.co/ssb v0.0.0-20201207161753-31d0f24b7a79

33
go.sum
View File

@ -1,4 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM=
@ -223,14 +225,26 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw=
github.com/ssbc/go-luigi v0.3.7-0.20221019204020-324065b9a7c6 h1:4Mhg4qHaiX56eXNND9gGJAf0xzoRQQtfFFhv6wcIOIU=
github.com/ssbc/go-luigi v0.3.7-0.20221019204020-324065b9a7c6/go.mod h1:tBPMBysJeh1u3vStvrWe5w3YBC4fnbnGsLk5ML4D6do=
github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f h1:eIzrej3VH9sYd13X8zVVzlsDRh0uCjYCbdsLcsZqrnc=
github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221020091224-b09bdf60812f/go.mod h1:CFvV9kCI3SmJM38pf1NCXWrS7UVgTYXJdKs+Q9hkJIw=
github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d h1:UnYPPekKU0mHzMMOSuI6117Djq9xni60c/IzzUYxgCI=
github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d/go.mod h1:tsE1qeqkc8kvf1psPNdJ5s8O+/jE1WlKwsEETb2VZqs=
github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe h1:naU+qPze58a1vOf4J0Glglc1GoTvRkuCv3+sWziocf4=
github.com/ssbc/go-secretstream v1.2.11-0.20221019175226-fa042d4912fe/go.mod h1:imXhXNa5OfEL+qrGtOs6NZ9zJe6L3P+ZwFVC2mIgH0E=
github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de h1:av0v73MeB+HASXfbtr3+r1dWD1DrYlGEIMCdVKV09Ag=
github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de/go.mod h1:TRIqkOhZERfVzB+NoO3eUoru0ceQAsDnfZricPd1sUM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/throttled/throttled/v2 v2.7.1 h1:FnBysDX4Sok55bvfDMI0l2Y71V1vM2wi7O79OW7fNtw=
github.com/throttled/throttled/v2 v2.7.1/go.mod h1:fuOeyK9fmnA+LQnsBbfT/mmPHjmkdogRBQxaD8YsgZ8=
@ -258,22 +272,11 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.cryptoscope.co/luigi v0.3.5 h1:6rrNciUqbuwphT7hIjFd8eVRP3IatDX6HxdHs/Qo+Zw=
go.cryptoscope.co/luigi v0.3.5/go.mod h1:vJZOaxKWLWTC5oRWBOGVVW9X+o6nikLZSYUF9bvPd2w=
go.cryptoscope.co/muxrpc/v2 v2.0.6 h1:AzzrPQnx9sqUlqczJMOes9sQqYKvINz7Ie1ZJIdgy/Y=
go.cryptoscope.co/muxrpc/v2 v2.0.6/go.mod h1:og3Wr0CWnJBVp3aiRa9MmmTUQh901wWNjI96+o3NZag=
go.cryptoscope.co/netwrap v0.1.0/go.mod h1:7zcYswCa4CT+ct54e9uH9+IIbYYETEMHKDNpzl8Ukew=
go.cryptoscope.co/netwrap v0.1.1 h1:JLzzGKEvrUrkKzu3iM0DhpHmt+L/gYqmpcf1lJMUyFs=
go.cryptoscope.co/netwrap v0.1.1/go.mod h1:7zcYswCa4CT+ct54e9uH9+IIbYYETEMHKDNpzl8Ukew=
go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810 h1:Sa7Q5X/La6bVTNT8Vcnt9GIGuOFOEFmjY3UNiwPErQk=
go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810/go.mod h1:SJ9qQwHw1S7F2RsE9Ez9RmBhGpIdAphG1xGnI0rdKUI=
go.cryptoscope.co/secretstream v1.2.8 h1:M/2EYQfj2A97oe44jGWFDMxgu9NsRnjRSTnz1WPWTnA=
go.cryptoscope.co/secretstream v1.2.8/go.mod h1:OjHU/Io8LYyBxv1ehWohsFyyz4fVcKGozAzLoj6il50=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.mindeco.de v1.12.0 h1:K5FHILjJlD/U1HJMs8Y9ZLwdfG4dPEsxw+e+eqg1wKc=
go.mindeco.de v1.12.0/go.mod h1:dZty08izAk/rSX8wSLen4gMR4WDPYmA6vUTE0QtepHA=
go.mindeco.de/ssb-refs v0.2.0 h1:KL+W2gq8ZeUzoFsPlKL0G/oThYeJKscqq8V3D0AgMoc=
go.mindeco.de/ssb-refs v0.2.0/go.mod h1:Ysyvb0aGeR721Nvu5V7mCJtkQP1fwf0qEBLA4FXHXXk=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
@ -376,8 +379,8 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/sqlite v1.1.3 h1:BYfdVuZB5He/u9dt4qDpZqiqDJ6KhPqs5QUqsr/Eeuc=
gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c=
gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=

View File

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
// Package aliases implements the validation and signing features of https://ssb-ngi-pointer.github.io/rooms2/#alias
// Package aliases implements the validation and signing features of https://ssbc.github.io/rooms2/#alias
package aliases
import (
@ -10,7 +10,7 @@ import (
"golang.org/x/crypto/ed25519"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
)
// Registration ties an alias to the ID of the user and the RoomID it should be registered on
@ -33,9 +33,9 @@ func (r Registration) Sign(privKey ed25519.PrivateKey) Confirmation {
func (r Registration) createRegistrationMessage() []byte {
var message bytes.Buffer
message.WriteString("=room-alias-registration:")
message.WriteString(r.RoomID.Ref())
message.WriteString(r.RoomID.String())
message.WriteString(":")
message.WriteString(r.UserID.Ref())
message.WriteString(r.UserID.String())
message.WriteString(":")
message.WriteString(r.Alias)
return message.Bytes()

View File

@ -8,18 +8,18 @@ import (
"bytes"
"testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs"
)
func TestConfirmation(t *testing.T) {
r := require.New(t)
// this is our room, it's not a valid feed but thats fine for this test
roomID := refs.FeedRef{
ID: bytes.Repeat([]byte("test"), 8),
Algo: "test",
roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("test"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
// to make the test deterministic, decided by fair dice roll.
@ -36,7 +36,7 @@ func TestConfirmation(t *testing.T) {
// internal function to create the registration string
msg := valid.createRegistrationMessage()
want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.test:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation"
want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.ed25519:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation"
r.Equal(want, string(msg))
// create the signed confirmation
@ -46,9 +46,9 @@ func TestConfirmation(t *testing.T) {
r.True(yes, "should be valid for this room and feed")
// make up another id for the invalid test(s)
otherID := refs.FeedRef{
ID: bytes.Repeat([]byte("nope"), 8),
Algo: "test",
otherID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("nope"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
confirmation.RoomID = otherID

View File

@ -5,7 +5,7 @@
package aliases
// IsValid decides whether an alias is okay for use or not.
// The room spec defines it as _labels valid under RFC 1035_ ( https://ssb-ngi-pointer.github.io/rooms2/#alias-string )
// The room spec defines it as _labels valid under RFC 1035_ ( https://ssbc.github.io/rooms2/#alias-string )
// but that can be mostly any string since DNS is a 8bit binary protocol,
// as long as it's shorter then 63 charachters.
//

View File

@ -8,8 +8,8 @@ import (
"io"
"sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
)
type AttendantsEmitter interface {

View File

@ -4,4 +4,4 @@
// Package broadcasts implements custom typed one-to-n facilities for broadcasting messages/calls to multiple subscribers.
// They loosely follow from luigi.Broadcasts but using concrete types instead of empty interfaces.
package broadcasts
package broadcasts

View File

@ -8,7 +8,7 @@ import (
"io"
"sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
)
type EndpointsEmitter interface {

View File

@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: MIT
//go:build tools
// +build tools
package devtools

View File

@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: MIT
//go:build tools
// +build tools
package devtools

View File

@ -14,9 +14,9 @@ import (
"path/filepath"
"strings"
"github.com/ssbc/go-secretstream/secrethandshake"
refs "github.com/ssbc/go-ssb-refs"
"go.cryptoscope.co/nocomment"
"go.cryptoscope.co/secretstream/secrethandshake"
refs "go.mindeco.de/ssb-refs"
)
var SecretPerms = os.FileMode(0600)
@ -38,8 +38,8 @@ type ssbSecret struct {
// IsValidFeedFormat checks if the passed FeedRef is for one of the two supported formats,
// legacy/crapp or GabbyGrove.
func IsValidFeedFormat(r refs.FeedRef) error {
if r.Algo != refs.RefAlgoFeedSSB1 && r.Algo != refs.RefAlgoFeedGabby {
return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo)
if r.Algo() != refs.RefAlgoFeedSSB1 && r.Algo() != refs.RefAlgoFeedGabby {
return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo())
}
return nil
}
@ -53,11 +53,13 @@ func NewKeyPair(r io.Reader) (*KeyPair, error) {
return nil, fmt.Errorf("ssb: error building key pair: %w", err)
}
feed, err := refs.NewFeedRefFromBytes(kp.Public[:], refs.RefAlgoFeedSSB1)
if err != nil {
return nil, fmt.Errorf("ssb: error building key pair: %w", err)
}
keyPair := KeyPair{
Feed: refs.FeedRef{
ID: kp.Public[:],
Algo: refs.RefAlgoFeedSSB1,
},
Feed: feed,
Pair: *kp,
}

View File

@ -9,7 +9,7 @@ import (
"io"
"sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
)
type Closer struct {

View File

@ -8,7 +8,7 @@ import (
"net"
"sync"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
)
type Authorizer interface {

View File

@ -11,8 +11,8 @@ import (
"sync"
"time"
"go.cryptoscope.co/netwrap"
"go.cryptoscope.co/secretstream"
"github.com/ssbc/go-netwrap"
"github.com/ssbc/go-secretstream"
)
type connEntry struct {

View File

@ -15,10 +15,10 @@ import (
"net/url"
"time"
"go.cryptoscope.co/muxrpc/v2"
"go.cryptoscope.co/netwrap"
"go.cryptoscope.co/secretstream"
refs "go.mindeco.de/ssb-refs"
"github.com/ssbc/go-muxrpc/v2"
"github.com/ssbc/go-netwrap"
"github.com/ssbc/go-secretstream"
refs "github.com/ssbc/go-ssb-refs"
)
// ServerEndpointDetails encapsulates the endpoint information.
@ -131,10 +131,10 @@ type ConnTracker interface {
}
// GetFeedRefFromAddr uses netwrap to get the secretstream address and then uses ParseFeedRef
func GetFeedRefFromAddr(addr net.Addr) (*refs.FeedRef, error) {
func GetFeedRefFromAddr(addr net.Addr) (refs.FeedRef, error) {
addr = netwrap.GetAddr(addr, secretstream.NetworkString)
if addr == nil {
return nil, errors.New("no shs-bs address found")
return refs.FeedRef{}, errors.New("no shs-bs address found")
}
ssAddr := addr.(secretstream.Addr)
return refs.ParseFeedRef(ssAddr.String())

View File

@ -11,11 +11,11 @@ import (
"os"
"testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"go.mindeco.de/log"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
"github.com/stretchr/testify/require"
)

View File

@ -8,9 +8,9 @@ package mocked
import (
"sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
muxrpc "go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs"
muxrpc "github.com/ssbc/go-muxrpc/v2"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/network"
)
type FakeEndpoints struct {

View File

@ -10,8 +10,8 @@ import (
"strings"
"testing"
refs "github.com/ssbc/go-ssb-refs"
"github.com/stretchr/testify/assert"
refs "go.mindeco.de/ssb-refs"
)
func TestMultiserverAddress(t *testing.T) {
@ -21,10 +21,11 @@ func TestMultiserverAddress(t *testing.T) {
sed.Domain = "the.ho.st"
sed.ListenAddressMUXRPC = ":8008"
sed.RoomID = refs.FeedRef{
ID: bytes.Repeat([]byte("ohai"), 8),
Algo: "doesnt-matter", // not part of msaddr v1
roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("ohai"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
sed.RoomID = roomID
gotMultiAddr := sed.MultiserverAddress()

View File

@ -14,14 +14,14 @@ import (
"strings"
"sync"
"go.cryptoscope.co/muxrpc/v2"
"go.cryptoscope.co/netwrap"
"go.cryptoscope.co/secretstream"
"github.com/ssbc/go-muxrpc/v2"
"github.com/ssbc/go-netwrap"
"github.com/ssbc/go-secretstream"
"go.mindeco.de/log"
"go.mindeco.de/log/level"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
)
// DefaultPort is the default listening port for ScuttleButt.
@ -128,7 +128,7 @@ func (n *node) GetEndpointFor(ref refs.FeedRef) (muxrpc.Endpoint, bool) {
n.remotesLock.Lock()
defer n.remotesLock.Unlock()
edp, has := n.remotes[ref.Ref()]
edp, has := n.remotes[ref.String()]
return edp, has
}
@ -147,7 +147,7 @@ func (n *node) GetAllEndpoints() []EndpointStat {
continue
}
stats = append(stats, EndpointStat{
ID: id,
ID: &id,
Addr: remote,
Since: durr,
Endpoint: edp,
@ -164,7 +164,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) {
if err != nil {
panic(err)
}
// ref := r.Ref()
// ref := r.String()
// if oldEdp, has := n.remotes[ref]; has {
// n.log.Log("remotes", "previous active", "ref", ref)
// c := client.FromEndpoint(oldEdp)
@ -175,7 +175,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) {
// }
// }
// replace with new
n.remotes[r.Ref()] = edp
n.remotes[r.String()] = edp
}
// TODO: merge with conntracker
@ -186,7 +186,7 @@ func (n *node) removeRemote(edp muxrpc.Endpoint) {
if err != nil {
panic(err)
}
delete(n.remotes, r.Ref())
delete(n.remotes, r.String())
}
func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer bool, hws ...muxrpc.HandlerWrapper) {
@ -205,7 +205,7 @@ func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer
level.Error(n.log).Log("conn", "not shs authorized", "err", err)
return
}
rLogger := log.With(n.log, "peer", remoteRef.ShortRef())
rLogger := log.With(n.log, "peer", remoteRef.ShortSigil())
ok, ctx := n.connTracker.OnAccept(ctx, conn)
if !ok {

View File

@ -13,7 +13,7 @@ import (
"time"
"github.com/gorilla/websocket"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level"
)

View File

@ -8,8 +8,8 @@ import (
"errors"
"net"
"go.cryptoscope.co/netwrap"
"go.cryptoscope.co/secretstream"
"github.com/ssbc/go-netwrap"
"github.com/ssbc/go-secretstream"
)
// SpoofRemoteAddress wraps the connection with the passed reference

View File

@ -8,8 +8,8 @@ import (
"net"
"testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/stretchr/testify/require"
)
@ -28,7 +28,7 @@ func TestSpoof(t *testing.T) {
ref, err := network.GetFeedRefFromAddr(wrapped.RemoteAddr())
r.NoError(err)
r.True(ref.Equal(&kp.Feed))
r.True(ref.Equal(kp.Feed))
wc.Close()
rc.Close()

View File

@ -11,8 +11,8 @@ import (
"os"
"path/filepath"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
)
func DefaultKeyPair(r Interface) (*keys.KeyPair, error) {
@ -29,7 +29,7 @@ func DefaultKeyPair(r Interface) (*keys.KeyPair, error) {
if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
return nil, fmt.Errorf("repo: error saving new identity file: %w", err)
}
log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath)
log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath)
}
return keyPair, nil
}
@ -53,7 +53,7 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair,
return nil, err
}
}
if algo != refs.RefAlgoFeedSSB1 && algo != refs.RefAlgoFeedGabby { // enums would be nice
if algo != string(refs.RefAlgoFeedSSB1) && algo != string(refs.RefAlgoFeedGabby) { // enums would be nice
return nil, fmt.Errorf("invalid feed refrence algo")
}
if _, err := keys.LoadKeyPair(secPath); err == nil {
@ -63,11 +63,10 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair,
if err != nil {
return nil, fmt.Errorf("repo: no keypair but couldn't create one either: %w", err)
}
keyPair.Feed.Algo = algo
if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
return nil, fmt.Errorf("repo: error saving new identity file: %w", err)
}
log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath)
log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath)
return keyPair, nil
}

View File

@ -12,7 +12,7 @@ import (
"golang.org/x/crypto/ed25519"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
)
// sign-in with ssb uses 256-bit nonces
@ -54,9 +54,9 @@ type ClientPayload struct {
func (cr ClientPayload) createMessage() []byte {
var msg bytes.Buffer
msg.WriteString("=http-auth-sign-in:")
msg.WriteString(cr.ServerID.Ref())
msg.WriteString(cr.ServerID.String())
msg.WriteString(":")
msg.WriteString(cr.ClientID.Ref())
msg.WriteString(cr.ClientID.String())
msg.WriteString(":")
msg.WriteString(cr.ServerChallenge)
msg.WriteString(":")

View File

@ -11,13 +11,20 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
)
func TestPayloadString(t *testing.T) {
server := refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "test"}
client := refs.FeedRef{ID: bytes.Repeat([]byte{2}, 32), Algo: "test"}
server, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
client, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{2}, 32), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
var req ClientPayload
@ -27,7 +34,7 @@ func TestPayloadString(t *testing.T) {
req.ServerChallenge = "fooo"
req.ClientChallenge = "barr"
want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.test:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.test:fooo:barr"
want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.ed25519:fooo:barr"
got := req.createMessage()
assert.Equal(t, want, string(got))

View File

@ -13,14 +13,14 @@ import (
"fmt"
"strings"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/aliases"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssbc/go-ssb-room/v2/web/router"
)
// Handler implements the muxrpc methods for alias registration and recvocation
@ -93,7 +93,7 @@ func (h Handler) Register(ctx context.Context, req *muxrpc.Request) (interface{}
return nil, err
}
confirmation.UserID = *userID
confirmation.UserID = userID
// check the signature
if !confirmation.Verify() {

View File

@ -4,5 +4,5 @@
// Package handlers contains the muxrpc handler packages for the room server.
//
// The implementation the actual multiplexing implementation is go.cryptoscope.co/muxrpc.
// The implementation the actual multiplexing implementation is github.com/ssbc/go-muxrpc.
package handlers

View File

@ -10,7 +10,7 @@ import (
"io"
"time"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
"go.mindeco.de/encodedTime"
)

View File

@ -11,14 +11,14 @@ import (
"fmt"
"strings"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
validate "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
validate "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssbc/go-ssb-room/v2/roomdb"
)
// Handler implements the muxrpc methods for the "Sign-in with SSB" calls. SendSolution and InvalidateAllSolutions.
@ -64,7 +64,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa
return nil, err
}
member, err := h.members.GetByFeed(ctx, *clientID)
member, err := h.members.GetByFeed(ctx, clientID)
if err != nil {
return nil, fmt.Errorf("client is not a room member")
}
@ -81,7 +81,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa
var payload validate.ClientPayload
payload.ServerID = h.self
payload.ServerChallenge = params[0]
payload.ClientID = *clientID
payload.ClientID = clientID
payload.ClientChallenge = params[1]
sig, err := base64.StdEncoding.DecodeString(strings.TrimSuffix(params[2], ".sig.ed25519"))
@ -120,7 +120,7 @@ func (h Handler) InvalidateAllSolutions(ctx context.Context, req *muxrpc.Request
}
// lookup the member
member, err := h.members.GetByFeed(ctx, *clientID)
member, err := h.members.GetByFeed(ctx, clientID)
if err != nil {
return nil, err
}

View File

@ -10,10 +10,10 @@ import (
"fmt"
"sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
"go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs"
"github.com/ssbc/go-muxrpc/v2"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/roomdb"
)
// AttendantsUpdate is emitted if a single member joins or leaves.
@ -43,14 +43,14 @@ func (h *Handler) attendants(ctx context.Context, req *muxrpc.Request, snk *muxr
}
if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted {
_, err := h.membersdb.GetByFeed(ctx, *peer)
_, err := h.membersdb.GetByFeed(ctx, peer)
if err != nil {
return fmt.Errorf("external user are not allowed to enumerate members")
}
}
// add peer to the state
h.state.AddEndpoint(*peer, req.Endpoint())
h.state.AddEndpoint(peer, req.Endpoint())
// send the current state
snk.SetEncoding(muxrpc.TypeJSON)

View File

@ -10,13 +10,13 @@ import (
"fmt"
"io"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate"
refs "go.mindeco.de/ssb-refs"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/roomstate"
)
type ConnectArg struct {
@ -46,7 +46,7 @@ func (h connectHandler) HandleConnect(ctx context.Context, edp muxrpc.Endpoint)
return
}
h.state.Remove(*peer)
h.state.Remove(peer)
}
// HandleDuplex here implements the tunnel.connect behavior of the server-side. It receives incoming events
@ -63,7 +63,7 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p
}
arg := args[0]
if !arg.Portal.Equal(&h.self) {
if !arg.Portal.Equal(h.self) {
return fmt.Errorf("talking to the wrong room")
}
@ -74,29 +74,29 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p
}
// make sure they dont want to connect to themselves
if caller.Equal(&arg.Target) {
if caller.Equal(arg.Target) {
return fmt.Errorf("can't connect to self")
}
// see if we have and endpoint for the target
edp, has := h.state.Has(arg.Target)
if !has {
return fmt.Errorf("could not connect to:%s", arg.Target.Ref())
return fmt.Errorf("could not connect to:%s", arg.Target.String())
}
// call connect on them
var argWorigin connectWithOriginArg
argWorigin.ConnectArg = arg
argWorigin.Origin = *caller
argWorigin.Origin = caller
targetSrc, targetSnk, err := edp.Duplex(ctx, muxrpc.TypeBinary, muxrpc.Method{"tunnel", "connect"}, argWorigin)
if err != nil {
return fmt.Errorf("could not connect to:%s", arg.Target.Ref())
return fmt.Errorf("could not connect to:%s", arg.Target.String())
}
// pipe data between caller and target
var cpy muxrpcDuplexCopy
cpy.logger = kitlog.With(h.logger, "caller", caller.ShortRef(), "target", arg.Target.ShortRef())
cpy.logger = kitlog.With(h.logger, "caller", caller.ShortSigil(), "target", arg.Target.ShortSigil())
cpy.ctx, cpy.cancel = context.WithCancel(ctx)
go cpy.do(targetSnk, peerSrc)

View File

@ -8,10 +8,11 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
"go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs"
"github.com/ssbc/go-muxrpc/v2"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssbc/go-ssb-room/v2/roomdb"
)
type Member struct {
@ -30,7 +31,7 @@ func (h *Handler) members(ctx context.Context, req *muxrpc.Request, snk *muxrpc.
}
if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted {
_, err := h.membersdb.GetByFeed(ctx, *peer)
_, err := h.membersdb.GetByFeed(ctx, peer)
if err != nil {
return fmt.Errorf("external users are not allowed to list members: %w", err)
}

View File

@ -5,13 +5,13 @@
package server
import (
"go.cryptoscope.co/muxrpc/v2"
"go.cryptoscope.co/muxrpc/v2/typemux"
<