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 # 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. This repository implements the [Room (v1+v2) server spec](https://github.com/ssbc/rooms2), in Go.
It includes: 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 * muxrpc handlers for tunneling connections
* a fully embedded HTTP server & HTML frontend, for administering the room * 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 ## License
MIT MIT

View File

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

View File

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

View File

@ -9,9 +9,9 @@ SPDX-License-Identifier: CC0-1.0
## Invite flow ## Invite flow
This implementation of Rooms 2.0 is compliant with the [Rooms 2.0 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 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: A summary can be seen in the following chart:
@ -25,7 +25,7 @@ in a form.
## Sign-in flow ## Sign-in flow
This implementation is compliant with [SSB HTTP 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 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 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 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: 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 # Getting Started
There are two paths to starting your own room: creating a build from source, or downloading one There are two paths to starting your own room: creating a build from source, or downloading one
of the premade releases. of the premade releases.
## Premade builds ## 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. 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. 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 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 ## 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 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) * [Follow the development instructions](./development.md)
* You should now have a working go-ssb-room binary! Read the HTTP Hosting section below and admin * 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. 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 This project includes a docker-compose.yml file as well as a Docker file. Using
it should be fairly straight forward. 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 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 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 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). 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 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 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 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 The example nginx configuration uses prebuilt Diffie-Hellman parameters. You can generate these
with the following command: 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" 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 cd cmd/server && go build && ./server -htts-domain=my.room.example
``` ```
## Tooling ## Tooling
### Mocks ### Mocks
[`counterfeiter`](https://github.com/maxbrunsfeld/counterfeiter) enables generating mocks for defined interfaces. To update the mocks, run `go generate` in package roomdb. [`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 ## 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). 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). 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. This is also where you would put custom translations.
For more configuration background see /usr/share/go-ssb-room/README.md 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. 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 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. 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. the module [`goquery`](https://github.com/PuerkitoBio/goquery) for querying the returned HTML.
## Snippets ## Snippets
#### Print the raw html of the corresponding page #### Print the raw html of the corresponding page
``` ```
html, _ := ts.Client.GetHTML(url) html, _ := ts.Client.GetHTML(url)
fmt.Println(html.Html()) fmt.Println(html.Html())
``` ```
#### Find and print the `title` element of a page #### Find and print the `title` element of a page
``` ```
html, _ := ts.Client.GetHTML(url) html, _ := ts.Client.GetHTML(url)
title := html.Find("title") title := html.Find("title")
// print the title string // print the title string
fmt.Println(title.Text()) fmt.Println(title.Text())
``` ```
## Filling the mockdb ## Filling the mockdb
`go-ssb-room` uses database mocks for performing tests against the backend database logic. This `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. 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 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 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 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 > [counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) generates a bunch of methods for each function, so you have
> XXXXReturns, XXXCallCount XXXArgsForCall(i) etc > 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. The following examples show more concretely what mocking the data looks like.
**Having the List() function return a static list of three items:** **Having the List() function return a static list of three items:**
```go ```go
// go-ssb-room/web/handlers/admin/allow_list_test.go:113 // go-ssb-room/web/handlers/admin/allow_list_test.go:113
lst := roomdb.ListEntries{ lst := roomdb.ListEntries{
@ -80,10 +85,10 @@ lst := roomdb.ListEntries{
{ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}}, {ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}},
} }
ts.MembersDB.ListReturns(lst, nil) ts.MembersDB.ListReturns(lst, nil)
``` ```
**Checking how often RemoveID was called and with what arguments:** **Checking how often RemoveID was called and with what arguments:**
```go ```go
// go-ssb-room/web/handlers/admin/allow_list_test.go:210 // go-ssb-room/web/handlers/admin/allow_list_test.go:210
a.Equal(1, ts.MembersDB.RemoveIDCallCount()) a.Equal(1, ts.MembersDB.RemoveIDCallCount())
@ -91,8 +96,8 @@ ts.MembersDB.ListReturns(lst, nil)
a.EqualValues(666, theID) a.EqualValues(666, theID)
``` ```
## Example test ## Example test
```go ```go
package handlers package handlers
@ -144,4 +149,3 @@ cd muxrpc/test/nodejs
npm ci npm ci
go test go test
``` ```

17
go.mod
View File

@ -2,7 +2,7 @@
// //
// SPDX-License-Identifier: Unlicense // 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 go 1.16
@ -20,30 +20,29 @@ require (
github.com/mattevans/pwned-passwords v0.3.0 github.com/mattevans/pwned-passwords v0.3.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 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/nicksnyder/go-i18n/v2 v2.1.2
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351 github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
github.com/russross/blackfriday/v2 v2.1.0 github.com/russross/blackfriday/v2 v2.1.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e 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/throttled/throttled/v2 v2.7.1
github.com/unrolled/secure v1.0.8 github.com/unrolled/secure v1.0.8
github.com/vcraescu/go-paginator/v2 v2.0.0 github.com/vcraescu/go-paginator/v2 v2.0.0
github.com/volatiletech/sqlboiler/v4 v4.5.0 github.com/volatiletech/sqlboiler/v4 v4.5.0
github.com/volatiletech/strmangle v0.0.1 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/nocomment v0.0.0-20210520094614-fb744e81f810
go.cryptoscope.co/secretstream v1.2.8
go.mindeco.de v1.12.0 go.mindeco.de v1.12.0
go.mindeco.de/ssb-refs v0.2.0 golang.org/x/crypto v0.0.0-20221012134737-56aed061732a
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.5 golang.org/x/text v0.3.5
golang.org/x/tools v0.1.1 golang.org/x/tools v0.1.1
gopkg.in/yaml.v2 v2.4.0 // indirect 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 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= 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 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= 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/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.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= 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.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.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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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.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.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/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 h1:FnBysDX4Sok55bvfDMI0l2Y71V1vM2wi7O79OW7fNtw=
github.com/throttled/throttled/v2 v2.7.1/go.mod h1:fuOeyK9fmnA+LQnsBbfT/mmPHjmkdogRBQxaD8YsgZ8= 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/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 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= 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 h1:Sa7Q5X/La6bVTNT8Vcnt9GIGuOFOEFmjY3UNiwPErQk=
go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810/go.mod h1:SJ9qQwHw1S7F2RsE9Ez9RmBhGpIdAphG1xGnI0rdKUI= 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.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 h1:K5FHILjJlD/U1HJMs8Y9ZLwdfG4dPEsxw+e+eqg1wKc=
go.mindeco.de v1.12.0/go.mod h1:dZty08izAk/rSX8wSLen4gMR4WDPYmA6vUTE0QtepHA= 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/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/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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-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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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 h1:BYfdVuZB5He/u9dt4qDpZqiqDJ6KhPqs5QUqsr/Eeuc=
gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c= 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= gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=

View File

@ -2,7 +2,7 @@
// //
// SPDX-License-Identifier: MIT // 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 package aliases
import ( import (
@ -10,7 +10,7 @@ import (
"golang.org/x/crypto/ed25519" "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 // 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 { func (r Registration) createRegistrationMessage() []byte {
var message bytes.Buffer var message bytes.Buffer
message.WriteString("=room-alias-registration:") message.WriteString("=room-alias-registration:")
message.WriteString(r.RoomID.Ref()) message.WriteString(r.RoomID.String())
message.WriteString(":") message.WriteString(":")
message.WriteString(r.UserID.Ref()) message.WriteString(r.UserID.String())
message.WriteString(":") message.WriteString(":")
message.WriteString(r.Alias) message.WriteString(r.Alias)
return message.Bytes() return message.Bytes()

View File

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

View File

@ -5,7 +5,7 @@
package aliases package aliases
// IsValid decides whether an alias is okay for use or not. // 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, // but that can be mostly any string since DNS is a 8bit binary protocol,
// as long as it's shorter then 63 charachters. // as long as it's shorter then 63 charachters.
// //

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import (
"io" "io"
"sync" "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 { type Closer struct {

View File

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

View File

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

View File

@ -15,10 +15,10 @@ import (
"net/url" "net/url"
"time" "time"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
"go.cryptoscope.co/netwrap" "github.com/ssbc/go-netwrap"
"go.cryptoscope.co/secretstream" "github.com/ssbc/go-secretstream"
refs "go.mindeco.de/ssb-refs" refs "github.com/ssbc/go-ssb-refs"
) )
// ServerEndpointDetails encapsulates the endpoint information. // ServerEndpointDetails encapsulates the endpoint information.
@ -131,10 +131,10 @@ type ConnTracker interface {
} }
// GetFeedRefFromAddr uses netwrap to get the secretstream address and then uses ParseFeedRef // 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) addr = netwrap.GetAddr(addr, secretstream.NetworkString)
if addr == nil { 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) ssAddr := addr.(secretstream.Addr)
return refs.ParseFeedRef(ssAddr.String()) return refs.ParseFeedRef(ssAddr.String())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,8 +11,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
) )
func DefaultKeyPair(r Interface) (*keys.KeyPair, error) { 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 { if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
return nil, fmt.Errorf("repo: error saving new identity file: %w", err) 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 return keyPair, nil
} }
@ -53,7 +53,7 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair,
return nil, err 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") return nil, fmt.Errorf("invalid feed refrence algo")
} }
if _, err := keys.LoadKeyPair(secPath); err == nil { 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 { if err != nil {
return nil, fmt.Errorf("repo: no keypair but couldn't create one either: %w", err) 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 { if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
return nil, fmt.Errorf("repo: error saving new identity file: %w", err) 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 return keyPair, nil
} }

View File

@ -12,7 +12,7 @@ import (
"golang.org/x/crypto/ed25519" "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 // sign-in with ssb uses 256-bit nonces
@ -54,9 +54,9 @@ type ClientPayload struct {
func (cr ClientPayload) createMessage() []byte { func (cr ClientPayload) createMessage() []byte {
var msg bytes.Buffer var msg bytes.Buffer
msg.WriteString("=http-auth-sign-in:") msg.WriteString("=http-auth-sign-in:")
msg.WriteString(cr.ServerID.Ref()) msg.WriteString(cr.ServerID.String())
msg.WriteString(":") msg.WriteString(":")
msg.WriteString(cr.ClientID.Ref()) msg.WriteString(cr.ClientID.String())
msg.WriteString(":") msg.WriteString(":")
msg.WriteString(cr.ServerChallenge) msg.WriteString(cr.ServerChallenge)
msg.WriteString(":") msg.WriteString(":")

View File

@ -11,13 +11,20 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs" refs "github.com/ssbc/go-ssb-refs"
) )
func TestPayloadString(t *testing.T) { func TestPayloadString(t *testing.T) {
server := refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "test"} server, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1)
client := refs.FeedRef{ID: bytes.Repeat([]byte{2}, 32), Algo: "test"} 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 var req ClientPayload
@ -27,7 +34,7 @@ func TestPayloadString(t *testing.T) {
req.ServerChallenge = "fooo" req.ServerChallenge = "fooo"
req.ClientChallenge = "barr" 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() got := req.createMessage()
assert.Equal(t, want, string(got)) assert.Equal(t, want, string(got))

View File

@ -13,14 +13,14 @@ import (
"fmt" "fmt"
"strings" "strings"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/aliases"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/web/router"
) )
// Handler implements the muxrpc methods for alias registration and recvocation // 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 return nil, err
} }
confirmation.UserID = *userID confirmation.UserID = userID
// check the signature // check the signature
if !confirmation.Verify() { if !confirmation.Verify() {

View File

@ -4,5 +4,5 @@
// Package handlers contains the muxrpc handler packages for the room server. // 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 package handlers

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,13 +5,13 @@
package server package server
import ( import (
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
"go.cryptoscope.co/muxrpc/v2/typemux" "github.com/ssbc/go-muxrpc/v2/typemux"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" "github.com/ssbc/go-ssb-room/v2/roomstate"
) )
/* manifest: /* manifest:

View File

@ -12,11 +12,11 @@ import (
"sync" "sync"
"time" "time"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" "github.com/ssbc/go-ssb-room/v2/roomstate"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
) )
@ -50,7 +50,7 @@ func (h *Handler) metadata(ctx context.Context, req *muxrpc.Request) (interface{
reply.Name = h.netInfo.Domain reply.Name = h.netInfo.Domain
// check if caller is a member // check if caller is a member
if _, err := h.membersdb.GetByFeed(ctx, *ref); err != nil { if _, err := h.membersdb.GetByFeed(ctx, ref); err != nil {
if !errors.Is(err, roomdb.ErrNotFound) { if !errors.Is(err, roomdb.ErrNotFound) {
return nil, err return nil, err
} }
@ -90,7 +90,7 @@ func (h *Handler) announce(_ context.Context, req *muxrpc.Request) (interface{},
return nil, err return nil, err
} }
h.state.AddEndpoint(*ref, req.Endpoint()) h.state.AddEndpoint(ref, req.Endpoint())
return true, nil return true, nil
} }
@ -101,7 +101,7 @@ func (h *Handler) leave(_ context.Context, req *muxrpc.Request) (interface{}, er
return nil, err return nil, err
} }
h.state.Remove(*ref) h.state.Remove(ref)
return true, nil return true, nil
} }
@ -123,7 +123,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp
case roomdb.ModeCommunity: case roomdb.ModeCommunity:
fallthrough fallthrough
case roomdb.ModeRestricted: case roomdb.ModeRestricted:
_, err := h.membersdb.GetByFeed(ctx, *peer) _, err := h.membersdb.GetByFeed(ctx, peer)
if err != nil { if err != nil {
return fmt.Errorf("external user are not allowed to enumerate members") return fmt.Errorf("external user are not allowed to enumerate members")
} }
@ -134,7 +134,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp
h.state.RegisterLegacyEndpoints(toPeer) h.state.RegisterLegacyEndpoints(toPeer)
// add the peer to the room state if they arent already // add the peer to the room state if they arent already
h.state.AlreadyAdded(*peer, req.Endpoint()) h.state.AlreadyAdded(peer, req.Endpoint())
// update the peer with // update the peer with
toPeer.Update(h.state.List()) toPeer.Update(h.state.List())

View File

@ -7,13 +7,13 @@ package whoami
import ( import (
"context" "context"
"go.cryptoscope.co/muxrpc/v2/typemux" "github.com/ssbc/go-muxrpc/v2/typemux"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
refs "go.mindeco.de/ssb-refs" refs "github.com/ssbc/go-ssb-refs"
) )
var ( var (
@ -39,5 +39,5 @@ func (h handler) HandleAsync(ctx context.Context, req *muxrpc.Request) (interfac
ID string `json:"id"` ID string `json:"id"`
} }
return ret{h.id.Ref()}, nil return ret{h.id.String()}, nil
} }

View File

@ -13,14 +13,14 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssbc/go-muxrpc/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" "github.com/ssbc/go-ssb-room/v2/internal/aliases"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" "github.com/ssbc/go-ssb-room/v2/roomsrv"
) )
// technically we are usign two servers here // technically we are usign two servers here
@ -104,7 +104,7 @@ func TestAliasRegister(t *testing.T) {
a.Equal(confirmation.Alias, alias.Name) a.Equal(confirmation.Alias, alias.Name)
a.Equal(confirmation.Signature, alias.Signature) a.Equal(confirmation.Signature, alias.Signature)
a.True(confirmation.UserID.Equal(&bobsKey.Feed)) a.True(confirmation.UserID.Equal(bobsKey.Feed))
t.Log("alias stored") t.Log("alias stored")
@ -183,7 +183,7 @@ func TestListAliases(t *testing.T) {
var response string var response string
err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.Ref()) err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String())
r.NoError(err) r.NoError(err)
a.Equal("[]", response, "initially the list of aliases should be empty") a.Equal("[]", response, "initially the list of aliases should be empty")
@ -191,7 +191,7 @@ func TestListAliases(t *testing.T) {
r.NoError(err) r.NoError(err)
a.NotEqual("", response, "response isn't empty") a.NotEqual("", response, "response isn't empty")
err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.Ref()) err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String())
r.NoError(err) r.NoError(err)
a.Equal("[\"bob\"]", response, "new alias should be in the list") a.Equal("[\"bob\"]", response, "new alias should be in the list")
} }

View File

@ -13,11 +13,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/ssbc/go-muxrpc/v2"
refs "github.com/ssbc/go-ssb-refs"
"github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs"
) )
// this tests the new room.attendants call // this tests the new room.attendants call
@ -55,7 +55,7 @@ func TestRoomAttendants(t *testing.T) {
decodeJSONsrc(t, carlsSource, &initState) decodeJSONsrc(t, carlsSource, &initState)
a.Equal("state", initState.Type) a.Equal("state", initState.Type)
a.Len(initState.IDs, 1) a.Len(initState.IDs, 1)
a.True(initState.IDs[0].Equal(&carl.feed)) a.True(initState.IDs[0].Equal(carl.feed))
announcementsForCarl := make(announcements) announcementsForCarl := make(announcements)
go logAttendantsStream(ts, carlsSource, "carl", announcementsForCarl) go logAttendantsStream(ts, carlsSource, "carl", announcementsForCarl)
@ -85,7 +85,7 @@ func TestRoomAttendants(t *testing.T) {
a.Len(announcementsForAlf, 0, "none yet") a.Len(announcementsForAlf, 0, "none yet")
// assert what carl saw // assert what carl saw
_, seen = announcementsForCarl[alf.feed.Ref()] _, seen = announcementsForCarl[alf.feed.String()]
a.True(seen, "carl saw alf") a.True(seen, "carl saw alf")
// let bre join the room // let bre join the room
@ -109,10 +109,10 @@ func TestRoomAttendants(t *testing.T) {
a.Len(announcementsForBre, 0, "none yet") a.Len(announcementsForBre, 0, "none yet")
// the two present people saw her // the two present people saw her
_, seen = announcementsForAlf[bre.feed.Ref()] _, seen = announcementsForAlf[bre.feed.String()]
a.True(seen, "alf saw bre") a.True(seen, "alf saw bre")
_, seen = announcementsForCarl[bre.feed.Ref()] _, seen = announcementsForCarl[bre.feed.String()]
a.True(seen, "carl saw alf") a.True(seen, "carl saw alf")
// shutdown alf first // shutdown alf first
@ -122,10 +122,10 @@ func TestRoomAttendants(t *testing.T) {
// bre and arl should have removed him // bre and arl should have removed him
_, seen = announcementsForBre[alf.feed.Ref()] _, seen = announcementsForBre[alf.feed.String()]
a.False(seen, "alf should be gone for bre") a.False(seen, "alf should be gone for bre")
_, seen = announcementsForCarl[alf.feed.Ref()] _, seen = announcementsForCarl[alf.feed.String()]
a.False(seen, "alf should be gone for carl") a.False(seen, "alf should be gone for carl")
// terminate server and the clients // terminate server and the clients
@ -143,12 +143,12 @@ func TestRoomAttendants(t *testing.T) {
func assertListContains(t *testing.T, lst []refs.FeedRef, who refs.FeedRef) { func assertListContains(t *testing.T, lst []refs.FeedRef, who refs.FeedRef) {
var found = false var found = false
for _, feed := range lst { for _, feed := range lst {
if feed.Equal(&who) { if feed.Equal(who) {
found = true found = true
} }
} }
if !found { if !found {
t.Errorf("did not find %s in list of %d", who.ShortRef(), len(lst)) t.Errorf("did not find %s in list of %d", who.ShortSigil(), len(lst))
} }
} }
@ -176,13 +176,13 @@ func logAttendantsStream(ts *testSession, src *muxrpc.ByteSource, who string, a
if err != nil { if err != nil {
panic(err) panic(err)
} }
ts.t.Log(who, "got an update:", update.Type, update.ID.ShortRef()) ts.t.Log(who, "got an update:", update.Type, update.ID.ShortSigil())
switch update.Type { switch update.Type {
case "joined": case "joined":
a[update.ID.Ref()] = struct{}{} a[update.ID.String()] = struct{}{}
case "left": case "left":
delete(a, update.ID.Ref()) delete(a, update.ID.String())
default: default:
ts.t.Fatalf("%s: unexpected update type: %v", who, update.Type) ts.t.Fatalf("%s: unexpected update type: %v", who, update.Type)
} }

View File

@ -9,12 +9,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssbc/go-muxrpc/v2"
refs "github.com/ssbc/go-ssb-refs"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs"
) )
// This test denies connections for keys that have been added to the deny list database, DeniedKeys. // This test denies connections for keys that have been added to the deny list database, DeniedKeys.
@ -72,7 +72,7 @@ func TestConnEstablishmentDeniedKey(t *testing.T) {
a.Nil(endpointB, "should not have an endpoint on B") a.Nil(endpointB, "should not have an endpoint on B")
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.Error(err) r.Error(err)
t.Log(srvWho.ID.Ref()) t.Log(srvWho.ID.String())
} }
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
@ -81,8 +81,8 @@ func TestConnEstablishmentDeniedKey(t *testing.T) {
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
t.Log("server whoami:", srvWho.ID.Ref()) t.Log("server whoami:", srvWho.ID.String())
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
cancel() cancel()
} }
@ -141,7 +141,7 @@ func TestConnEstablishmentDenyNonMembersRestrictedRoom(t *testing.T) {
a.Nil(endpointB, "should not have an endpoint on B (B is not a member, and the server is restricted)") a.Nil(endpointB, "should not have an endpoint on B (B is not a member, and the server is restricted)")
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.Error(err) r.Error(err)
t.Log(srvWho.ID.Ref()) t.Log(srvWho.ID.String())
} }
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
@ -150,8 +150,8 @@ func TestConnEstablishmentDenyNonMembersRestrictedRoom(t *testing.T) {
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
t.Log("server whoami:", srvWho.ID.Ref()) t.Log("server whoami:", srvWho.ID.String())
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
cancel() cancel()
} }
@ -211,7 +211,7 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) {
r.True(has, "botB has no endpoint for the server") r.True(has, "botB has no endpoint for the server")
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
t.Log(srvWho.ID.Ref()) t.Log(srvWho.ID.String())
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
r.True(has, "botA has no endpoint for the server") r.True(has, "botA has no endpoint for the server")
@ -219,8 +219,8 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) {
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
t.Log("server whoami:", srvWho.ID.Ref()) t.Log("server whoami:", srvWho.ID.String())
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
cancel() cancel()
} }

View File

@ -12,11 +12,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssbc/go-muxrpc/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
refs "go.mindeco.de/ssb-refs" refs "github.com/ssbc/go-ssb-refs"
) )
type announcements map[string]struct{} type announcements map[string]struct{}
@ -54,7 +54,7 @@ func TestEndpointClients(t *testing.T) {
go logEndpointsStream(ts, carlEndpointsSrc, "carl", announcementsForCarl) go logEndpointsStream(ts, carlEndpointsSrc, "carl", announcementsForCarl)
time.Sleep(1 * time.Second) // give some time to process new events time.Sleep(1 * time.Second) // give some time to process new events
_, seen := announcementsForCarl[carl.feed.Ref()] _, seen := announcementsForCarl[carl.feed.String()]
a.True(seen, "carl saw himself") a.True(seen, "carl saw himself")
// let alf join the room // let alf join the room
@ -66,13 +66,13 @@ func TestEndpointClients(t *testing.T) {
time.Sleep(1 * time.Second) // give some time to process new events time.Sleep(1 * time.Second) // give some time to process new events
// assert what alf saw // assert what alf saw
_, seen = announcementsForAlf[carl.feed.Ref()] _, seen = announcementsForAlf[carl.feed.String()]
a.True(seen, "alf saw carl") a.True(seen, "alf saw carl")
_, seen = announcementsForAlf[alf.feed.Ref()] _, seen = announcementsForAlf[alf.feed.String()]
a.True(seen, "alf saw himself") a.True(seen, "alf saw himself")
// assert what carl saw // assert what carl saw
_, seen = announcementsForCarl[alf.feed.Ref()] _, seen = announcementsForCarl[alf.feed.String()]
a.True(seen, "carl saw alf") a.True(seen, "carl saw alf")
// let bre join the room // let bre join the room
@ -85,17 +85,17 @@ func TestEndpointClients(t *testing.T) {
time.Sleep(1 * time.Second) // give some time to process new events time.Sleep(1 * time.Second) // give some time to process new events
// assert bre saw the other two and herself // assert bre saw the other two and herself
_, seen = announcementsForBre[carl.feed.Ref()] _, seen = announcementsForBre[carl.feed.String()]
a.True(seen, "bre saw carl") a.True(seen, "bre saw carl")
_, seen = announcementsForBre[alf.feed.Ref()] _, seen = announcementsForBre[alf.feed.String()]
a.True(seen, "bre saw alf") a.True(seen, "bre saw alf")
_, seen = announcementsForBre[bre.feed.Ref()] _, seen = announcementsForBre[bre.feed.String()]
a.True(seen, "bre saw herself") a.True(seen, "bre saw herself")
// assert the others saw bre // assert the others saw bre
_, seen = announcementsForAlf[bre.feed.Ref()] _, seen = announcementsForAlf[bre.feed.String()]
a.True(seen, "alf saw bre") a.True(seen, "alf saw bre")
_, seen = announcementsForCarl[bre.feed.Ref()] _, seen = announcementsForCarl[bre.feed.String()]
a.True(seen, "carl saw bre") a.True(seen, "carl saw bre")
// terminate server and the clients // terminate server and the clients
@ -127,10 +127,10 @@ func logEndpointsStream(ts *testSession, src *muxrpc.ByteSource, who string, a a
} }
ts.t.Log(who, "got endpoints:", len(edps)) ts.t.Log(who, "got endpoints:", len(edps))
for i, f := range edps { for i, f := range edps {
ts.t.Log(who, ":", i, f.ShortRef()) ts.t.Log(who, ":", i, f.ShortSigil())
// mark as f is present // mark as f is present
a[f.Ref()] = struct{}{} a[f.String()] = struct{}{}
} }
} }

View File

@ -7,16 +7,16 @@ package go_test
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" "github.com/ssbc/go-ssb-room/v2/roomsrv"
"math/rand" "math/rand"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
) )
// this tests the new room.members call // this tests the new room.members call

View File

@ -13,10 +13,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssbc/go-muxrpc/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
) )
// peers not on the members list can't connect // peers not on the members list can't connect
@ -73,7 +73,7 @@ func TestStaleMembers(t *testing.T) {
// restart srh // restart srh
oldSrh := srh.feed oldSrh := srh.feed
srh = ts.makeTestClient("srh") srh = ts.makeTestClient("srh")
r.True(oldSrh.Equal(&srh.feed)) r.True(oldSrh.Equal(srh.feed))
t.Log("restarted srh") t.Log("restarted srh")
time.Sleep(1 * time.Second) // let server respond time.Sleep(1 * time.Second) // let server respond

View File

@ -9,13 +9,13 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssbc/go-muxrpc/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
tunserv "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
func TestTunnelServerSimple(t *testing.T) { func TestTunnelServerSimple(t *testing.T) {
@ -68,7 +68,7 @@ func TestTunnelServerSimple(t *testing.T) {
a.Nil(endpointB, "should not have an endpoint on B") a.Nil(endpointB, "should not have an endpoint on B")
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.Error(err) r.Error(err)
t.Log(srvWho.ID.Ref()) t.Log(srvWho.ID.String())
} }
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami()) endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
@ -77,8 +77,8 @@ func TestTunnelServerSimple(t *testing.T) {
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
t.Log("server whoami:", srvWho.ID.Ref()) t.Log("server whoami:", srvWho.ID.String())
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
// start testing basic room stuff // start testing basic room stuff
var meta tunserv.MetadataReply var meta tunserv.MetadataReply
@ -145,11 +145,11 @@ func TestRoomAnnounce(t *testing.T) {
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"}) err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
r.NoError(err) r.NoError(err)
a.True(serv.Whoami().Equal(&srvWho.ID)) a.True(serv.Whoami().Equal(srvWho.ID))
// let B listen for changes // let B listen for changes
newRoomMember, err := endpointB.Source(ctx, muxrpc.TypeJSON, muxrpc.Method{"tunnel", "endpoints"}) newRoomMember, err := endpointB.Source(ctx, muxrpc.TypeJSON, muxrpc.Method{"tunnel", "endpoints"})

View File

@ -19,25 +19,25 @@ import (
"time" "time"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/ssbc/go-muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2/debug"
"github.com/ssbc/go-netwrap"
"github.com/ssbc/go-secretstream"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
"go.cryptoscope.co/muxrpc/v2/debug"
"go.cryptoscope.co/netwrap"
"go.cryptoscope.co/secretstream"
"go.mindeco.de/log" "go.mindeco.de/log"
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils" "github.com/ssbc/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/testutils"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomsrv"
) )
var ( var (
@ -167,7 +167,7 @@ func (ts *testSession) makeTestClient(name string) testClient {
ts.clientKeys[name] = client ts.clientKeys[name] = client
} }
ts.t.Log(name, "is", client.Feed.ShortRef()) ts.t.Log(name, "is", client.Feed.ShortSigil())
// add it as a memeber, if it isnt already // add it as a memeber, if it isnt already
_, err := ts.srv.Members.GetByFeed(ts.ctx, client.Feed) _, err := ts.srv.Members.GetByFeed(ts.ctx, client.Feed)

View File

@ -17,16 +17,16 @@ import (
"time" "time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/ssbc/go-muxrpc/v2"
"github.com/ssbc/go-muxrpc/v2/debug"
"github.com/ssbc/go-secretstream"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2"
"go.cryptoscope.co/muxrpc/v2/debug"
"go.cryptoscope.co/secretstream"
"go.mindeco.de/encodedTime" "go.mindeco.de/encodedTime"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" "github.com/ssbc/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/network"
tunserv "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
func TestWebsocketDialing(t *testing.T) { func TestWebsocketDialing(t *testing.T) {

View File

@ -11,9 +11,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases" "github.com/ssbc/go-ssb-room/v2/internal/aliases"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb"
) )
func TestGoServerJSClientAliases(t *testing.T) { func TestGoServerJSClientAliases(t *testing.T) {
@ -51,7 +51,7 @@ func TestGoServerJSClientAliases(t *testing.T) {
r.Equal(1, aliasesDB.RegisterCallCount(), "register call count") r.Equal(1, aliasesDB.RegisterCallCount(), "register call count")
_, name, ref, signature := aliasesDB.RegisterArgsForCall(0) _, name, ref, signature := aliasesDB.RegisterArgsForCall(0)
a.Equal("alice", name, "wrong alias registered") a.Equal("alice", name, "wrong alias registered")
a.Equal(alice.Ref(), ref.Ref()) a.Equal(alice.String(), ref.String())
var aliasReq aliases.Confirmation var aliasReq aliases.Confirmation
aliasReq.Alias = name aliasReq.Alias = name

View File

@ -21,20 +21,20 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssbc/go-muxrpc/v2/debug"
"github.com/ssbc/go-netwrap"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.cryptoscope.co/muxrpc/v2/debug"
"go.cryptoscope.co/netwrap"
"go.mindeco.de/log" "go.mindeco.de/log"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/maybemod/testutils"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv" "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomsrv"
) )
func init() { func init() {
@ -121,7 +121,7 @@ func (ts *testSession) startGoServer(
if err != nil { if err != nil {
return nil, err return nil, err
} }
fname := filepath.Join("testrun", ts.t.Name(), "muxdump", ref.ShortRef()) fname := filepath.Join("testrun", ts.t.Name(), "muxdump", ref.ShortSigil())
return debug.WrapDump(fname, conn) return debug.WrapDump(fname, conn)
}), }),
) )
@ -135,7 +135,7 @@ func (ts *testSession) startGoServer(
srv, err := roomsrv.New(membersDB, deniedKeysDB, aliasDB, authSessionsDB, sb, fakeConfig, netInfo, opts...) srv, err := roomsrv.New(membersDB, deniedKeysDB, aliasDB, authSessionsDB, sb, fakeConfig, netInfo, opts...)
r.NoError(err, "failed to init tees a server") r.NoError(err, "failed to init tees a server")
ts.t.Logf("go server: %s", srv.Whoami().Ref()) ts.t.Logf("go server: %s", srv.Whoami().String())
ts.t.Cleanup(func() { ts.t.Cleanup(func() {
ts.t.Log("bot close:", srv.Close()) ts.t.Log("bot close:", srv.Close())
}) })
@ -143,7 +143,7 @@ func (ts *testSession) startGoServer(
ts.done.Go(func() error { ts.done.Go(func() error {
err := srv.Network.Serve(ts.ctx) err := srv.Network.Serve(ts.ctx)
// if the muxrpc protocol fucks up by e.g. unpacking body data into a header, this type of error will be surfaced here and look scary in the test output // if the muxrpc protocol fucks up by e.g. unpacking body data into a header, this type of error will be surfaced here and look scary in the test output
// example: https://github.com/ssb-ngi-pointer/go-ssb-room/pull/85#issuecomment-801106687 // example: https://github.com/ssbc/go-ssb-room/pull/85#issuecomment-801106687
if err != nil && !errors.Is(err, context.Canceled) { if err != nil && !errors.Is(err, context.Canceled) {
err = fmt.Errorf("go server exited: %w", err) err = fmt.Errorf("go server exited: %w", err)
ts.t.Log(err) ts.t.Log(err)
@ -187,7 +187,7 @@ func (ts *testSession) startJSClient(
"TEST_NAME=" + name, "TEST_NAME=" + name,
"TEST_REPO=" + cmd.Dir, "TEST_REPO=" + cmd.Dir,
"TEST_PEERADDR=" + netwrap.GetAddr(peerAddr, "tcp").String(), "TEST_PEERADDR=" + netwrap.GetAddr(peerAddr, "tcp").String(),
"TEST_PEERREF=" + peerRef.Ref(), "TEST_PEERREF=" + peerRef.String(),
"TEST_SESSIONSCRIPT=" + testScript, "TEST_SESSIONSCRIPT=" + testScript,
// "DEBUG=ssb:room:tunnel:*", // "DEBUG=ssb:room:tunnel:*",
} }
@ -221,8 +221,8 @@ func (ts *testSession) startJSClient(
jsBotRef, err := refs.ParseFeedRef(pubScanner.Text()) jsBotRef, err := refs.ParseFeedRef(pubScanner.Text())
r.NoError(err, "failed to get %s key from JS process") r.NoError(err, "failed to get %s key from JS process")
ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.Ref()) ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.String())
return *jsBotRef return jsBotRef
} }
// startJSBotAsServer returns the servers public key and it's TCP port on localhost. // startJSBotAsServer returns the servers public key and it's TCP port on localhost.
@ -277,8 +277,8 @@ func (ts *testSession) startJSBotAsServer(name, testScriptFileName string) (*ref
srvRef, err := refs.ParseFeedRef(pubScanner.Text()) srvRef, err := refs.ParseFeedRef(pubScanner.Text())
r.NoError(err, "failed to get srvRef key from JS process") r.NoError(err, "failed to get srvRef key from JS process")
ts.t.Logf("JS %s: %s port: %d", name, srvRef.Ref(), port) ts.t.Logf("JS %s: %s port: %d", name, srvRef.String(), port)
return srvRef, port return &srvRef, port
} }
func (ts *testSession) wait() { func (ts *testSession) wait() {

View File

@ -16,9 +16,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb/mockdb"
) )
// legacy js end-to-end test as a sanity check // legacy js end-to-end test as a sanity check
@ -136,7 +136,7 @@ func TestModernJSClient(t *testing.T) {
} }
// found a nasty `throw err` in the JS stack around pull.drain. lets make sure it stays gone // found a nasty `throw err` in the JS stack around pull.drain. lets make sure it stays gone
// https://github.com/ssb-ngi-pointer/go-ssb-room/issues/190 // https://github.com/ssbc/go-ssb-room/issues/190
func TestClientSurvivesShutdown(t *testing.T) { func TestClientSurvivesShutdown(t *testing.T) {
r := require.New(t) r := require.New(t)
@ -177,11 +177,11 @@ func TestClientSurvivesShutdown(t *testing.T) {
func writeRoomHandleFile(srv, target refs.FeedRef, filePath string) error { func writeRoomHandleFile(srv, target refs.FeedRef, filePath string) error {
var roomHandle bytes.Buffer var roomHandle bytes.Buffer
roomHandle.WriteString("tunnel:") roomHandle.WriteString("tunnel:")
roomHandle.WriteString(srv.Ref()) roomHandle.WriteString(srv.String())
roomHandle.WriteString(":") roomHandle.WriteString(":")
roomHandle.WriteString(target.Ref()) roomHandle.WriteString(target.String())
roomHandle.WriteString("~shs:") roomHandle.WriteString("~shs:")
roomHandle.WriteString(base64.StdEncoding.EncodeToString(target.ID)) roomHandle.WriteString(base64.StdEncoding.EncodeToString(target.PubKey()))
os.MkdirAll(filepath.Dir(filePath), 0700) os.MkdirAll(filepath.Dir(filePath), 0700)
return ioutil.WriteFile(filePath, roomHandle.Bytes(), 0700) return ioutil.WriteFile(filePath, roomHandle.Bytes(), 0700)

View File

@ -15,8 +15,8 @@ package roomdb
import ( import (
"context" "context"
refs "github.com/ssbc/go-ssb-refs"
"go.mindeco.de/http/auth" "go.mindeco.de/http/auth"
refs "go.mindeco.de/ssb-refs"
) )
type RoomConfig interface { type RoomConfig interface {
@ -143,7 +143,7 @@ type AliasesService interface {
type InvitesService interface { type InvitesService interface {
// Create creates a new invite for a new member. It returns the token or an error. // Create creates a new invite for a new member. It returns the token or an error.
// createdBy is user ID of the admin or moderator who created it. MemberID -1 is allowed if Privacy Mode is set to Open. // createdBy is user ID of the admin or moderator who created it. MemberID -1 is allowed if Privacy Mode is set to Open.
// aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssb-ngi-pointer/rooms2/issues/21) // aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssbc/rooms2/issues/21)
Create(ctx context.Context, createdBy int64) (string, error) Create(ctx context.Context, createdBy int64) (string, error)
// Consume checks if the passed token is still valid. // Consume checks if the passed token is still valid.

View File

@ -9,8 +9,8 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeAliasesService struct { type FakeAliasesService struct {

View File

@ -9,7 +9,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeAuthWithSSBService struct { type FakeAuthWithSSBService struct {

View File

@ -9,7 +9,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeAuthFallbackService struct { type FakeAuthFallbackService struct {

View File

@ -9,8 +9,8 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeDeniedKeysService struct { type FakeDeniedKeysService struct {

View File

@ -9,7 +9,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakePinnedNoticesService struct { type FakePinnedNoticesService struct {

View File

@ -9,8 +9,8 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeInvitesService struct { type FakeInvitesService struct {

View File

@ -9,8 +9,8 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeMembersService struct { type FakeMembersService struct {

View File

@ -9,7 +9,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeNoticesService struct { type FakeNoticesService struct {

View File

@ -9,7 +9,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
type FakeRoomConfig struct { type FakeRoomConfig struct {

View File

@ -13,9 +13,9 @@ import (
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface
@ -82,7 +82,7 @@ func (a Aliases) List(ctx context.Context) ([]roomdb.Alias, error) {
func (a Aliases) Register(ctx context.Context, alias string, userFeed refs.FeedRef, signature []byte) error { func (a Aliases) Register(ctx context.Context, alias string, userFeed refs.FeedRef, signature []byte) error {
return transact(a.db, func(tx *sql.Tx) error { return transact(a.db, func(tx *sql.Tx) error {
// check we have a members entry for the feed and load it to get its ID // check we have a members entry for the feed and load it to get its ID
memberEntry, err := models.Members(qm.Where("pub_key = ?", userFeed.Ref())).One(ctx, tx) memberEntry, err := models.Members(qm.Where("pub_key = ?", userFeed.String())).One(ctx, tx)
if err != nil { if err != nil {
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return roomdb.ErrNotFound return roomdb.ErrNotFound

View File

@ -15,9 +15,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/repo"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
func TestAliases(t *testing.T) { func TestAliases(t *testing.T) {
@ -28,7 +28,10 @@ func TestAliases(t *testing.T) {
tr := repo.New(testRepo) tr := repo.New(testRepo)
// fake feed for testing, looks ok at least // fake feed for testing, looks ok at least
newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
// 64 bytes of random for testing (validation is handled by the handlers) // 64 bytes of random for testing (validation is handled by the handlers)
testSig := make([]byte, 64) testSig := make([]byte, 64)
@ -112,7 +115,10 @@ func TestAliasesUniqueError(t *testing.T) {
r.NoError(err) r.NoError(err)
// fake feed for testing, looks ok at least // fake feed for testing, looks ok at least
newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
// 64 bytes of random for testing (validation is handled by the handlers) // 64 bytes of random for testing (validation is handled by the handlers)
testSig := make([]byte, 64) testSig := make([]byte, 64)

View File

@ -19,9 +19,9 @@ import (
"go.mindeco.de/http/auth" "go.mindeco.de/http/auth"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" weberrors "github.com/ssbc/go-ssb-room/v2/web/errors"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface

View File

@ -12,10 +12,10 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs"
) )
func TestFallbackAuth(t *testing.T) { func TestFallbackAuth(t *testing.T) {
@ -27,7 +27,10 @@ func TestFallbackAuth(t *testing.T) {
tr := repo.New(testRepo) tr := repo.New(testRepo)
// fake feed for testing, looks ok at least // fake feed for testing, looks ok at least
newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
db, err := Open(tr) db, err := Open(tr)
r.NoError(err, "failed to open database") r.NoError(err, "failed to open database")
@ -40,7 +43,7 @@ func TestFallbackAuth(t *testing.T) {
err = db.AuthFallback.SetPassword(ctx, memberID, testPassword) err = db.AuthFallback.SetPassword(ctx, memberID, testPassword)
r.NoError(err, "failed to create password") r.NoError(err, "failed to create password")
cookieVal, err := db.AuthFallback.Check(newMember.Ref(), string(testPassword)) cookieVal, err := db.AuthFallback.Check(newMember.String(), string(testPassword))
r.NoError(err, "failed to check password") r.NoError(err, "failed to check password")
gotID, ok := cookieVal.(int64) gotID, ok := cookieVal.(int64)
r.True(ok, "unexpected cookie value: %T", cookieVal) r.True(ok, "unexpected cookie value: %T", cookieVal)
@ -74,7 +77,10 @@ func TestFallbackAuthSetPassword(t *testing.T) {
tr := repo.New(testRepo) tr := repo.New(testRepo)
// fake feed for testing, looks ok at least // fake feed for testing, looks ok at least
newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
db, err := Open(tr) db, err := Open(tr)
r.NoError(err, "failed to open database") r.NoError(err, "failed to open database")
@ -88,14 +94,14 @@ func TestFallbackAuthSetPassword(t *testing.T) {
r.NoError(err, "failed to set password") r.NoError(err, "failed to set password")
// use the password // use the password
cookieVal, err := db.AuthFallback.Check(newMember.Ref(), string(testPassword)) cookieVal, err := db.AuthFallback.Check(newMember.String(), string(testPassword))
r.NoError(err, "failed to check password") r.NoError(err, "failed to check password")
gotID, ok := cookieVal.(int64) gotID, ok := cookieVal.(int64)
r.True(ok, "unexpected cookie value: %T", cookieVal) r.True(ok, "unexpected cookie value: %T", cookieVal)
r.Equal(memberID, gotID, "unexpected member ID value") r.Equal(memberID, gotID, "unexpected member ID value")
// use a wrong password // use a wrong password
cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(testPassword)+"nope-nope-nope") cookieVal, err = db.AuthFallback.Check(newMember.String(), string(testPassword)+"nope-nope-nope")
r.Error(err, "wrong password actually worked?!") r.Error(err, "wrong password actually worked?!")
r.Nil(cookieVal) r.Nil(cookieVal)
@ -105,11 +111,11 @@ func TestFallbackAuthSetPassword(t *testing.T) {
r.NoError(err, "failed to update password") r.NoError(err, "failed to update password")
// now try to use old and new // now try to use old and new
cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(testPassword)) cookieVal, err = db.AuthFallback.Check(newMember.String(), string(testPassword))
r.Error(err, "old password actually worked?!") r.Error(err, "old password actually worked?!")
r.Nil(cookieVal) r.Nil(cookieVal)
cookieVal, err = db.AuthFallback.Check(newMember.Ref(), string(changedTestPassword)) cookieVal, err = db.AuthFallback.Check(newMember.String(), string(changedTestPassword))
r.NoError(err, "new password didnt work") r.NoError(err, "new password didnt work")
gotID, ok = cookieVal.(int64) gotID, ok = cookieVal.(int64)
r.True(ok, "unexpected cookie value: %T", cookieVal) r.True(ok, "unexpected cookie value: %T", cookieVal)
@ -125,8 +131,15 @@ func TestFallbackAuthSetPasswordWithToken(t *testing.T) {
tr := repo.New(testRepo) tr := repo.New(testRepo)
// two fake feeds for testing, looks ok at least // two fake feeds for testing, looks ok at least
alf := refs.FeedRef{ID: bytes.Repeat([]byte("whyy"), 8), Algo: refs.RefAlgoFeedSSB1} alf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("whyy"), 8), refs.RefAlgoFeedSSB1)
carl := refs.FeedRef{ID: bytes.Repeat([]byte("carl"), 8), Algo: refs.RefAlgoFeedSSB1} if err != nil {
r.Error(err)
}
carl, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("carl"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
db, err := Open(tr) db, err := Open(tr)
r.NoError(err, "failed to open database") r.NoError(err, "failed to open database")
@ -155,7 +168,7 @@ func TestFallbackAuthSetPasswordWithToken(t *testing.T) {
r.NoError(err, "setPassword with token failed") r.NoError(err, "setPassword with token failed")
// now use the new password // now use the new password
cookieVal, err := db.AuthFallback.Check(carl.Ref(), newPassword) cookieVal, err := db.AuthFallback.Check(carl.String(), newPassword)
r.NoError(err, "new password didnt work") r.NoError(err, "new password didnt work")
gotID, ok := cookieVal.(int64) gotID, ok := cookieVal.(int64)
r.True(ok, "unexpected cookie value: %T", cookieVal) r.True(ok, "unexpected cookie value: %T", cookieVal)

View File

@ -14,9 +14,9 @@ import (
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/randutil" "github.com/ssbc/go-ssb-room/v2/internal/randutil"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface

View File

@ -14,9 +14,9 @@ import (
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface
@ -30,7 +30,7 @@ type DeniedKeys struct {
// Add adds the feed to the list. // Add adds the feed to the list.
func (dk DeniedKeys) Add(ctx context.Context, a refs.FeedRef, comment string) error { func (dk DeniedKeys) Add(ctx context.Context, a refs.FeedRef, comment string) error {
// TODO: better valid // TODO: better valid
if _, err := refs.ParseFeedRef(a.Ref()); err != nil { if _, err := refs.ParseFeedRef(a.String()); err != nil {
return err return err
} }
@ -53,7 +53,7 @@ func (dk DeniedKeys) Add(ctx context.Context, a refs.FeedRef, comment string) er
// HasFeed returns true if a feed is on the list. // HasFeed returns true if a feed is on the list.
func (dk DeniedKeys) HasFeed(ctx context.Context, h refs.FeedRef) bool { func (dk DeniedKeys) HasFeed(ctx context.Context, h refs.FeedRef) bool {
_, err := models.DeniedKeys(qm.Where("pub_key = ?", h.Ref())).One(ctx, dk.db) _, err := models.DeniedKeys(qm.Where("pub_key = ?", h.String())).One(ctx, dk.db)
if err != nil { if err != nil {
return false return false
} }
@ -116,7 +116,7 @@ func (dk DeniedKeys) Count(ctx context.Context) (uint, error) {
// RemoveFeed removes the feed from the list. // RemoveFeed removes the feed from the list.
func (dk DeniedKeys) RemoveFeed(ctx context.Context, r refs.FeedRef) error { func (dk DeniedKeys) RemoveFeed(ctx context.Context, r refs.FeedRef) error {
entry, err := models.DeniedKeys(qm.Where("pub_key = ?", r.Ref())).One(ctx, dk.db) entry, err := models.DeniedKeys(qm.Where("pub_key = ?", r.String())).One(ctx, dk.db)
if err != nil { if err != nil {
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return roomdb.ErrNotFound return roomdb.ErrNotFound

View File

@ -12,12 +12,12 @@ import (
"testing" "testing"
"time" "time"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs"
) )
func TestDeniedKeys(t *testing.T) { func TestDeniedKeys(t *testing.T) {
@ -32,14 +32,20 @@ func TestDeniedKeys(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
tf := refs.FeedRef{ID: bytes.Repeat([]byte("fooo"), 8), Algo: "nope"} tf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("fooo"), 8), "nope")
if err != nil {
r.Error(err)
}
err = db.DeniedKeys.Add(ctx, tf, "wont work anyhow") err = db.DeniedKeys.Add(ctx, tf, "wont work anyhow")
r.Error(err) r.Error(err)
// looks ok at least // looks ok at least
created := time.Now() created := time.Now()
time.Sleep(time.Second) time.Sleep(time.Second)
okFeed := refs.FeedRef{ID: bytes.Repeat([]byte("b44d"), 8), Algo: refs.RefAlgoFeedSSB1} okFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b44d"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
err = db.DeniedKeys.Add(ctx, okFeed, "be gone") err = db.DeniedKeys.Add(ctx, okFeed, "be gone")
r.NoError(err) r.NoError(err)
@ -53,7 +59,7 @@ func TestDeniedKeys(t *testing.T) {
lst, err := db.DeniedKeys.List(ctx) lst, err := db.DeniedKeys.List(ctx)
r.NoError(err) r.NoError(err)
r.Len(lst, 1) r.Len(lst, 1)
r.Equal(okFeed.Ref(), lst[0].PubKey.Ref()) r.Equal(okFeed.String(), lst[0].PubKey.String())
r.Equal("be gone", lst[0].Comment) r.Equal("be gone", lst[0].Comment)
r.True(lst[0].CreatedAt.After(created), "not created after the sleep?") r.True(lst[0].CreatedAt.After(created), "not created after the sleep?")
@ -92,7 +98,10 @@ func TestDeniedKeysUnique(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("b33f"), 8), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b33f"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
err = db.DeniedKeys.Add(ctx, feedA, "test comment") err = db.DeniedKeys.Add(ctx, feedA, "test comment")
r.NoError(err) r.NoError(err)
@ -118,7 +127,10 @@ func TestDeniedKeysByID(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("b33f"), 8), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("b33f"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
err = db.DeniedKeys.Add(ctx, feedA, "nope") err = db.DeniedKeys.Add(ctx, feedA, "nope")
r.NoError(err) r.NoError(err)

View File

@ -17,9 +17,9 @@ import (
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface
@ -35,7 +35,7 @@ type Invites struct {
// Create creates a new invite for a new member. It returns the token or an error. // Create creates a new invite for a new member. It returns the token or an error.
// createdBy is user ID of the admin or moderator who created it. // createdBy is user ID of the admin or moderator who created it.
// aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssb-ngi-pointer/rooms2/issues/21) // aliasSuggestion is optional (empty string is fine) but can be used to disambiguate open invites. (See https://github.com/ssbc/rooms2/issues/21)
// The returned token is base64 URL encoded and has inviteTokenLength when decoded. // The returned token is base64 URL encoded and has inviteTokenLength when decoded.
func (i Invites) Create(ctx context.Context, createdBy int64) (string, error) { func (i Invites) Create(ctx context.Context, createdBy int64) (string, error) {
var newInvite = models.Invite{ var newInvite = models.Invite{
@ -132,7 +132,7 @@ func (i Invites) Consume(ctx context.Context, token string, newMember refs.FeedR
_, err = i.members.add(ctx, tx, newMember, roomdb.RoleMember) _, err = i.members.add(ctx, tx, newMember, roomdb.RoleMember)
var alreadyAdded roomdb.ErrAlreadyAdded var alreadyAdded roomdb.ErrAlreadyAdded
if err != nil { if err != nil {
if errors.As(err, &alreadyAdded) && alreadyAdded.Ref.Equal(&newMember) { if errors.As(err, &alreadyAdded) && alreadyAdded.Ref.Equal(newMember) {
// it is fine to use an invite twice // it is fine to use an invite twice
} else { } else {
return err return err

View File

@ -16,9 +16,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/repo"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
func TestInvites(t *testing.T) { func TestInvites(t *testing.T) {
@ -29,7 +29,10 @@ func TestInvites(t *testing.T) {
tr := repo.New(testRepo) tr := repo.New(testRepo)
// fake feed for testing, looks ok at least // fake feed for testing, looks ok at least
newMember := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} newMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
@ -55,7 +58,10 @@ func TestInvites(t *testing.T) {
r.Error(err, "can't create invite for invalid user") r.Error(err, "can't create invite for invalid user")
}) })
invitingMember := refs.FeedRef{ID: bytes.Repeat([]byte("ohai"), 8), Algo: refs.RefAlgoFeedSSB1} invitingMember, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("ohai"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
mid, err := db.Members.Add(ctx, invitingMember, roomdb.RoleModerator) mid, err := db.Members.Add(ctx, invitingMember, roomdb.RoleModerator)
require.NoError(t, err, "failed to create test user") require.NoError(t, err, "failed to create test user")

View File

@ -11,11 +11,11 @@ import (
"github.com/friendsofgo/errors" "github.com/friendsofgo/errors"
"github.com/mattn/go-sqlite3" "github.com/mattn/go-sqlite3"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
refs "go.mindeco.de/ssb-refs"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface
@ -59,7 +59,7 @@ func (Members) add(ctx context.Context, tx *sql.Tx, pubKey refs.FeedRef, role ro
return -1, err return -1, err
} }
if _, err := refs.ParseFeedRef(pubKey.Ref()); err != nil { if _, err := refs.ParseFeedRef(pubKey.String()); err != nil {
return -1, err return -1, err
} }
@ -105,7 +105,7 @@ func (m Members) GetByID(ctx context.Context, mid int64) (roomdb.Member, error)
// GetByFeed returns the member if it exists // GetByFeed returns the member if it exists
func (m Members) GetByFeed(ctx context.Context, h refs.FeedRef) (roomdb.Member, error) { func (m Members) GetByFeed(ctx context.Context, h refs.FeedRef) (roomdb.Member, error) {
entry, err := models.Members(qm.Where("pub_key = ?", h.Ref())).One(ctx, m.db) entry, err := models.Members(qm.Where("pub_key = ?", h.String())).One(ctx, m.db)
if err != nil { if err != nil {
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return roomdb.Member{}, roomdb.ErrNotFound return roomdb.Member{}, roomdb.ErrNotFound
@ -156,7 +156,7 @@ func (m Members) Count(ctx context.Context) (uint, error) {
// RemoveFeed removes the feed from the list. // RemoveFeed removes the feed from the list.
func (m Members) RemoveFeed(ctx context.Context, r refs.FeedRef) error { func (m Members) RemoveFeed(ctx context.Context, r refs.FeedRef) error {
entry, err := models.Members(qm.Where("pub_key = ?", r.Ref())).One(ctx, m.db) entry, err := models.Members(qm.Where("pub_key = ?", r.String())).One(ctx, m.db)
if err != nil { if err != nil {
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return roomdb.ErrNotFound return roomdb.ErrNotFound

View File

@ -11,12 +11,12 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
refs "github.com/ssbc/go-ssb-refs"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
refs "go.mindeco.de/ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
func TestMembers(t *testing.T) { func TestMembers(t *testing.T) {
@ -32,12 +32,18 @@ func TestMembers(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// broken feed (unknown algo) // broken feed (unknown algo)
tf := refs.FeedRef{ID: bytes.Repeat([]byte("fooo"), 8), Algo: "nope"} tf, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("fooo"), 8), "nope")
if err != nil {
r.Error(err)
}
_, err = db.Members.Add(ctx, tf, roomdb.RoleMember) _, err = db.Members.Add(ctx, tf, roomdb.RoleMember)
r.Error(err) r.Error(err)
// looks ok at least // looks ok at least
okFeed := refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: refs.RefAlgoFeedSSB1} okFeed, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("acab"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
mid, err := db.Members.Add(ctx, okFeed, roomdb.RoleMember) mid, err := db.Members.Add(ctx, okFeed, roomdb.RoleMember)
r.NoError(err) r.NoError(err)
@ -57,7 +63,7 @@ func TestMembers(t *testing.T) {
r.NoError(err) r.NoError(err)
r.Equal(okMember.ID, mid) r.Equal(okMember.ID, mid)
r.Equal(okMember.Role, roomdb.RoleMember) r.Equal(okMember.Role, roomdb.RoleMember)
r.True(okMember.PubKey.Equal(&okFeed)) r.True(okMember.PubKey.Equal(okFeed))
_, yes = db.Members.GetByFeed(ctx, tf) _, yes = db.Members.GetByFeed(ctx, tf)
r.Error(yes) r.Error(yes)
@ -91,7 +97,10 @@ func TestMembersUnique(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
_, err = db.Members.Add(ctx, feedA, roomdb.RoleMember) _, err = db.Members.Add(ctx, feedA, roomdb.RoleMember)
r.NoError(err) r.NoError(err)
@ -117,7 +126,10 @@ func TestMembersByID(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
_, err = db.Members.Add(ctx, feedA, roomdb.RoleMember) _, err = db.Members.Add(ctx, feedA, roomdb.RoleMember)
r.NoError(err) r.NoError(err)
@ -157,12 +169,18 @@ func TestMembersSetRole(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// create two users // create two users
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1"), 32), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1"), 32), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
idA, err := db.Members.Add(ctx, feedA, roomdb.RoleAdmin) idA, err := db.Members.Add(ctx, feedA, roomdb.RoleAdmin)
r.NoError(err) r.NoError(err)
t.Log("member A:", idA) t.Log("member A:", idA)
feedB := refs.FeedRef{ID: bytes.Repeat([]byte("2"), 32), Algo: refs.RefAlgoFeedSSB1} feedB, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("2"), 32), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
idB, err := db.Members.Add(ctx, feedB, roomdb.RoleModerator) idB, err := db.Members.Add(ctx, feedB, roomdb.RoleModerator)
r.NoError(err) r.NoError(err)
t.Log("member B:", idB) t.Log("member B:", idB)
@ -238,7 +256,10 @@ func TestMembersAliases(t *testing.T) {
db, err := Open(tr) db, err := Open(tr)
require.NoError(t, err) require.NoError(t, err)
feedA := refs.FeedRef{ID: bytes.Repeat([]byte("1312"), 8), Algo: refs.RefAlgoFeedSSB1} feedA, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("1312"), 8), refs.RefAlgoFeedSSB1)
if err != nil {
r.Error(err)
}
mid, err := db.Members.Add(ctx, feedA, roomdb.RoleMember) mid, err := db.Members.Add(ctx, feedA, roomdb.RoleMember)
r.NoError(err) r.NoError(err)

View File

@ -17,7 +17,7 @@ import (
"time" "time"
"github.com/friendsofgo/errors" "github.com/friendsofgo/errors"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"

View File

@ -17,7 +17,7 @@ import (
"time" "time"
"github.com/friendsofgo/errors" "github.com/friendsofgo/errors"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"

View File

@ -17,7 +17,7 @@ import (
"time" "time"
"github.com/friendsofgo/errors" "github.com/friendsofgo/errors"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"

View File

@ -28,7 +28,7 @@ import (
migrate "github.com/rubenv/sql-migrate" migrate "github.com/rubenv/sql-migrate"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
) )
type Database struct { type Database struct {

View File

@ -12,7 +12,7 @@ import (
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
) )
// verify the database opens and migrates successfully from zero state // verify the database opens and migrates successfully from zero state

View File

@ -13,8 +13,8 @@ import (
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
) )
// compiler assertion to ensure the struct fullfills the interface // compiler assertion to ensure the struct fullfills the interface

View File

@ -12,8 +12,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -9,8 +9,8 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite/models" "github.com/ssbc/go-ssb-room/v2/roomdb/sqlite/models"
"github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/boil"
) )

View File

@ -10,9 +10,9 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -11,7 +11,7 @@ import (
"sort" "sort"
"time" "time"
refs "go.mindeco.de/ssb-refs" refs "github.com/ssbc/go-ssb-refs"
) )
// ErrNotFound is returned by the admin db if an object couldn't be found. // ErrNotFound is returned by the admin db if an object couldn't be found.
@ -169,7 +169,7 @@ type ErrAlreadyAdded struct {
} }
func (aa ErrAlreadyAdded) Error() string { func (aa ErrAlreadyAdded) Error() string {
return fmt.Sprintf("roomdb: the item (%s) is already on the list", aa.Ref.Ref()) return fmt.Sprintf("roomdb: the item (%s) is already on the list", aa.Ref.PubKey())
} }
// Invite is a combination of an invite id, who created it and when. // Invite is a combination of an invite id, who created it and when.
@ -205,14 +205,14 @@ func (r *DBFeedRef) Scan(src interface{}) error {
return err return err
} }
r.FeedRef = *fr r.FeedRef = fr
return nil return nil
} }
// Value returns feed references as strings to the database. // Value returns feed references as strings to the database.
// https://pkg.go.dev/database/sql/driver#Valuer // https://pkg.go.dev/database/sql/driver#Valuer
func (r DBFeedRef) Value() (driver.Value, error) { func (r DBFeedRef) Value() (driver.Value, error) {
return driver.Value(r.Ref()), nil return driver.Value(r.String()), nil
} }
// PinnedNoticeName holds a name of a well known part of the page with a fixed location. // PinnedNoticeName holds a name of a well known part of the page with a fixed location.

View File

@ -5,15 +5,15 @@
package roomsrv package roomsrv
import ( import (
muxrpc "go.cryptoscope.co/muxrpc/v2" muxrpc "github.com/ssbc/go-muxrpc/v2"
"go.cryptoscope.co/muxrpc/v2/typemux" "github.com/ssbc/go-muxrpc/v2/typemux"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/alias" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/alias"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/gossip" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/gossip"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/signinwithssb" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/whoami" "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/whoami"
) )
// instantiate and register the muxrpc handlers // instantiate and register the muxrpc handlers

View File

@ -8,10 +8,10 @@ import (
"fmt" "fmt"
"net" "net"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
) )
// opens the shs listener for TCP connections // opens the shs listener for TCP connections
@ -37,13 +37,13 @@ func (s *Server) initNetwork() error {
// if privacy mode is restricted, deny connections from non-members // if privacy mode is restricted, deny connections from non-members
if pm == roomdb.ModeRestricted { if pm == roomdb.ModeRestricted {
if _, err := s.Members.GetByFeed(s.rootCtx, *remote); err != nil { if _, err := s.Members.GetByFeed(s.rootCtx, remote); err != nil {
return nil, fmt.Errorf("access restricted to members") return nil, fmt.Errorf("access restricted to members")
} }
} }
// if feed is in the deny list, deny their connection // if feed is in the deny list, deny their connection
if s.DeniedKeys.HasFeed(s.rootCtx, *remote) { if s.DeniedKeys.HasFeed(s.rootCtx, remote) {
return nil, fmt.Errorf("this key has been banned") return nil, fmt.Errorf("this key has been banned")
} }

View File

@ -10,12 +10,12 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/netwraputil" "github.com/ssbc/go-ssb-room/v2/internal/netwraputil"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/repo"
) )
// WithUNIXSocket enables listening for muxrpc connections on a unix socket files ($repo/socket). // WithUNIXSocket enables listening for muxrpc connections on a unix socket files ($repo/socket).
@ -34,7 +34,7 @@ func (s *Server) initUnixSock() error {
if s.keyPair == nil { if s.keyPair == nil {
return fmt.Errorf("roomsrv/unixsock: keypair is nil. please use unixSocket with LateOption") return fmt.Errorf("roomsrv/unixsock: keypair is nil. please use unixSocket with LateOption")
} }
spoofWrapper := netwraputil.SpoofRemoteAddress(s.keyPair.Feed.ID) spoofWrapper := netwraputil.SpoofRemoteAddress(s.keyPair.Feed.PubKey())
r := repo.New(s.repoPath) r := repo.New(s.repoPath)
sockPath := r.GetPath("socket") sockPath := r.GetPath("socket")

View File

@ -9,7 +9,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
) )
type manifestHandler string type manifestHandler string

View File

@ -9,10 +9,10 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" "github.com/ssbc/go-netwrap"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/network"
"go.cryptoscope.co/netwrap" "github.com/ssbc/go-ssb-room/v2/internal/repo"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
) )

View File

@ -16,19 +16,19 @@ import (
"path/filepath" "path/filepath"
"sync" "sync"
"go.cryptoscope.co/muxrpc/v2/typemux" "github.com/ssbc/go-muxrpc/v2/typemux"
"go.cryptoscope.co/netwrap" "github.com/ssbc/go-netwrap"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multicloser" "github.com/ssbc/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/multicloser"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb" "github.com/ssbc/go-ssb-room/v2/internal/repo"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" "github.com/ssbc/go-ssb-room/v2/roomdb"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/roomstate"
) )
type Server struct { type Server struct {

View File

@ -9,11 +9,11 @@ import (
"sort" "sort"
"sync" "sync"
"go.cryptoscope.co/muxrpc/v2" "github.com/ssbc/go-muxrpc/v2"
kitlog "go.mindeco.de/log" kitlog "go.mindeco.de/log"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/broadcasts" refs "github.com/ssbc/go-ssb-refs"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/internal/broadcasts"
) )
type Manager struct { type Manager struct {
@ -79,7 +79,7 @@ func (m *Manager) ListAsRefs() []refs.FeedRef {
if err != nil { if err != nil {
panic(fmt.Errorf("invalid feed ref in room state: %d: %s", i, err)) panic(fmt.Errorf("invalid feed ref in room state: %d: %s", i, err))
} }
rlst[i] = *fr rlst[i] = fr
} }
return rlst return rlst
} }
@ -88,7 +88,7 @@ func (m *Manager) ListAsRefs() []refs.FeedRef {
func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) { func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) {
m.roomMu.Lock() m.roomMu.Lock()
// add ref to to the room map // add ref to to the room map
m.room[who.Ref()] = edp m.room[who.String()] = edp
currentMembers := m.room.AsList() currentMembers := m.room.AsList()
m.roomMu.Unlock() m.roomMu.Unlock()
// update all the connected tunnel.endpoints calls // update all the connected tunnel.endpoints calls
@ -101,7 +101,7 @@ func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) {
func (m *Manager) Remove(who refs.FeedRef) { func (m *Manager) Remove(who refs.FeedRef) {
m.roomMu.Lock() m.roomMu.Lock()
// remove ref from lobby // remove ref from lobby
delete(m.room, who.Ref()) delete(m.room, who.String())
currentMembers := m.room.AsList() currentMembers := m.room.AsList()
m.roomMu.Unlock() m.roomMu.Unlock()
// update all the connected tunnel.endpoints calls // update all the connected tunnel.endpoints calls
@ -117,10 +117,10 @@ func (m *Manager) AlreadyAdded(who refs.FeedRef, edp muxrpc.Endpoint) bool {
var currentMembers []string var currentMembers []string
// if the peer didn't call tunnel.announce() // if the peer didn't call tunnel.announce()
_, has := m.room[who.Ref()] _, has := m.room[who.String()]
if !has { if !has {
// register them as if they didnt // register them as if they didnt
m.room[who.Ref()] = edp m.room[who.String()] = edp
currentMembers = m.room.AsList() currentMembers = m.room.AsList()
} }
m.roomMu.Unlock() m.roomMu.Unlock()
@ -138,7 +138,7 @@ func (m *Manager) AlreadyAdded(who refs.FeedRef, edp muxrpc.Endpoint) bool {
func (m *Manager) Has(who refs.FeedRef) (muxrpc.Endpoint, bool) { func (m *Manager) Has(who refs.FeedRef) (muxrpc.Endpoint, bool) {
m.roomMu.Lock() m.roomMu.Lock()
// add ref to to the room map // add ref to to the room map
edp, has := m.room[who.Ref()] edp, has := m.room[who.String()]
m.roomMu.Unlock() m.roomMu.Unlock()
return edp, has return edp, has
} }

View File

@ -16,7 +16,7 @@ import (
const Production = false const Production = false
// absolute path of where this package is located // absolute path of where this package is located
var pkgDir = goutils.MustLocatePackage("github.com/ssb-ngi-pointer/go-ssb-room/v2/web") var pkgDir = goutils.MustLocatePackage("github.com/ssbc/go-ssb-room/v2/web")
var Templates = http.Dir(filepath.Join(pkgDir, "templates")) var Templates = http.Dir(filepath.Join(pkgDir, "templates"))

View File

@ -14,8 +14,8 @@ import (
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
"go.mindeco.de/logging" "go.mindeco.de/logging"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" "github.com/ssbc/go-ssb-room/v2/web/i18n"
) )
type ErrorHandler struct { type ErrorHandler struct {
@ -120,7 +120,7 @@ func localizeError(ih *i18n.Localizer, err error) (int, template.HTML) {
msg = ih.LocalizeSimple("ErrorNotFound") msg = ih.LocalizeSimple("ErrorNotFound")
case errors.As(err, &aa): case errors.As(err, &aa):
msg = ih.LocalizeWithData("ErrorAlreadyAdded", "Feed", aa.Ref.Ref()) msg = ih.LocalizeWithData("ErrorAlreadyAdded", "Feed", aa.Ref.String())
case errors.As(err, &pnf): case errors.As(err, &pnf):
code = http.StatusNotFound code = http.StatusNotFound

View File

@ -11,7 +11,7 @@ import (
"net/http" "net/http"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/i18n" "github.com/ssbc/go-ssb-room/v2/web/i18n"
) )
type FlashHelper struct { type FlashHelper struct {

View File

@ -12,9 +12,9 @@ import (
"github.com/gorilla/csrf" "github.com/gorilla/csrf"
"go.mindeco.de/http/render" "go.mindeco.de/http/render"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" weberrors "github.com/ssbc/go-ssb-room/v2/web/errors"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/members" "github.com/ssbc/go-ssb-room/v2/web/members"
) )
// aliasesHandler implements the managment endpoints for aliases (list and revoke), // aliasesHandler implements the managment endpoints for aliases (list and revoke),
@ -90,7 +90,7 @@ func (h aliasesHandler) revoke(rw http.ResponseWriter, req *http.Request) {
} }
// ensure own alias or admin // ensure own alias or admin
if !aliasEntry.Feed.Equal(&currentMember.PubKey) && currentMember.Role != roomdb.RoleAdmin { if !aliasEntry.Feed.Equal(currentMember.PubKey) && currentMember.Role != roomdb.RoleAdmin {
err := weberrors.ErrForbidden{Details: fmt.Errorf("not your alias or not an admin")} err := weberrors.ErrForbidden{Details: fmt.Errorf("not your alias or not an admin")}
h.flashes.AddError(rw, req, err) h.flashes.AddError(rw, req, err)
return return

View File

@ -11,10 +11,10 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" "github.com/ssbc/go-ssb-room/v2/web/router"
refs "go.mindeco.de/ssb-refs" "github.com/ssbc/go-ssb-room/v2/web/webassert"
) )
func TestAliasesRevokeConfirmation(t *testing.T) { func TestAliasesRevokeConfirmation(t *testing.T) {
@ -23,7 +23,7 @@ func TestAliasesRevokeConfirmation(t *testing.T) {
testKey, err := refs.ParseFeedRef("@x7iOLUcq3o+sjGeAnipvWeGzfuYgrXl8L4LYlxIhwDc=.ed25519") testKey, err := refs.ParseFeedRef("@x7iOLUcq3o+sjGeAnipvWeGzfuYgrXl8L4LYlxIhwDc=.ed25519")
a.NoError(err) a.NoError(err)
testEntry := roomdb.Alias{ID: 666, Name: "the-test-name", Feed: *testKey} testEntry := roomdb.Alias{ID: 666, Name: "the-test-name", Feed: testKey}
ts.AliasesDB.GetByIDReturns(testEntry, nil) ts.AliasesDB.GetByIDReturns(testEntry, nil)
urlRevokeConfirm := ts.URLTo(router.AdminAliasesRevokeConfirm, "id", 3) urlRevokeConfirm := ts.URLTo(router.AdminAliasesRevokeConfirm, "id", 3)
@ -31,7 +31,7 @@ func TestAliasesRevokeConfirmation(t *testing.T) {
html, resp := ts.Client.GetHTML(urlRevokeConfirm) html, resp := ts.Client.GetHTML(urlRevokeConfirm)
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code") a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
a.Equal(testKey.Ref(), html.Find("pre#verify").Text(), "has the key for verification") a.Equal(testKey.String(), html.Find("pre#verify").Text(), "has the key for verification")
form := html.Find("form#confirm") form := html.Find("form#confirm")

View File

@ -10,15 +10,15 @@ import (
"net/http" "net/http"
"time" "time"
refs "github.com/ssbc/go-ssb-refs"
"go.mindeco.de/http/render" "go.mindeco.de/http/render"
"go.mindeco.de/log/level" "go.mindeco.de/log/level"
"go.mindeco.de/logging" "go.mindeco.de/logging"
refs "go.mindeco.de/ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network" "github.com/ssbc/go-ssb-room/v2/internal/network"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate" "github.com/ssbc/go-ssb-room/v2/roomstate"
weberrors "github.com/ssb-ngi-pointer/go-ssb-room/v2/web/errors" weberrors "github.com/ssbc/go-ssb-room/v2/web/errors"
) )
type dashboardHandler struct { type dashboardHandler struct {
@ -34,7 +34,7 @@ func (h dashboardHandler) overview(w http.ResponseWriter, req *http.Request) (in
var ( var (
err error err error
ctx = req.Context() ctx = req.Context()
roomRef = h.netInfo.RoomID.Ref() roomRef = h.netInfo.RoomID.String()
onlineRefs []refs.FeedRef onlineRefs []refs.FeedRef
refsUpdateCh = make(chan []refs.FeedRef) refsUpdateCh = make(chan []refs.FeedRef)
@ -116,5 +116,5 @@ func (dm connectedUser) String() string {
if len(dm.Aliases) > 0 { if len(dm.Aliases) > 0 {
return dm.Aliases[0].Name return dm.Aliases[0].Name
} }
return dm.PubKey.Ref() return dm.PubKey.String()
} }

View File

@ -10,18 +10,21 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb" refs "github.com/ssbc/go-ssb-refs"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router" "github.com/ssbc/go-ssb-room/v2/roomdb"
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/webassert" "github.com/ssbc/go-ssb-room/v2/web/router"
"github.com/ssbc/go-ssb-room/v2/web/webassert"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
refs "go.mindeco.de/ssb-refs"
) )
func TestDashboardSimple(t *testing.T) { func TestDashboardSimple(t *testing.T) {
ts := newSession(t) ts := newSession(t)
a := assert.New(t) a := assert.New(t)
testRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{0}, 32)} testRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
ts.RoomState.AddEndpoint(testRef, nil) // 1 online ts.RoomState.AddEndpoint(testRef, nil) // 1 online
ts.MembersDB.CountReturns(4, nil) // 4 members ts.MembersDB.CountReturns(4, nil) // 4 members
ts.InvitesDB.CountReturns(3, nil) // 3 invites ts.InvitesDB.CountReturns(3, nil) // 3 invites
@ -47,15 +50,21 @@ func TestDashboardWithVisitors(t *testing.T) {
ts := newSession(t) ts := newSession(t)
a := assert.New(t) a := assert.New(t)
visitorRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{0}, 32)} visitorRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{0}, 32), refs.RefAlgoFeedSSB1)
memberRef := refs.FeedRef{Algo: "ed25519", ID: bytes.Repeat([]byte{1}, 32)} if err != nil {
t.Error(err)
}
memberRef, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1)
if err != nil {
t.Error(err)
}
ts.RoomState.AddEndpoint(visitorRef, nil) ts.RoomState.AddEndpoint(visitorRef, nil)
ts.RoomState.AddEndpoint(memberRef, nil) ts.RoomState.AddEndpoint(memberRef, nil)
ts.MembersDB.CountReturns(1, nil) ts.MembersDB.CountReturns(1, nil)
// return a member for the member but not for the visitor // return a member for the member but not for the visitor
ts.MembersDB.GetByFeedStub = func(ctx context.Context, r refs.FeedRef) (roomdb.Member, error) { ts.MembersDB.GetByFeedStub = func(ctx context.Context, r refs.FeedRef) (roomdb.Member, error) {
if r.Equal(&memberRef) { if r.Equal(memberRef) {
return roomdb.Member{ID: 23, Role: roomdb.RoleMember, PubKey: r}, nil return roomdb.Member{ID: 23, Role: roomdb.RoleMember, PubKey: r}, nil
} }
return roomdb.Member{}, roomdb.ErrNotFound return roomdb.Member{}, roomdb.ErrNotFound
@ -73,12 +82,12 @@ func TestDashboardWithVisitors(t *testing.T) {
a.Equal(2, memberList.Length()) a.Equal(2, memberList.Length())
htmlVisitor := memberList.Eq(0) htmlVisitor := memberList.Eq(0)
a.Equal(visitorRef.Ref(), htmlVisitor.Text()) a.Equal(visitorRef.String(), htmlVisitor.Text())
gotLink, has := htmlVisitor.Attr("href") gotLink, has := htmlVisitor.Attr("href")
a.False(has, "visitor should not have a link to a details page: %v", gotLink) a.False(has, "visitor should not have a link to a details page: %v", gotLink)
htmlMember := memberList.Eq(1) htmlMember := memberList.Eq(1)
a.Equal(memberRef.Ref(), htmlMember.Text()) a.Equal(memberRef.String(), htmlMember.Text())
gotLink, has = htmlMember.Attr("href") gotLink, has = htmlMember.Attr("href")
a.True(has, "member should have a link to a details page") a.True(has, "member should have a link to a details page")
wantLink := ts.URLTo(router.AdminMemberDetails, "id", 23) wantLink := ts.URLTo(router.AdminMemberDetails, "id", 23)

Some files were not shown because too many files have changed in this diff Show More