Compare commits
111
Commits
v2.0.5
...
coop-cloud
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b080502c7b | ||
|
|
6e89cc403e | ||
|
|
43eeea8a8d | ||
|
|
577529e642 | ||
|
|
c8411340be | ||
|
|
753e30690f | ||
|
|
ab664aafc3 | ||
|
|
0a5b6d13e4 | ||
|
|
e55f152905 | ||
|
|
5fa4744344 | ||
|
|
0c0f34dac9 | ||
|
|
aa9776924e | ||
|
|
78ca74fe7a | ||
|
|
e7eb4db759 | ||
|
|
b5c1a8c052
|
||
|
|
bac75715fc | ||
|
|
fe4c05474f | ||
|
|
c0efe13e0c | ||
|
|
eaf4229e5e | ||
|
|
10f2e44c87 | ||
|
|
71167234d8 | ||
|
|
6e2963c7ee | ||
|
|
88eb972e60 | ||
|
|
9126215e01 | ||
|
|
dc6ff365fb
|
||
|
|
58f44537bf
|
||
|
|
c9db01515c
|
||
|
|
2833558d94
|
||
|
|
3fcd61e1ca | ||
|
|
b81c03c837
|
||
|
|
aced1a2790
|
||
|
|
641069a8f1 | ||
|
|
0692aa27b9 | ||
|
|
6a7f74b047 | ||
|
|
0be5899235 | ||
|
|
2014016de3 | ||
|
|
6a7b7f2b66 | ||
|
|
f1645cd0f6 | ||
|
|
bf3a7a61bf
|
||
|
|
d169aaf137
|
||
|
|
ed71cda319
|
||
|
|
c506340a2d
|
||
|
|
00a1452cfc | ||
|
|
e3afd943c9 | ||
|
|
7abf0a07ed | ||
|
|
cecadc4402 | ||
|
|
0fa646ccdf | ||
|
|
72e7d68176 | ||
|
|
ea9b22cfa7 | ||
|
|
158e5129ba | ||
|
|
919fd552eb | ||
|
|
4b9fdf2eba | ||
|
|
26b8baefa0 | ||
|
|
cc41eae0e9 | ||
|
|
c16fceb3ce | ||
|
|
18062a2305 | ||
|
|
227efa6a79 | ||
|
|
6aaea32407 | ||
|
|
92681a9c49 | ||
|
|
0535ba14e0 | ||
|
|
761a3b7244 | ||
|
|
c4607e0367 | ||
|
|
d5bfa51970 | ||
|
|
7b1bf012dc | ||
|
|
49fa1fde14
|
||
|
|
e3cfbaf175
|
||
|
|
de4321dcb2 | ||
|
|
c87a69f907 | ||
|
|
114f1682a3 | ||
|
|
f09ca6aff3 | ||
|
|
c7430e7976 | ||
|
|
49aaff968f | ||
|
|
6f5edbaa43 | ||
|
|
e3cea25e25 | ||
|
|
dcb09e05ef | ||
|
|
47ae7bb39c | ||
|
|
5687fd5fa1 | ||
|
|
747f5123f3 | ||
|
|
3c6831d39a | ||
|
|
2d722f2098 | ||
|
|
8c9413d55d | ||
|
|
642022cb0a | ||
|
|
f6fca892ce | ||
|
|
ad3cf28cb2 | ||
|
|
794a8f9755 | ||
|
|
583bd81976 | ||
|
|
7b3a5852da | ||
|
|
a249fd8bee | ||
|
|
ec89a8ab34 | ||
|
|
694d9b2ac0 | ||
|
|
5dd18b4781 | ||
|
|
914a4f98e8 | ||
|
|
d056953438 | ||
|
|
bbfb64cd1c | ||
|
|
6313ee5546 | ||
|
|
72becc0ca2 | ||
|
|
499ee484e8 | ||
|
|
b3b2f59f90 | ||
|
|
5d3ccc7184 | ||
|
|
922fa34302 | ||
|
|
c673872548 | ||
|
|
7cdcc3db69 | ||
|
|
18320f9ed7 | ||
|
|
39116da6f7 | ||
|
|
93208fa1e3 | ||
|
|
dc801b291f | ||
|
|
7c068f2df1 | ||
|
|
a51e5327c8 | ||
|
|
8a19bc6806 | ||
|
|
d147d0642a | ||
|
|
45967a79cb |
@@ -0,0 +1,9 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
node_moduels
|
||||
ssb-go-room-secrets
|
||||
ssb-go-room-secrets/**/*
|
||||
.git
|
||||
.env
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: publish docker image
|
||||
steps:
|
||||
- name: build and publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username: 3wordchant
|
||||
password:
|
||||
from_secret: git_coopcloud_tech_token_3wc
|
||||
repo: git.coopcloud.tech/coop-cloud-chaos-patchs/go-ssb-room
|
||||
tags: latest
|
||||
registry: git.coopcloud.tech
|
||||
@@ -0,0 +1,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
HTTPS_DOMAIN=yourhttpsdomainhere
|
||||
ALIASES_AS_SUBDOMAINS=true
|
||||
# uncomment variable if you want to store data in a custom directory (required for default docker-compose setup)
|
||||
# REPO=/ssb-go-room-secrets
|
||||
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
name: Go
|
||||
|
||||
on:
|
||||
@@ -21,14 +25,17 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
|
||||
go-version: 1.17
|
||||
|
||||
- name: Get dependencies
|
||||
run: go get -v -t -d ./...
|
||||
|
||||
- name: Build smoke test
|
||||
run: go build ./cmd/...
|
||||
|
||||
- name: Build dev smoke test
|
||||
run: go build -tags dev ./cmd/...
|
||||
|
||||
- name: install node ssb-stack
|
||||
run: |
|
||||
pushd muxrpc/test/nodejs
|
||||
@@ -50,4 +57,3 @@ jobs:
|
||||
with:
|
||||
commit_message: update production style.css
|
||||
file_pattern: web/assets/style.css
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# vim
|
||||
.*.sw[a-z]
|
||||
|
||||
@@ -11,9 +15,14 @@ muxrpc/test/nodejs/testrun
|
||||
web/handlers/testrun
|
||||
web/handlers/admin/testrun
|
||||
roomdb/sqlite/testrun
|
||||
web/i18n/i18ntesting/testrun/
|
||||
|
||||
# build artifacts from node.js project web/styles
|
||||
node_modules
|
||||
|
||||
# goreleaser output
|
||||
dist/
|
||||
|
||||
# secrets and config
|
||||
ssb-go-room-secrets/
|
||||
.env
|
||||
|
||||
+84
-12
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
@@ -5,7 +9,8 @@ before:
|
||||
- go generate ./...
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- id: go-ssb-room-linux-amd64
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
main: ./cmd/server
|
||||
@@ -15,11 +20,82 @@ builds:
|
||||
goarch:
|
||||
- amd64
|
||||
|
||||
- id: go-ssb-room-insert-user-linux-amd64
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
main: ./cmd/insert-user
|
||||
binary: go-ssb-room-insert-user
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
|
||||
- id: go-ssb-room-linux-arm64
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
# cross-compilation
|
||||
- CC=aarch64-linux-gnu-gcc
|
||||
- CXX=aarch64-linux-gnu-g++
|
||||
main: ./cmd/server
|
||||
binary: go-ssb-room
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm64
|
||||
|
||||
- id: go-ssb-room-insert-user-linux-arm64
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
# cross-compilation
|
||||
- CC=aarch64-linux-gnu-gcc
|
||||
- CXX=aarch64-linux-gnu-g++
|
||||
main: ./cmd/insert-user
|
||||
binary: go-ssb-room-insert-user
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm64
|
||||
|
||||
- id: go-ssb-room-linux-armhf
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
# cross-compilation
|
||||
- CC=arm-linux-gnueabihf-gcc
|
||||
- CXX=arm-linux-gnueabihf--g++
|
||||
main: ./cmd/server
|
||||
binary: go-ssb-room
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm
|
||||
goarm:
|
||||
- 6
|
||||
- 7
|
||||
|
||||
- id: go-ssb-room-insert-user-linux-armhf
|
||||
env:
|
||||
# needed for sqlite
|
||||
- CGO_ENABLED=1
|
||||
# cross-compilation
|
||||
- CC=arm-linux-gnueabihf-gcc
|
||||
- CXX=arm-linux-gnueabihf--g++
|
||||
main: ./cmd/insert-user
|
||||
binary: go-ssb-room-insert-user
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- arm
|
||||
goarm:
|
||||
- 6
|
||||
- 7
|
||||
|
||||
gomod:
|
||||
# sum.golang.org somehow doesn't handle replace as expected. TODO: file issue
|
||||
proxy: false
|
||||
env:
|
||||
- GOPROXY=https://proxy.golang.org,direct
|
||||
- GOPROXY=https://proxy.golang.org
|
||||
- GOSUMDB=sum.golang.org
|
||||
|
||||
# for .deb packages
|
||||
@@ -27,9 +103,6 @@ gomod:
|
||||
nfpms:
|
||||
- id: go-ssb-room
|
||||
package_name: go-ssb-room
|
||||
replacements:
|
||||
linux: Linux
|
||||
amd64: x86_64
|
||||
vendor: Secure-Scuttlebutt Community
|
||||
maintainer: Go-SSB-Room NGI-Pointer Team <go-ssb-room@ssb-ngi-pointer.email>
|
||||
homepage: https://scuttlebutt.nz
|
||||
@@ -40,9 +113,10 @@ nfpms:
|
||||
suggests:
|
||||
- ngingx
|
||||
- certbot
|
||||
empty_folders:
|
||||
- /var/log/go-ssb-room
|
||||
contents:
|
||||
- dst: /var/log/go-ssb-room
|
||||
type: dir
|
||||
|
||||
- src: docs/files/example-systemd.service
|
||||
dst: /etc/systemd/system/go-ssb-room.service
|
||||
type: "config|noreplace"
|
||||
@@ -60,9 +134,7 @@ nfpms:
|
||||
preremove: docs/files/debian-preremove.sh
|
||||
|
||||
archives:
|
||||
- replacements:
|
||||
linux: Linux
|
||||
amd64: x86_64
|
||||
- id: go-ssb-room
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: go-ssb-room
|
||||
Upstream-Contact: Andre 'Staltz' Medeiros <contact@staltz.com>
|
||||
Source: https://gitlab.com/ssb-ngi-pointer/go-ssb-room-archived
|
||||
|
||||
Files: web/assets/style.css
|
||||
Copyright: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
License: CC-BY-4.0
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
FROM golang:1.17-alpine
|
||||
|
||||
RUN apk add --no-cache \
|
||||
build-base \
|
||||
git \
|
||||
sqlite \
|
||||
sqlite-dev
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
RUN cd /app/cmd/server && go build && \
|
||||
cd /app/cmd/insert-user && go build
|
||||
|
||||
EXPOSE 8008
|
||||
EXPOSE 3000
|
||||
|
||||
RUN apk del \
|
||||
build-base \
|
||||
git
|
||||
|
||||
CMD ./start.sh
|
||||
@@ -0,0 +1,156 @@
|
||||
Creative Commons Attribution 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
|
||||
|
||||
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
Section 1 – Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
|
||||
Section 2 – Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part; and
|
||||
|
||||
B. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
|
||||
|
||||
Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
|
||||
|
||||
Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
|
||||
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
@@ -0,0 +1,121 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,10 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
@@ -1,24 +1,35 @@
|
||||
# Go-SSB Room
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fssb-ngi-pointer%2Fgo-ssb-room?ref=badge_shield)
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
This repository contains code for a [Secure Scuttlebutt](https://ssb.nz) [Room (v1+v2) server](https://github.com/ssb-ngi-pointer/rooms2), written in Go.
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# Go-SSB Room
|
||||
[](https://api.reuse.software/info/github.com/ssbc/go-ssb-room)
|
||||
|
||||
This repository implements the [Room (v1+v2) server spec](https://github.com/ssbc/rooms2), in Go.
|
||||
|
||||
It includes:
|
||||
* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/cryptoscope/secretstream)
|
||||
* secret-handshake+boxstream network transport, sometimes referred to as SHS, using [secretstream](https://github.com/ssbc/go-secretstream)
|
||||
* muxrpc handlers for tunneling connections
|
||||
* a fully embedded HTTP server & HTML frontend, for administering the room
|
||||
|
||||

|
||||
|
||||
See [this project](https://github.com/orgs/ssbc/projects/2) for current focus.
|
||||
|
||||
## :star: Features
|
||||
|
||||
* Rooms v1 (`tunnel.connect`, `tunnel.endpoints`, etc.)
|
||||
* User management (allow- & denylisting + moderator & administrator roles), all administered via the web dashboard
|
||||
* Multiple [privacy modes](https://ssb-ngi-pointer.github.io/rooms2/#privacy-modes)
|
||||
* [Sign-in with SSB](https://ssb-ngi-pointer.github.io/ssb-http-auth-spec/)
|
||||
* [HTTP Invites](https://github.com/ssb-ngi-pointer/ssb-http-invite-spec)
|
||||
* Multiple [privacy modes](https://ssbc.github.io/rooms2/#privacy-modes)
|
||||
* [Sign-in with SSB](https://ssbc.github.io/ssb-http-auth-spec/)
|
||||
* [HTTP Invites](https://github.com/ssbc/ssb-http-invite-spec)
|
||||
* Alias management
|
||||
|
||||
For a comprehensive introduction to rooms 2.0, 🎥 [watch this video](https://www.youtube.com/watch?v=W5p0y_MWwDE).
|
||||
For a description of MuxRPC APIs see https://github.com/ssbc/rooms2
|
||||
|
||||
## :rocket: Deployment
|
||||
|
||||
If you want to deploy a room server yourself, follow our [deployment.md](./docs/deployment.md) docs.
|
||||
@@ -36,5 +47,3 @@ For an in-depth codebase walkthrough, see the [development.md](./docs/developmen
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fssb-ngi-pointer%2Fgo-ssb-room?ref=badge_large)
|
||||
@@ -1,3 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
id=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w0)
|
||||
echo "@${id}.ed25519"
|
||||
|
||||
+17
-8
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// insert-user is a utility to create a new member and fallback password for them
|
||||
@@ -17,10 +19,10 @@ import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -32,7 +34,7 @@ func main() {
|
||||
repoPath string
|
||||
)
|
||||
|
||||
flag.StringVar(&repoPath, "repo", filepath.Join(u.HomeDir, ".ssb-go-room"), "[optional] where the locally stored files of the room is located")
|
||||
flag.StringVar(&repoPath, "repo", filepath.Join(u.HomeDir, ".ssb-go-room"), "[optional] where the locally stored files of the room are located")
|
||||
flag.Func("role", "[optional] which role the new member should have (values: mod[erator], admin, or member. default is admin)", func(val string) error {
|
||||
switch strings.ToLower(val) {
|
||||
case "admin":
|
||||
@@ -51,6 +53,13 @@ func main() {
|
||||
})
|
||||
flag.Parse()
|
||||
|
||||
if _, err := os.Stat(repoPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Fprintf(os.Stderr, "error: %s does not exist (-repo)?\n", repoPath)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// we require one more argument which is not a flag.
|
||||
if len(flag.Args()) != 1 {
|
||||
cliMissingArguments("please provide a public key")
|
||||
@@ -58,7 +67,7 @@ func main() {
|
||||
|
||||
pubKey, err := refs.ParseFeedRef(flag.Arg(0))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Invalid ssb public-key referenfce:", err)
|
||||
fmt.Fprintln(os.Stderr, "Invalid ssb public-key reference:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -67,7 +76,7 @@ func main() {
|
||||
check(err)
|
||||
defer db.Close()
|
||||
|
||||
fmt.Fprintln(os.Stderr, "Enter Password: ")
|
||||
fmt.Fprintln(os.Stderr, "Choose a password to be able to log into the web frontend: ")
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
check(err)
|
||||
|
||||
@@ -81,7 +90,7 @@ func main() {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
mid, err := db.Members.Add(ctx, *pubKey, role)
|
||||
mid, err := db.Members.Add(ctx, pubKey, role)
|
||||
check(err)
|
||||
|
||||
err = db.AuthFallback.SetPassword(ctx, mid, string(bytePassword))
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// +build dev
|
||||
|
||||
package main
|
||||
|
||||
+14
-12
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// go-roomsrv hosts the database and p2p server for replication.
|
||||
@@ -24,26 +26,26 @@ import (
|
||||
_ "net/http/pprof"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/ssbc/go-muxrpc/v2/debug"
|
||||
"github.com/throttled/throttled/v2"
|
||||
"github.com/throttled/throttled/v2/store/memstore"
|
||||
"github.com/unrolled/secure"
|
||||
"go.cryptoscope.co/muxrpc/v2/debug"
|
||||
kitlog "go.mindeco.de/log"
|
||||
"go.mindeco.de/log/level"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
|
||||
mksrv "github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/handlers"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
mksrv "github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
"github.com/ssbc/go-ssb-room/v2/web/handlers"
|
||||
)
|
||||
|
||||
// Version and Build are set by ldflags
|
||||
var (
|
||||
version = "v2.0.5"
|
||||
version = "v2.0.7"
|
||||
commit = "unset"
|
||||
)
|
||||
|
||||
@@ -90,7 +92,7 @@ func initFlags() {
|
||||
u, err := user.Current()
|
||||
checkFatal(err)
|
||||
|
||||
flag.StringVar(&appKey, "shscap", "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=", "secret-handshake app-key (or capability)")
|
||||
flag.StringVar(&appKey, "shscap", "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=", "secret-handshake app-key or capability; should likely not be changed as this makes you part of a different network")
|
||||
|
||||
flag.StringVar(&listenAddrShsMux, "lismux", ":8008", "address to listen on for secret-handshake+muxrpc")
|
||||
flag.StringVar(&listenAddrHTTP, "lishttp", ":3000", "address to listen on for HTTP requests")
|
||||
@@ -373,7 +375,7 @@ func runroomsrv() error {
|
||||
// all init was successfull
|
||||
level.Info(log).Log(
|
||||
"event", "serving",
|
||||
"ID", roomsrv.Whoami().Ref(),
|
||||
"ID", roomsrv.Whoami().String(),
|
||||
"shsmuxaddr", listenAddrShsMux,
|
||||
"httpaddr", listenAddrHTTP,
|
||||
"version", version, "commit", commit,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// +build !dev
|
||||
|
||||
package main
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
version: '3'
|
||||
services:
|
||||
room:
|
||||
build: .
|
||||
command: 'sh start.sh'
|
||||
env_file: .env
|
||||
ports:
|
||||
- "3000:3000" # Proxypass this port through NGINX or Apache as your HTTP landing & dashboard page
|
||||
- "0.0.0.0:8008:8008" # This is the port SSB clients connect to
|
||||
volumes:
|
||||
- ./ssb-go-room-secrets:/ssb-go-room-secrets
|
||||
@@ -1,3 +1,9 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [**Deployment**](./deployment.md)
|
||||
|
||||
+10
-4
@@ -1,11 +1,17 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# Architecture
|
||||
|
||||
## Invite flow
|
||||
|
||||
This implementation of Rooms 2.0 is compliant with the [Rooms 2.0
|
||||
specification](https://github.com/ssb-ngi-pointer/rooms2), but we add a few additional features
|
||||
specification](https://github.com/ssbc/rooms2), but we add a few additional features
|
||||
and pages in order to improve user experience when their SSB app does not support [SSB
|
||||
URIs](https://github.com/ssb-ngi-pointer/ssb-uri-spec).
|
||||
URIs](https://github.com/ssbc/ssb-uri-spec).
|
||||
|
||||
A summary can be seen in the following chart:
|
||||
|
||||
@@ -19,7 +25,7 @@ in a form.
|
||||
## Sign-in flow
|
||||
|
||||
This implementation is compliant with [SSB HTTP
|
||||
Authentication](https://github.com/ssb-ngi-pointer/ssb-http-auth-spec), but we add a few
|
||||
Authentication](https://github.com/ssbc/ssb-http-auth-spec), but we add a few
|
||||
additional features and pages in order to improve user experience. For instance, besides
|
||||
conventional SSB HTTP Auth, we also render a QR code to sign-in with a remote SSB app (an SSB
|
||||
identity not on the device that has the browser open). We also support sign-in with
|
||||
@@ -27,4 +33,4 @@ username/password, what we call "fallback authentication".
|
||||
|
||||
A summary can be seen in the following chart:
|
||||
|
||||

|
||||

|
||||
|
||||
+128
-9
@@ -1,26 +1,73 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# Getting Started
|
||||
|
||||
There are two paths to starting your own room: creating a build from source, or downloading one
|
||||
of the premade releases.
|
||||
|
||||
## Premade builds
|
||||
|
||||
See the [releases page](https://github.com/ssb-ngi-pointer/go-ssb-room/releases) for packaged linux releases.
|
||||
See the [releases page](https://github.com/ssbc/go-ssb-room/releases) for packaged linux releases.
|
||||
|
||||
We currently only distributed pre-packaged releases for Debian-compatible distributions.
|
||||
See [Issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) for the details.
|
||||
See [Issue #79](https://github.com/ssbc/go-ssb-room/issues/79) for the details.
|
||||
If this doesn't work for you, read the "Creating a build" section below.
|
||||
|
||||
After running `sudo dpkg -i go-ssb-room_v1.2.3_Linux_x86_64.deb` pay special attention to the
|
||||
After running `sudo dpkg -i go-ssb-room_v1.2.3_linux_amd64.deb` pay special attention to the
|
||||
[postinstall notes](./files/debian-postinstall.sh) for how to configure the systemd file and webserver.
|
||||
|
||||
## Creating a build
|
||||
|
||||
* [Download Go](https://golang.org/doc/install) & [set up your Go environment](https://golang.org/doc/install#install). You will need at least Go v1.16.
|
||||
* Download the repository `git clone git@github.com:ssb-ngi-pointer/go-ssb-room.git && cd go-ssb-room`
|
||||
* [Download Go](https://golang.org/doc/install) & [set up your Go environment](https://golang.org/doc/install#install). You will need at least Go v1.17.
|
||||
* Download the repository `git clone git@github.com:ssbc/go-ssb-room.git && cd go-ssb-room`
|
||||
* [Follow the development instructions](./development.md)
|
||||
* You should now have a working go-ssb-room binary! Read the HTTP Hosting section below and admin
|
||||
user sections below, for more instructions on the last mile.
|
||||
|
||||
# Docker & Docker-compose
|
||||
|
||||
This project includes a docker-compose.yml file as well as a Docker file. Using
|
||||
it should be fairly straight forward.
|
||||
|
||||
Start off by making a copy of `.env_example` called `.env` and insert your
|
||||
website domain there. With that done execute
|
||||
|
||||
```
|
||||
docker-compose build room
|
||||
```
|
||||
|
||||
Followed by
|
||||
|
||||
```
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
Your database, secrets and other things will be synchronized to a folder in your
|
||||
project called "docker-secrets".
|
||||
|
||||
After starting your server for the first time you need to enter your running
|
||||
server to insert your first user (your docker-compose up should be active).
|
||||
You can do this by:
|
||||
|
||||
```
|
||||
docker-compose exec room sh
|
||||
```
|
||||
|
||||
Then inside the virtual machine:
|
||||
|
||||
```
|
||||
/app/cmd/insert-user/insert-user -repo /ssb-go-room-secrets @your-own-ssb-public-key
|
||||
```
|
||||
|
||||
Fill in your password and then exit your instance by typing `exit`.
|
||||
|
||||
You should setup Nginx or HTTPS load-balancing outside the docker-compose
|
||||
instance.
|
||||
|
||||
# HTTP Hosting
|
||||
|
||||
We currently assume a standard HTTPS server in front of go-ssb-room to facilitate TLS
|
||||
@@ -30,10 +77,10 @@ proxying](https://en.wikipedia.org/wiki/Reverse_proxy).
|
||||
|
||||
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
|
||||
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).
|
||||
listen on port :443—blocking the use of other domains on the same IP.
|
||||
2. Listening on :443 can be pretty annoying (you might need root privileges or similar capabilities).
|
||||
|
||||
go-ssb-room needs three headers to function properly, which need to be forwarded by the
|
||||
webserver.
|
||||
@@ -49,9 +96,75 @@ follow the steps in [this
|
||||
article](https://medium.com/@alitou/getting-a-wildcard-ssl-certificate-using-certbot-and-deploy-on-nginx-15b8ffa34157),
|
||||
which uses the [certbot](https://certbot.eff.org/) utility.
|
||||
|
||||
For example, to get a wildcard SSL certificate for `hermies.club`, we typically run
|
||||
|
||||
```
|
||||
certbot certonly --manual --server https://acme-v02.api.letsencrypt.org/directory \
|
||||
--preferred-challenges dns-01 \
|
||||
-d 'hermies.club' -d '*.hermies.club'
|
||||
```
|
||||
|
||||
(Replace `hermies.club` with your room's domain, of course)
|
||||
|
||||
`certbot` will tell you to update TXT DNS records with the key `_acme-challenge.hermies.club` but be
|
||||
carefully with your DNS provider because you may have to input just `_acme-challenge` since the rest
|
||||
is often added automatically by your provider.
|
||||
|
||||
When the process is complete with `certbot`, pay attention to where the certificate has been placed
|
||||
in the filesystem. If it's at `/etc/letsencrypt/live/hermies.club`, it's correct, otherwise you may
|
||||
need to rename it e.g. `hermies.club-0001` to `hermies.club`.
|
||||
|
||||
The example nginx configuration uses prebuilt Diffie-Hellman parameters. You can generate these
|
||||
with the following command:
|
||||
|
||||
```
|
||||
openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048
|
||||
```
|
||||
|
||||
Then restart your server, e.g. `systemctl restart nginx`.
|
||||
|
||||
If you see such errors as the following when setting up your deployment:
|
||||
|
||||
```
|
||||
nginx: [emerg] unknown "connection_upgrade" variable
|
||||
```
|
||||
|
||||
You may need to configure `$connection_upgrade` in your
|
||||
`/etc/nginx/nginx.conf`. See [this
|
||||
article](https://futurestud.io/tutorials/nginx-how-to-fix-unknown-connection_upgrade-variable)
|
||||
for more.
|
||||
|
||||
## Enable TCP ports
|
||||
|
||||
For your room to fully work the following **TCP** ports need to be allowed:
|
||||
|
||||
- 80 (HTTP)
|
||||
- 443 (HTTPS)
|
||||
- 8008 (SSB)
|
||||
|
||||
### Example
|
||||
|
||||
Using a Debian-compatible distribution with `ufw`, execute the commands below:
|
||||
|
||||
```bash
|
||||
sudo ufw allow http
|
||||
sudo ufw allow https
|
||||
sudo ufw allow 8008/tcp
|
||||
```
|
||||
|
||||
|
||||
# First Admin user
|
||||
|
||||
To manage your now working server, you need an initial admin user. For this you can use the "insert-user" utility included with go-ssb-room.
|
||||
|
||||
If you installed the Debian package, you will first need to install Go to build the "insert-user" utility. You can do this via:
|
||||
|
||||
```
|
||||
sudo apt-get install golang-go
|
||||
```
|
||||
|
||||
(**WARNING**: please check that `golang-go` is >= 1.17 and if not, you may need to use the [official installation documentation](https://go.dev/dl/) instead. `go-ssb-room` requires at least Go 1.17.)
|
||||
|
||||
In a new terminal window navigate to the insert-user utility folder and compile the GO-based utility into an executable your computer can use
|
||||
|
||||
```
|
||||
@@ -68,4 +181,10 @@ example (with custom repo location, only needed if you setup your with a custom
|
||||
./insert-user -repo "/ssb-go-room-secrets" "@Bp5Z5TQKv6E/Y+QZn/3LiDWMPi63EP8MHsXZ4tiIb2w=.ed25519"
|
||||
```
|
||||
|
||||
You can now login in the web-front-end using these credentials
|
||||
Or if you installed go-ssb-room using the Debian package:
|
||||
|
||||
```
|
||||
sudo ./insert-user -repo "/var/lib/go-ssb-room" "@Bp5Z5TQKv6E/Y+QZn/3LiDWMPi63EP8MHsXZ4tiIb2w=.ed25519"
|
||||
```
|
||||
|
||||
It will ask you to create a password to access the web-front-end. You can now login in the web-front-end using these credentials.
|
||||
|
||||
+21
-13
@@ -1,6 +1,12 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
## Development notes
|
||||
|
||||
To get started, you need a recent version of [Go](https://golang.org). v1.16 and onward should be sufficient.
|
||||
To get started, you need a recent version of [Go](https://golang.org). v1.17 and onward should be sufficient.
|
||||
|
||||
Also, if you want to develop the CSS and HTML on the website, you need Node.js v14 in order to compile Tailwind.
|
||||
|
||||
@@ -31,7 +37,7 @@ Usage of ./server:
|
||||
-repo string
|
||||
where to put the log and indexes (default "~/.ssb-go-room")
|
||||
-shscap string
|
||||
secret-handshake app-key (or capability) (default "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=")
|
||||
secret-handshake app-key or capability; should likely not be changed as this makes you part of a different network (default "1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=")
|
||||
-version
|
||||
print version number and build date
|
||||
|
||||
@@ -60,11 +66,11 @@ Once you are done with your changes and want to update the embedded assets to th
|
||||
# cd to the root of the folder, and then run go generate
|
||||
go generate ./...
|
||||
# now build the server without the development mode
|
||||
cd cmd/server && go build && ./server -htts-domain my.room.example
|
||||
cd cmd/server && go build && ./server -htts-domain=my.room.example
|
||||
```
|
||||
|
||||
|
||||
## Tooling
|
||||
|
||||
### Mocks
|
||||
|
||||
[`counterfeiter`](https://github.com/maxbrunsfeld/counterfeiter) enables generating mocks for defined interfaces. To update the mocks, run `go generate` in package roomdb.
|
||||
@@ -104,7 +110,7 @@ cd cmd/insert-user
|
||||
go build
|
||||
# optional step: run a script to generate a valid ssb id @<pubkey>.ed25519, useful for trying things out quickly
|
||||
./generate-fake-id.sh
|
||||
./insert-user -login <username> -key <@pubkey.ed25519>
|
||||
./insert-user <@pubkey.ed25519>
|
||||
```
|
||||
Then repeat your password twice and you are all set for development.
|
||||
|
||||
@@ -120,12 +126,14 @@ See the [testing.md](./testing.md) for a thorough walkthorugh of the different t
|
||||
|
||||
## Release packaging
|
||||
|
||||
Because of [issue #79](https://github.com/ssb-ngi-pointer/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows:
|
||||
Because of [issue #79](https://github.com/ssbc/go-ssb-room/issues/79) we can't simply create binaries for all platforms independantly. Therefore binaries for re-distributions need to be created on the relevant distributions themselvs. We currently do this for debian. The process is as follows:
|
||||
|
||||
1) Install a recent debian stable version onto a dedicated machine or VM for instance (docker might also be possible).
|
||||
2) Install [Go](https://golang.org/doc/install).
|
||||
3) Install a C compiler (`sudo apt install gcc` for instance) for the CGo based sqlite dependency.
|
||||
4) Install [GoReleaser](https://goreleaser.com/install/).
|
||||
5) Create a version tag in git.
|
||||
6) run `goreleaser release` at the root of the repo to create the `dist/` folder with the `.deb` file.
|
||||
7) Upload the built packages.
|
||||
1. Install a recent debian stable version onto a dedicated machine or VM for instance (docker might also be possible).
|
||||
1. Install [Go](https://golang.org/doc/install).
|
||||
1. Install a C compiler (`sudo apt install gcc` for instance) for the CGo based sqlite dependency.
|
||||
1. Install a compiler which supports cross-compilation for ARM* architectures (`sudo apt install gccgo-aarch64-linux-gnu gccgo-arm-linux-gnueabihf`).
|
||||
1. Install Node.js v14 and install the dependencies (`cd ./web/styles && npm ci`, you may need to `npm install postcss` also).
|
||||
1. Install [GoReleaser](https://goreleaser.com/install/).
|
||||
1. Create a version tag in git.
|
||||
1. Run `goreleaser release` at the root of the repo to create the `dist/` folder with the `.deb` file.
|
||||
1. Upload the built packages.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
# create a user to run the server as
|
||||
adduser --system --home /var/lib/go-ssb-room go-ssb-room
|
||||
chown go-ssb-room /var/lib/go-ssb-room
|
||||
@@ -12,12 +16,12 @@ It will store it's files (roomdb and cookie secrets) under /var/lib/go-ssb-room.
|
||||
This is also where you would put custom translations.
|
||||
|
||||
For more configuration background see /usr/share/go-ssb-room/README.md
|
||||
or visit the code repo at https://github.com/ssb-ngi-pointer/go-ssb-room/tree/master/docs
|
||||
or visit the code repo at https://github.com/ssbc/go-ssb-room/tree/master/docs
|
||||
|
||||
Like outlined in that document, we highly encourage using nginx with certbot for TLS termination.
|
||||
We also supply an example config for this. You can find it under /usr/share/go-ssb-room/nginx-example.conf
|
||||
|
||||
> Important
|
||||
> Important
|
||||
|
||||
Before you start using room server via the systemd service, you need to at least change the https domain in the systemd service.
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
systemctl stop go-ssb-room
|
||||
systemctl disable go-ssb-room
|
||||
# TODO: we might want to have a proper config file so users dont need to tweak this file, then we can also remove and upgrade it properly
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
server {
|
||||
server_name hermies.club;
|
||||
|
||||
@@ -17,6 +21,8 @@ server {
|
||||
# for websocket
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
# requires a $connection_upgrade definition in /etc/nginx/nginx.conf
|
||||
# see https://futurestud.io/tutorials/nginx-how-to-fix-unknown-connection_upgrade-variable
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
|
||||
@@ -66,4 +72,4 @@ server {
|
||||
listen [::]:80 default_server;
|
||||
server_name hermies.club;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
[Unit]
|
||||
Description="The showcase v2 room"
|
||||
After=network.target
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC-BY-4.0
|
||||
+30
-10
@@ -1,9 +1,25 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# Testing
|
||||
`go-ssb-room` has a variety of tests to ensure that functionality that once worked, keeps
|
||||
working (it does not regress.) These tests are scattered around the repositories modules, but
|
||||
they are always contained in a file ending with `_test.go`—a compiler-enforced naming
|
||||
convention for Golang tests.
|
||||
|
||||
## Running all tests
|
||||
|
||||
You'll need to have Node.js v14 installed before running this.
|
||||
|
||||
```
|
||||
go test ./...
|
||||
```
|
||||
|
||||
This command can be run at the root of the repository.
|
||||
|
||||
## Structure
|
||||
Most routes are focused on administrating the room server. Tasks such as adding new users,
|
||||
editing notices (like the _Welcome_ or _Code of Conduct_ pages). These are routes that require
|
||||
@@ -21,21 +37,25 @@ The frontend tests—tests that check for the presence of various elements on se
|
||||
the module [`goquery`](https://github.com/PuerkitoBio/goquery) for querying the returned HTML.
|
||||
|
||||
## Snippets
|
||||
|
||||
#### Print the raw html of the corresponding page
|
||||
|
||||
```
|
||||
html, _ := ts.Client.GetHTML(url)
|
||||
fmt.Println(html.Html())
|
||||
html, _ := ts.Client.GetHTML(url)
|
||||
fmt.Println(html.Html())
|
||||
```
|
||||
|
||||
#### Find and print the `title` element of a page
|
||||
|
||||
```
|
||||
html, _ := ts.Client.GetHTML(url)
|
||||
title := html.Find("title")
|
||||
// print the title string
|
||||
fmt.Println(title.Text())
|
||||
html, _ := ts.Client.GetHTML(url)
|
||||
title := html.Find("title")
|
||||
// print the title string
|
||||
fmt.Println(title.Text())
|
||||
```
|
||||
|
||||
## Filling the mockdb
|
||||
|
||||
`go-ssb-room` uses database mocks for performing tests against the backend database logic. This
|
||||
means prefilling a route with the data you expect to be returned when the route is queried.
|
||||
This type of testing is an alternative to using an entire pre-filled sqlite database of test
|
||||
@@ -43,7 +63,7 @@ data.
|
||||
|
||||
As such, there is no command you run first to generate your fake database, but
|
||||
functions you have to call in a kind of pre-test setup, inside each testing
|
||||
block you are authoring.
|
||||
block you are authoring.
|
||||
|
||||
> [counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) generates a bunch of methods for each function, so you have
|
||||
> XXXXReturns, XXXCallCount XXXArgsForCall(i) etc
|
||||
@@ -56,6 +76,7 @@ That is, for a function `GetUID` there is a corresponding mock-filling function
|
||||
The following examples show more concretely what mocking the data looks like.
|
||||
|
||||
**Having the List() function return a static list of three items:**
|
||||
|
||||
```go
|
||||
// go-ssb-room/web/handlers/admin/allow_list_test.go:113
|
||||
lst := roomdb.ListEntries{
|
||||
@@ -64,10 +85,10 @@ lst := roomdb.ListEntries{
|
||||
{ID: 3, PubKey: refs.FeedRef{ID: bytes.Repeat([]byte("acab"), 8), Algo: "true"}},
|
||||
}
|
||||
ts.MembersDB.ListReturns(lst, nil)
|
||||
|
||||
```
|
||||
|
||||
**Checking how often RemoveID was called and with what arguments:**
|
||||
|
||||
```go
|
||||
// go-ssb-room/web/handlers/admin/allow_list_test.go:210
|
||||
a.Equal(1, ts.MembersDB.RemoveIDCallCount())
|
||||
@@ -75,8 +96,8 @@ ts.MembersDB.ListReturns(lst, nil)
|
||||
a.EqualValues(666, theID)
|
||||
```
|
||||
|
||||
|
||||
## Example test
|
||||
|
||||
```go
|
||||
package handlers
|
||||
|
||||
@@ -128,4 +149,3 @@ cd muxrpc/test/nodejs
|
||||
npm ci
|
||||
go test
|
||||
```
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package tunnel
|
||||
|
||||
@@ -1,56 +1,59 @@
|
||||
module github.com/ssb-ngi-pointer/go-ssb-room/v2
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
module github.com/ssbc/go-ssb-room/v2
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/PuerkitoBio/goquery v1.5.0
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
github.com/BurntSushi/toml v1.2.1
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/friendsofgo/errors v0.9.2
|
||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
||||
github.com/gorilla/csrf v1.7.0
|
||||
github.com/go-logfmt/logfmt v0.5.1 // indirect
|
||||
github.com/gomodule/redigo v2.0.0+incompatible // indirect
|
||||
github.com/gorilla/csrf v1.7.1
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gorilla/securecookie v1.1.1
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/mattevans/pwned-passwords v0.3.0
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||
github.com/nicksnyder/go-i18n/v2 v2.1.2
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattevans/pwned-passwords v0.6.0
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.5.0
|
||||
github.com/mileusna/useragent v1.2.1
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.1
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
|
||||
github.com/rubenv/sql-migrate v1.2.0
|
||||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/throttled/throttled/v2 v2.7.1
|
||||
github.com/unrolled/secure v1.0.8
|
||||
github.com/ssbc/go-muxrpc/v2 v2.0.14-0.20221111190521-10382533750c
|
||||
github.com/ssbc/go-netwrap v0.1.5-0.20221019160355-cd323bb2e29d
|
||||
github.com/ssbc/go-secretstream v1.2.11-0.20221111164233-4b41f899f844
|
||||
github.com/ssbc/go-ssb-refs v0.5.2-0.20221019090322-8b558c2f31de
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/throttled/throttled/v2 v2.9.1
|
||||
github.com/unrolled/secure v1.13.0
|
||||
github.com/vcraescu/go-paginator/v2 v2.0.0
|
||||
github.com/volatiletech/sqlboiler/v4 v4.5.0
|
||||
github.com/volatiletech/strmangle v0.0.1
|
||||
go.cryptoscope.co/muxrpc/v2 v2.0.6
|
||||
go.cryptoscope.co/netwrap v0.1.1
|
||||
github.com/volatiletech/sqlboiler/v4 v4.14.0
|
||||
github.com/volatiletech/strmangle v0.0.4
|
||||
go.cryptoscope.co/nocomment v0.0.0-20210520094614-fb744e81f810
|
||||
go.cryptoscope.co/secretstream v1.2.8
|
||||
go.mindeco.de v1.12.0
|
||||
go.mindeco.de/ssb-refs v0.2.0
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/text v0.3.5
|
||||
golang.org/x/tools v0.1.1
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
golang.org/x/crypto v0.4.0
|
||||
golang.org/x/sync v0.1.0
|
||||
golang.org/x/text v0.5.0
|
||||
golang.org/x/tools v0.4.0
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
gorm.io/gorm v1.24.1 // indirect
|
||||
)
|
||||
|
||||
exclude go.cryptoscope.co/ssb v0.0.0-20201207161753-31d0f24b7a79
|
||||
|
||||
// We need our internal/extra25519 since agl pulled his repo recently.
|
||||
// Issue: https://github.com/cryptoscope/ssb/issues/44
|
||||
// Ours uses a fork of x/crypto where edwards25519 is not an internal package,
|
||||
// This seemed like the easiest change to port agl's extra25519 to use x/crypto
|
||||
// Background: https://github.com/agl/ed25519/issues/27#issuecomment-591073699
|
||||
// The branch in use: https://github.com/cryptix/golang_x_crypto/tree/non-internal-edwards
|
||||
replace golang.org/x/crypto => github.com/cryptix/golang_x_crypto v0.0.0-20200924101112-886946aabeb8
|
||||
|
||||
// https://github.com/rubenv/sql-migrate/pull/189
|
||||
// and using branch 'drop-other-drivers' for less dependency pollution (oracaldb and the like)
|
||||
replace github.com/rubenv/sql-migrate => github.com/cryptix/go-sql-migrate v0.0.0-20210521142015-a3e4d9974764
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: Unlicense
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package aliases implements the validation and signing features of https://ssb-ngi-pointer.github.io/rooms2/#alias
|
||||
// Package aliases implements the validation and signing features of https://ssbc.github.io/rooms2/#alias
|
||||
package aliases
|
||||
|
||||
import (
|
||||
@@ -8,7 +10,7 @@ import (
|
||||
|
||||
"golang.org/x/crypto/ed25519"
|
||||
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
)
|
||||
|
||||
// Registration ties an alias to the ID of the user and the RoomID it should be registered on
|
||||
@@ -31,9 +33,9 @@ func (r Registration) Sign(privKey ed25519.PrivateKey) Confirmation {
|
||||
func (r Registration) createRegistrationMessage() []byte {
|
||||
var message bytes.Buffer
|
||||
message.WriteString("=room-alias-registration:")
|
||||
message.WriteString(r.RoomID.Ref())
|
||||
message.WriteString(r.RoomID.String())
|
||||
message.WriteString(":")
|
||||
message.WriteString(r.UserID.Ref())
|
||||
message.WriteString(r.UserID.String())
|
||||
message.WriteString(":")
|
||||
message.WriteString(r.Alias)
|
||||
return message.Bytes()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package aliases
|
||||
@@ -6,18 +8,18 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/stretchr/testify/require"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
)
|
||||
|
||||
func TestConfirmation(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
// this is our room, it's not a valid feed but thats fine for this test
|
||||
roomID := refs.FeedRef{
|
||||
ID: bytes.Repeat([]byte("test"), 8),
|
||||
Algo: "test",
|
||||
roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("test"), 8), refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
r.Error(err)
|
||||
}
|
||||
|
||||
// to make the test deterministic, decided by fair dice roll.
|
||||
@@ -34,7 +36,7 @@ func TestConfirmation(t *testing.T) {
|
||||
|
||||
// internal function to create the registration string
|
||||
msg := valid.createRegistrationMessage()
|
||||
want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.test:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation"
|
||||
want := "=room-alias-registration:@dGVzdHRlc3R0ZXN0dGVzdHRlc3R0ZXN0dGVzdHRlc3Q=.ed25519:@Rt2aJrtOqWXhBZ5/vlfzeWQ9Bj/z6iT8CMhlr2WWlG4=.ed25519:TestConfirmation"
|
||||
r.Equal(want, string(msg))
|
||||
|
||||
// create the signed confirmation
|
||||
@@ -44,9 +46,9 @@ func TestConfirmation(t *testing.T) {
|
||||
r.True(yes, "should be valid for this room and feed")
|
||||
|
||||
// make up another id for the invalid test(s)
|
||||
otherID := refs.FeedRef{
|
||||
ID: bytes.Repeat([]byte("nope"), 8),
|
||||
Algo: "test",
|
||||
otherID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("nope"), 8), refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
r.Error(err)
|
||||
}
|
||||
|
||||
confirmation.RoomID = otherID
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package aliases
|
||||
|
||||
// IsValid decides whether an alias is okay for use or not.
|
||||
// The room spec defines it as _labels valid under RFC 1035_ ( https://ssb-ngi-pointer.github.io/rooms2/#alias-string )
|
||||
// The room spec defines it as _labels valid under RFC 1035_ ( https://ssbc.github.io/rooms2/#alias-string )
|
||||
// but that can be mostly any string since DNS is a 8bit binary protocol,
|
||||
// as long as it's shorter then 63 charachters.
|
||||
//
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package aliases
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package broadcasts
|
||||
@@ -6,8 +8,8 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
)
|
||||
|
||||
type AttendantsEmitter interface {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package broadcasts implements custom typed one-to-n facilities for broadcasting messages/calls to multiple subscribers.
|
||||
// They loosely follow from luigi.Broadcasts but using concrete types instead of empty interfaces.
|
||||
package broadcasts
|
||||
package broadcasts
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package broadcasts
|
||||
@@ -6,7 +8,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
)
|
||||
|
||||
type EndpointsEmitter interface {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package broadcasts
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package devtools
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package devtools
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package keys could be it's own thing between go-ssb and this but not today
|
||||
@@ -12,9 +14,9 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ssbc/go-secretstream/secrethandshake"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"go.cryptoscope.co/nocomment"
|
||||
"go.cryptoscope.co/secretstream/secrethandshake"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
)
|
||||
|
||||
var SecretPerms = os.FileMode(0600)
|
||||
@@ -36,8 +38,8 @@ type ssbSecret struct {
|
||||
// IsValidFeedFormat checks if the passed FeedRef is for one of the two supported formats,
|
||||
// legacy/crapp or GabbyGrove.
|
||||
func IsValidFeedFormat(r refs.FeedRef) error {
|
||||
if r.Algo != refs.RefAlgoFeedSSB1 && r.Algo != refs.RefAlgoFeedGabby {
|
||||
return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo)
|
||||
if r.Algo() != refs.RefAlgoFeedSSB1 && r.Algo() != refs.RefAlgoFeedGabby {
|
||||
return fmt.Errorf("ssb: unsupported feed format:%s", r.Algo())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -51,11 +53,13 @@ func NewKeyPair(r io.Reader) (*KeyPair, error) {
|
||||
return nil, fmt.Errorf("ssb: error building key pair: %w", err)
|
||||
}
|
||||
|
||||
feed, err := refs.NewFeedRefFromBytes(kp.Public[:], refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ssb: error building key pair: %w", err)
|
||||
}
|
||||
|
||||
keyPair := KeyPair{
|
||||
Feed: refs.FeedRef{
|
||||
ID: kp.Public[:],
|
||||
Algo: refs.RefAlgoFeedSSB1,
|
||||
},
|
||||
Feed: feed,
|
||||
Pair: *kp,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package multicloser
|
||||
@@ -7,7 +9,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/multierror"
|
||||
)
|
||||
|
||||
type Closer struct {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package multierror
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package testutils
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package testutils
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package maybemuxrpc
|
||||
@@ -6,7 +8,7 @@ import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
)
|
||||
|
||||
type Authorizer interface {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
@@ -9,8 +11,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.cryptoscope.co/netwrap"
|
||||
"go.cryptoscope.co/secretstream"
|
||||
"github.com/ssbc/go-netwrap"
|
||||
"github.com/ssbc/go-secretstream"
|
||||
)
|
||||
|
||||
type connEntry struct {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
@@ -13,10 +15,10 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"go.cryptoscope.co/netwrap"
|
||||
"go.cryptoscope.co/secretstream"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/ssbc/go-netwrap"
|
||||
"github.com/ssbc/go-secretstream"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
)
|
||||
|
||||
// ServerEndpointDetails encapsulates the endpoint information.
|
||||
@@ -53,6 +55,7 @@ func (sed ServerEndpointDetails) URLForAlias(a string) string {
|
||||
if sed.UseSubdomainForAliases {
|
||||
u.Host = a + "." + sed.Domain
|
||||
} else {
|
||||
u.Host = sed.Domain
|
||||
u.Path = "/alias/" + a
|
||||
}
|
||||
|
||||
@@ -128,10 +131,10 @@ type ConnTracker interface {
|
||||
}
|
||||
|
||||
// GetFeedRefFromAddr uses netwrap to get the secretstream address and then uses ParseFeedRef
|
||||
func GetFeedRefFromAddr(addr net.Addr) (*refs.FeedRef, error) {
|
||||
func GetFeedRefFromAddr(addr net.Addr) (refs.FeedRef, error) {
|
||||
addr = netwrap.GetAddr(addr, secretstream.NetworkString)
|
||||
if addr == nil {
|
||||
return nil, errors.New("no shs-bs address found")
|
||||
return refs.FeedRef{}, errors.New("no shs-bs address found")
|
||||
}
|
||||
ssAddr := addr.(secretstream.Addr)
|
||||
return refs.ParseFeedRef(ssAddr.String())
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network_test
|
||||
@@ -9,11 +11,11 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"go.mindeco.de/log"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Code generated by counterfeiter. DO NOT EDIT.
|
||||
package mocked
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
muxrpc "go.cryptoscope.co/muxrpc/v2"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
muxrpc "github.com/ssbc/go-muxrpc/v2"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
)
|
||||
|
||||
type FakeEndpoints struct {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
|
||||
import (
|
||||
@@ -6,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
)
|
||||
|
||||
func TestMultiserverAddress(t *testing.T) {
|
||||
@@ -17,10 +21,11 @@ func TestMultiserverAddress(t *testing.T) {
|
||||
sed.Domain = "the.ho.st"
|
||||
sed.ListenAddressMUXRPC = ":8008"
|
||||
|
||||
sed.RoomID = refs.FeedRef{
|
||||
ID: bytes.Repeat([]byte("ohai"), 8),
|
||||
Algo: "doesnt-matter", // not part of msaddr v1
|
||||
roomID, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte("ohai"), 8), refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sed.RoomID = roomID
|
||||
|
||||
gotMultiAddr := sed.MultiserverAddress()
|
||||
|
||||
|
||||
+13
-11
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
@@ -12,14 +14,14 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"go.cryptoscope.co/netwrap"
|
||||
"go.cryptoscope.co/secretstream"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/ssbc/go-netwrap"
|
||||
"github.com/ssbc/go-secretstream"
|
||||
"go.mindeco.de/log"
|
||||
"go.mindeco.de/log/level"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
)
|
||||
|
||||
// DefaultPort is the default listening port for ScuttleButt.
|
||||
@@ -126,7 +128,7 @@ func (n *node) GetEndpointFor(ref refs.FeedRef) (muxrpc.Endpoint, bool) {
|
||||
n.remotesLock.Lock()
|
||||
defer n.remotesLock.Unlock()
|
||||
|
||||
edp, has := n.remotes[ref.Ref()]
|
||||
edp, has := n.remotes[ref.String()]
|
||||
return edp, has
|
||||
}
|
||||
|
||||
@@ -145,7 +147,7 @@ func (n *node) GetAllEndpoints() []EndpointStat {
|
||||
continue
|
||||
}
|
||||
stats = append(stats, EndpointStat{
|
||||
ID: id,
|
||||
ID: &id,
|
||||
Addr: remote,
|
||||
Since: durr,
|
||||
Endpoint: edp,
|
||||
@@ -162,7 +164,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// ref := r.Ref()
|
||||
// ref := r.String()
|
||||
// if oldEdp, has := n.remotes[ref]; has {
|
||||
// n.log.Log("remotes", "previous active", "ref", ref)
|
||||
// c := client.FromEndpoint(oldEdp)
|
||||
@@ -173,7 +175,7 @@ func (n *node) addRemote(edp muxrpc.Endpoint) {
|
||||
// }
|
||||
// }
|
||||
// replace with new
|
||||
n.remotes[r.Ref()] = edp
|
||||
n.remotes[r.String()] = edp
|
||||
}
|
||||
|
||||
// TODO: merge with conntracker
|
||||
@@ -184,7 +186,7 @@ func (n *node) removeRemote(edp muxrpc.Endpoint) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
delete(n.remotes, r.Ref())
|
||||
delete(n.remotes, r.String())
|
||||
}
|
||||
|
||||
func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer bool, hws ...muxrpc.HandlerWrapper) {
|
||||
@@ -203,7 +205,7 @@ func (n *node) handleConnection(ctx context.Context, origConn net.Conn, isServer
|
||||
level.Error(n.log).Log("conn", "not shs authorized", "err", err)
|
||||
return
|
||||
}
|
||||
rLogger := log.With(n.log, "peer", remoteRef.ShortRef())
|
||||
rLogger := log.With(n.log, "peer", remoteRef.ShortSigil())
|
||||
|
||||
ok, ctx := n.connTracker.OnAccept(ctx, conn)
|
||||
if !ok {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package network
|
||||
@@ -11,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
kitlog "go.mindeco.de/log"
|
||||
"go.mindeco.de/log/level"
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package netwraputil
|
||||
@@ -6,8 +8,8 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"go.cryptoscope.co/netwrap"
|
||||
"go.cryptoscope.co/secretstream"
|
||||
"github.com/ssbc/go-netwrap"
|
||||
"github.com/ssbc/go-secretstream"
|
||||
)
|
||||
|
||||
// SpoofRemoteAddress wraps the connection with the passed reference
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package netwraputil
|
||||
@@ -6,8 +8,8 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -26,7 +28,7 @@ func TestSpoof(t *testing.T) {
|
||||
|
||||
ref, err := network.GetFeedRefFromAddr(wrapped.RemoteAddr())
|
||||
r.NoError(err)
|
||||
r.True(ref.Equal(&kp.Feed))
|
||||
r.True(ref.Equal(kp.Feed))
|
||||
|
||||
wc.Close()
|
||||
rc.Close()
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package randutil
|
||||
|
||||
import "math/rand"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package repo
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package repo
|
||||
@@ -9,8 +11,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
)
|
||||
|
||||
func DefaultKeyPair(r Interface) (*keys.KeyPair, error) {
|
||||
@@ -27,7 +29,7 @@ func DefaultKeyPair(r Interface) (*keys.KeyPair, error) {
|
||||
if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
|
||||
return nil, fmt.Errorf("repo: error saving new identity file: %w", err)
|
||||
}
|
||||
log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath)
|
||||
log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath)
|
||||
}
|
||||
return keyPair, nil
|
||||
}
|
||||
@@ -51,7 +53,7 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if algo != refs.RefAlgoFeedSSB1 && algo != refs.RefAlgoFeedGabby { // enums would be nice
|
||||
if algo != string(refs.RefAlgoFeedSSB1) && algo != string(refs.RefAlgoFeedGabby) { // enums would be nice
|
||||
return nil, fmt.Errorf("invalid feed refrence algo")
|
||||
}
|
||||
if _, err := keys.LoadKeyPair(secPath); err == nil {
|
||||
@@ -61,11 +63,10 @@ func newKeyPair(r Interface, name, algo string, seed io.Reader) (*keys.KeyPair,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("repo: no keypair but couldn't create one either: %w", err)
|
||||
}
|
||||
keyPair.Feed.Algo = algo
|
||||
if err := keys.SaveKeyPair(*keyPair, secPath); err != nil {
|
||||
return nil, fmt.Errorf("repo: error saving new identity file: %w", err)
|
||||
}
|
||||
log.Printf("saved identity %s to %s", keyPair.Feed.Ref(), secPath)
|
||||
log.Printf("saved identity %s to %s", keyPair.Feed.String(), secPath)
|
||||
return keyPair, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package signinwithssb
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package signinwithssb
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package signinwithssb
|
||||
@@ -10,7 +12,7 @@ import (
|
||||
|
||||
"golang.org/x/crypto/ed25519"
|
||||
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
)
|
||||
|
||||
// sign-in with ssb uses 256-bit nonces
|
||||
@@ -52,9 +54,9 @@ type ClientPayload struct {
|
||||
func (cr ClientPayload) createMessage() []byte {
|
||||
var msg bytes.Buffer
|
||||
msg.WriteString("=http-auth-sign-in:")
|
||||
msg.WriteString(cr.ServerID.Ref())
|
||||
msg.WriteString(cr.ServerID.String())
|
||||
msg.WriteString(":")
|
||||
msg.WriteString(cr.ClientID.Ref())
|
||||
msg.WriteString(cr.ClientID.String())
|
||||
msg.WriteString(":")
|
||||
msg.WriteString(cr.ServerChallenge)
|
||||
msg.WriteString(":")
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package signinwithssb
|
||||
@@ -9,13 +11,20 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
)
|
||||
|
||||
func TestPayloadString(t *testing.T) {
|
||||
|
||||
server := refs.FeedRef{ID: bytes.Repeat([]byte{1}, 32), Algo: "test"}
|
||||
client := refs.FeedRef{ID: bytes.Repeat([]byte{2}, 32), Algo: "test"}
|
||||
server, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{1}, 32), refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
client, err := refs.NewFeedRefFromBytes(bytes.Repeat([]byte{2}, 32), refs.RefAlgoFeedSSB1)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
var req ClientPayload
|
||||
|
||||
@@ -25,7 +34,7 @@ func TestPayloadString(t *testing.T) {
|
||||
req.ServerChallenge = "fooo"
|
||||
req.ClientChallenge = "barr"
|
||||
|
||||
want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.test:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.test:fooo:barr"
|
||||
want := "=http-auth-sign-in:@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519:@AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=.ed25519:fooo:barr"
|
||||
|
||||
got := req.createMessage()
|
||||
assert.Equal(t, want, string(got))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package alias implements the muxrpc handlers for alias needs.
|
||||
@@ -11,14 +13,14 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
kitlog "go.mindeco.de/log"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/web/router"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/web/router"
|
||||
)
|
||||
|
||||
// Handler implements the muxrpc methods for alias registration and recvocation
|
||||
@@ -91,7 +93,7 @@ func (h Handler) Register(ctx context.Context, req *muxrpc.Request) (interface{}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
confirmation.UserID = *userID
|
||||
confirmation.UserID = userID
|
||||
|
||||
// check the signature
|
||||
if !confirmation.Verify() {
|
||||
@@ -145,3 +147,43 @@ func (h Handler) Revoke(ctx context.Context, req *muxrpc.Request) (interface{},
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (h Handler) List(ctx context.Context, req *muxrpc.Request) (interface{}, error) {
|
||||
var args []string
|
||||
|
||||
err := json.Unmarshal(req.RawArgs, &args)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("listAlias: bad request: %w", err)
|
||||
}
|
||||
|
||||
if n := len(args); n != 1 {
|
||||
return nil, fmt.Errorf("listAlias: expected one argument got %d", n)
|
||||
}
|
||||
|
||||
ref, err := refs.ParseFeedRef(args[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("listAlias: invalid feed ref: %w", err)
|
||||
}
|
||||
|
||||
allAliases, err := h.db.List(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("listAlias: could not list aliases: %w", err)
|
||||
}
|
||||
|
||||
var filteredAliases []roomdb.Alias
|
||||
for _, alias := range allAliases {
|
||||
if alias.Feed.Equal(ref) {
|
||||
filteredAliases = append(filteredAliases, alias)
|
||||
}
|
||||
}
|
||||
|
||||
return aliasesToListOfAliasStrings(filteredAliases), nil
|
||||
}
|
||||
|
||||
func aliasesToListOfAliasStrings(aliases []roomdb.Alias) []string {
|
||||
result := make([]string, 0)
|
||||
for _, alias := range aliases {
|
||||
result = append(result, alias.Name)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// 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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package gossip
|
||||
@@ -8,7 +10,7 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"go.mindeco.de/encodedTime"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package signinwithssb
|
||||
@@ -9,14 +11,14 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
kitlog "go.mindeco.de/log"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
|
||||
validate "github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
|
||||
validate "github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
)
|
||||
|
||||
// Handler implements the muxrpc methods for the "Sign-in with SSB" calls. SendSolution and InvalidateAllSolutions.
|
||||
@@ -62,7 +64,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
member, err := h.members.GetByFeed(ctx, *clientID)
|
||||
member, err := h.members.GetByFeed(ctx, clientID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("client is not a room member")
|
||||
}
|
||||
@@ -79,7 +81,7 @@ func (h Handler) SendSolution(ctx context.Context, req *muxrpc.Request) (interfa
|
||||
var payload validate.ClientPayload
|
||||
payload.ServerID = h.self
|
||||
payload.ServerChallenge = params[0]
|
||||
payload.ClientID = *clientID
|
||||
payload.ClientID = clientID
|
||||
payload.ClientChallenge = params[1]
|
||||
|
||||
sig, err := base64.StdEncoding.DecodeString(strings.TrimSuffix(params[2], ".sig.ed25519"))
|
||||
@@ -118,7 +120,7 @@ func (h Handler) InvalidateAllSolutions(ctx context.Context, req *muxrpc.Request
|
||||
}
|
||||
|
||||
// lookup the member
|
||||
member, err := h.members.GetByFeed(ctx, *clientID)
|
||||
member, err := h.members.GetByFeed(ctx, clientID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package server
|
||||
@@ -8,10 +10,10 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
)
|
||||
|
||||
// AttendantsUpdate is emitted if a single member joins or leaves.
|
||||
@@ -41,14 +43,14 @@ func (h *Handler) attendants(ctx context.Context, req *muxrpc.Request, snk *muxr
|
||||
}
|
||||
|
||||
if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted {
|
||||
_, err := h.members.GetByFeed(ctx, *peer)
|
||||
_, err := h.membersdb.GetByFeed(ctx, peer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("external user are not allowed to enumerate members")
|
||||
}
|
||||
}
|
||||
|
||||
// add peer to the state
|
||||
h.state.AddEndpoint(*peer, req.Endpoint())
|
||||
h.state.AddEndpoint(peer, req.Endpoint())
|
||||
|
||||
// send the current state
|
||||
snk.SetEncoding(muxrpc.TypeJSON)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package server
|
||||
@@ -8,13 +10,13 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
kitlog "go.mindeco.de/log"
|
||||
"go.mindeco.de/log/level"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomstate"
|
||||
)
|
||||
|
||||
type ConnectArg struct {
|
||||
@@ -44,7 +46,7 @@ func (h connectHandler) HandleConnect(ctx context.Context, edp muxrpc.Endpoint)
|
||||
return
|
||||
}
|
||||
|
||||
h.state.Remove(*peer)
|
||||
h.state.Remove(peer)
|
||||
}
|
||||
|
||||
// HandleDuplex here implements the tunnel.connect behavior of the server-side. It receives incoming events
|
||||
@@ -61,7 +63,7 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p
|
||||
}
|
||||
arg := args[0]
|
||||
|
||||
if !arg.Portal.Equal(&h.self) {
|
||||
if !arg.Portal.Equal(h.self) {
|
||||
return fmt.Errorf("talking to the wrong room")
|
||||
}
|
||||
|
||||
@@ -72,29 +74,29 @@ func (h connectHandler) HandleDuplex(ctx context.Context, req *muxrpc.Request, p
|
||||
}
|
||||
|
||||
// make sure they dont want to connect to themselves
|
||||
if caller.Equal(&arg.Target) {
|
||||
if caller.Equal(arg.Target) {
|
||||
return fmt.Errorf("can't connect to self")
|
||||
}
|
||||
|
||||
// see if we have and endpoint for the target
|
||||
edp, has := h.state.Has(arg.Target)
|
||||
if !has {
|
||||
return fmt.Errorf("could not connect to:%s", arg.Target.Ref())
|
||||
return fmt.Errorf("could not connect to:%s", arg.Target.String())
|
||||
}
|
||||
|
||||
// call connect on them
|
||||
var argWorigin connectWithOriginArg
|
||||
argWorigin.ConnectArg = arg
|
||||
argWorigin.Origin = *caller
|
||||
argWorigin.Origin = caller
|
||||
|
||||
targetSrc, targetSnk, err := edp.Duplex(ctx, muxrpc.TypeBinary, muxrpc.Method{"tunnel", "connect"}, argWorigin)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not connect to:%s", arg.Target.Ref())
|
||||
return fmt.Errorf("could not connect to:%s", arg.Target.String())
|
||||
}
|
||||
|
||||
// pipe data between caller and target
|
||||
var cpy muxrpcDuplexCopy
|
||||
cpy.logger = kitlog.With(h.logger, "caller", caller.ShortRef(), "target", arg.Target.ShortRef())
|
||||
cpy.logger = kitlog.With(h.logger, "caller", caller.ShortSigil(), "target", arg.Target.ShortSigil())
|
||||
cpy.ctx, cpy.cancel = context.WithCancel(ctx)
|
||||
|
||||
go cpy.do(targetSnk, peerSrc)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
)
|
||||
|
||||
type Member struct {
|
||||
ID refs.FeedRef `json:"id"`
|
||||
}
|
||||
|
||||
func (h *Handler) members(ctx context.Context, req *muxrpc.Request, snk *muxrpc.ByteSink) error {
|
||||
peer, err := network.GetFeedRefFromAddr(req.RemoteAddr())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pm, err := h.config.GetPrivacyMode(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("running with unknown privacy mode: %w", err)
|
||||
}
|
||||
|
||||
if pm == roomdb.ModeCommunity || pm == roomdb.ModeRestricted {
|
||||
_, err := h.membersdb.GetByFeed(ctx, peer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("external users are not allowed to list members: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
members, err := h.membersdb.List(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error listing members: %w", err)
|
||||
}
|
||||
|
||||
snk.SetEncoding(muxrpc.TypeJSON)
|
||||
|
||||
for _, member := range members {
|
||||
if err = json.NewEncoder(snk).Encode([]Member{
|
||||
{
|
||||
ID: member.PubKey,
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("encoder error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return snk.Close()
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"go.cryptoscope.co/muxrpc/v2/typemux"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2/typemux"
|
||||
kitlog "go.mindeco.de/log"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomstate"
|
||||
)
|
||||
|
||||
/* manifest:
|
||||
@@ -28,7 +30,7 @@ func New(log kitlog.Logger, netInfo network.ServerEndpointDetails, m *roomstate.
|
||||
h.netInfo = netInfo
|
||||
h.logger = log
|
||||
h.state = m
|
||||
h.members = members
|
||||
h.membersdb = members
|
||||
h.config = config
|
||||
|
||||
return h
|
||||
@@ -57,6 +59,7 @@ func (h *Handler) RegisterRoom(mux typemux.HandlerMux) {
|
||||
mux.RegisterAsync(append(namespace, "ping"), typemux.AsyncFunc(h.ping))
|
||||
|
||||
mux.RegisterSource(append(namespace, "attendants"), typemux.SourceFunc(h.attendants))
|
||||
mux.RegisterSource(append(namespace, "members"), typemux.SourceFunc(h.members))
|
||||
|
||||
mux.RegisterDuplex(append(namespace, "connect"), connectHandler{
|
||||
logger: h.logger,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package server
|
||||
@@ -10,21 +12,21 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomstate"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomstate"
|
||||
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
kitlog "go.mindeco.de/log"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
logger kitlog.Logger
|
||||
|
||||
netInfo network.ServerEndpointDetails
|
||||
state *roomstate.Manager
|
||||
members roomdb.MembersService
|
||||
config roomdb.RoomConfig
|
||||
netInfo network.ServerEndpointDetails
|
||||
state *roomstate.Manager
|
||||
membersdb roomdb.MembersService
|
||||
config roomdb.RoomConfig
|
||||
}
|
||||
|
||||
type MetadataReply struct {
|
||||
@@ -48,7 +50,7 @@ func (h *Handler) metadata(ctx context.Context, req *muxrpc.Request) (interface{
|
||||
reply.Name = h.netInfo.Domain
|
||||
|
||||
// check if caller is a member
|
||||
if _, err := h.members.GetByFeed(ctx, *ref); err != nil {
|
||||
if _, err := h.membersdb.GetByFeed(ctx, ref); err != nil {
|
||||
if !errors.Is(err, roomdb.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
@@ -88,7 +90,7 @@ func (h *Handler) announce(_ context.Context, req *muxrpc.Request) (interface{},
|
||||
return nil, err
|
||||
}
|
||||
|
||||
h.state.AddEndpoint(*ref, req.Endpoint())
|
||||
h.state.AddEndpoint(ref, req.Endpoint())
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -99,7 +101,7 @@ func (h *Handler) leave(_ context.Context, req *muxrpc.Request) (interface{}, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
h.state.Remove(*ref)
|
||||
h.state.Remove(ref)
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -121,7 +123,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp
|
||||
case roomdb.ModeCommunity:
|
||||
fallthrough
|
||||
case roomdb.ModeRestricted:
|
||||
_, err := h.members.GetByFeed(ctx, *peer)
|
||||
_, err := h.membersdb.GetByFeed(ctx, peer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("external user are not allowed to enumerate members")
|
||||
}
|
||||
@@ -132,7 +134,7 @@ func (h *Handler) endpoints(ctx context.Context, req *muxrpc.Request, snk *muxrp
|
||||
h.state.RegisterLegacyEndpoints(toPeer)
|
||||
|
||||
// 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
|
||||
toPeer.Update(h.state.List())
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package whoami
|
||||
@@ -5,13 +7,13 @@ package whoami
|
||||
import (
|
||||
"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"
|
||||
"go.mindeco.de/log/level"
|
||||
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -37,5 +39,5 @@ func (h handler) HandleAsync(ctx context.Context, req *muxrpc.Request) (interfac
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
return ret{h.id.Ref()}, nil
|
||||
return ret{h.id.String()}, nil
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -11,14 +13,14 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
)
|
||||
|
||||
// technically we are usign two servers here
|
||||
@@ -102,7 +104,7 @@ func TestAliasRegister(t *testing.T) {
|
||||
|
||||
a.Equal(confirmation.Alias, alias.Name)
|
||||
a.Equal(confirmation.Signature, alias.Signature)
|
||||
a.True(confirmation.UserID.Equal(&bobsKey.Feed))
|
||||
a.True(confirmation.UserID.Equal(bobsKey.Feed))
|
||||
|
||||
t.Log("alias stored")
|
||||
|
||||
@@ -121,3 +123,75 @@ func TestAliasRegister(t *testing.T) {
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
|
||||
func TestListAliases(t *testing.T) {
|
||||
testInit(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
r := require.New(t)
|
||||
a := assert.New(t)
|
||||
|
||||
// make a random test key
|
||||
appKey := make([]byte, 32)
|
||||
rand.Read(appKey)
|
||||
|
||||
netOpts := []roomsrv.Option{
|
||||
roomsrv.WithAppKey(appKey),
|
||||
roomsrv.WithContext(ctx),
|
||||
}
|
||||
|
||||
theBots := []*testSession{}
|
||||
|
||||
session := makeNamedTestBot(t, "srv", ctx, netOpts)
|
||||
theBots = append(theBots, session)
|
||||
|
||||
bobsKey, err := keys.NewKeyPair(nil)
|
||||
r.NoError(err)
|
||||
|
||||
bobSession := makeNamedTestBot(t, "bob", ctx, append(netOpts,
|
||||
roomsrv.WithKeyPair(bobsKey),
|
||||
))
|
||||
theBots = append(theBots, bobSession)
|
||||
|
||||
_, err = session.srv.Members.Add(ctx, bobSession.srv.Whoami(), roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
// allow bots to dial the remote
|
||||
// side-effect of re-using a room-server as the client
|
||||
_, err = bobSession.srv.Members.Add(ctx, session.srv.Whoami(), roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
// should work (we allowed A)
|
||||
err = bobSession.srv.Network.Connect(ctx, session.srv.Network.GetListenAddr())
|
||||
r.NoError(err, "connect A to the Server")
|
||||
|
||||
t.Log("letting handshaking settle..")
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
clientForServer, ok := bobSession.srv.Network.GetEndpointFor(session.srv.Whoami())
|
||||
r.True(ok)
|
||||
|
||||
var testReg aliases.Registration
|
||||
testReg.Alias = "bob"
|
||||
testReg.RoomID = session.srv.Whoami()
|
||||
testReg.UserID = bobSession.srv.Whoami()
|
||||
|
||||
confirmation := testReg.Sign(bobsKey.Pair.Secret)
|
||||
sig := base64.StdEncoding.EncodeToString(confirmation.Signature) + ".sig.ed25519"
|
||||
|
||||
var response string
|
||||
|
||||
err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String())
|
||||
r.NoError(err)
|
||||
a.Equal("[]", response, "initially the list of aliases should be empty")
|
||||
|
||||
err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "registerAlias"}, "bob", sig)
|
||||
r.NoError(err)
|
||||
a.NotEqual("", response, "response isn't empty")
|
||||
|
||||
err = clientForServer.Async(ctx, &response, muxrpc.TypeString, muxrpc.Method{"room", "listAliases"}, bobsKey.Feed.String())
|
||||
r.NoError(err)
|
||||
a.Equal("[\"bob\"]", response, "new alias should be in the list")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -11,11 +13,11 @@ import (
|
||||
"testing"
|
||||
"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/require"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
)
|
||||
|
||||
// this tests the new room.attendants call
|
||||
@@ -53,7 +55,7 @@ func TestRoomAttendants(t *testing.T) {
|
||||
decodeJSONsrc(t, carlsSource, &initState)
|
||||
a.Equal("state", initState.Type)
|
||||
a.Len(initState.IDs, 1)
|
||||
a.True(initState.IDs[0].Equal(&carl.feed))
|
||||
a.True(initState.IDs[0].Equal(carl.feed))
|
||||
|
||||
announcementsForCarl := make(announcements)
|
||||
go logAttendantsStream(ts, carlsSource, "carl", announcementsForCarl)
|
||||
@@ -83,7 +85,7 @@ func TestRoomAttendants(t *testing.T) {
|
||||
a.Len(announcementsForAlf, 0, "none yet")
|
||||
|
||||
// assert what carl saw
|
||||
_, seen = announcementsForCarl[alf.feed.Ref()]
|
||||
_, seen = announcementsForCarl[alf.feed.String()]
|
||||
a.True(seen, "carl saw alf")
|
||||
|
||||
// let bre join the room
|
||||
@@ -107,10 +109,10 @@ func TestRoomAttendants(t *testing.T) {
|
||||
a.Len(announcementsForBre, 0, "none yet")
|
||||
|
||||
// the two present people saw her
|
||||
_, seen = announcementsForAlf[bre.feed.Ref()]
|
||||
_, seen = announcementsForAlf[bre.feed.String()]
|
||||
a.True(seen, "alf saw bre")
|
||||
|
||||
_, seen = announcementsForCarl[bre.feed.Ref()]
|
||||
_, seen = announcementsForCarl[bre.feed.String()]
|
||||
a.True(seen, "carl saw alf")
|
||||
|
||||
// shutdown alf first
|
||||
@@ -120,10 +122,10 @@ func TestRoomAttendants(t *testing.T) {
|
||||
|
||||
// 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")
|
||||
|
||||
_, seen = announcementsForCarl[alf.feed.Ref()]
|
||||
_, seen = announcementsForCarl[alf.feed.String()]
|
||||
a.False(seen, "alf should be gone for carl")
|
||||
|
||||
// terminate server and the clients
|
||||
@@ -141,12 +143,12 @@ func TestRoomAttendants(t *testing.T) {
|
||||
func assertListContains(t *testing.T, lst []refs.FeedRef, who refs.FeedRef) {
|
||||
var found = false
|
||||
for _, feed := range lst {
|
||||
if feed.Equal(&who) {
|
||||
if feed.Equal(who) {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,13 +176,13 @@ func logAttendantsStream(ts *testSession, src *muxrpc.ByteSource, who string, a
|
||||
if err != nil {
|
||||
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 {
|
||||
case "joined":
|
||||
a[update.ID.Ref()] = struct{}{}
|
||||
a[update.ID.String()] = struct{}{}
|
||||
case "left":
|
||||
delete(a, update.ID.Ref())
|
||||
delete(a, update.ID.String())
|
||||
default:
|
||||
ts.t.Fatalf("%s: unexpected update type: %v", who, update.Type)
|
||||
}
|
||||
|
||||
+14
-12
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -7,12 +9,12 @@ import (
|
||||
"testing"
|
||||
"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/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.
|
||||
@@ -70,7 +72,7 @@ func TestConnEstablishmentDeniedKey(t *testing.T) {
|
||||
a.Nil(endpointB, "should not have an endpoint on B")
|
||||
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.Error(err)
|
||||
t.Log(srvWho.ID.Ref())
|
||||
t.Log(srvWho.ID.String())
|
||||
}
|
||||
|
||||
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
|
||||
@@ -79,8 +81,8 @@ func TestConnEstablishmentDeniedKey(t *testing.T) {
|
||||
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.NoError(err)
|
||||
|
||||
t.Log("server whoami:", srvWho.ID.Ref())
|
||||
a.True(serv.Whoami().Equal(&srvWho.ID))
|
||||
t.Log("server whoami:", srvWho.ID.String())
|
||||
a.True(serv.Whoami().Equal(srvWho.ID))
|
||||
|
||||
cancel()
|
||||
}
|
||||
@@ -139,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)")
|
||||
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.Error(err)
|
||||
t.Log(srvWho.ID.Ref())
|
||||
t.Log(srvWho.ID.String())
|
||||
}
|
||||
|
||||
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
|
||||
@@ -148,8 +150,8 @@ func TestConnEstablishmentDenyNonMembersRestrictedRoom(t *testing.T) {
|
||||
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.NoError(err)
|
||||
|
||||
t.Log("server whoami:", srvWho.ID.Ref())
|
||||
a.True(serv.Whoami().Equal(&srvWho.ID))
|
||||
t.Log("server whoami:", srvWho.ID.String())
|
||||
a.True(serv.Whoami().Equal(srvWho.ID))
|
||||
|
||||
cancel()
|
||||
}
|
||||
@@ -209,7 +211,7 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) {
|
||||
r.True(has, "botB has no endpoint for the server")
|
||||
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.NoError(err)
|
||||
t.Log(srvWho.ID.Ref())
|
||||
t.Log(srvWho.ID.String())
|
||||
|
||||
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
|
||||
r.True(has, "botA has no endpoint for the server")
|
||||
@@ -217,8 +219,8 @@ func TestConnEstablishmentAllowNonMembersCommunityRoom(t *testing.T) {
|
||||
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.NoError(err)
|
||||
|
||||
t.Log("server whoami:", srvWho.ID.Ref())
|
||||
a.True(serv.Whoami().Equal(&srvWho.ID))
|
||||
t.Log("server whoami:", srvWho.ID.String())
|
||||
a.True(serv.Whoami().Equal(srvWho.ID))
|
||||
|
||||
cancel()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -10,11 +12,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"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{}
|
||||
@@ -52,7 +54,7 @@ func TestEndpointClients(t *testing.T) {
|
||||
go logEndpointsStream(ts, carlEndpointsSrc, "carl", announcementsForCarl)
|
||||
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")
|
||||
|
||||
// let alf join the room
|
||||
@@ -64,13 +66,13 @@ func TestEndpointClients(t *testing.T) {
|
||||
time.Sleep(1 * time.Second) // give some time to process new events
|
||||
|
||||
// assert what alf saw
|
||||
_, seen = announcementsForAlf[carl.feed.Ref()]
|
||||
_, seen = announcementsForAlf[carl.feed.String()]
|
||||
a.True(seen, "alf saw carl")
|
||||
_, seen = announcementsForAlf[alf.feed.Ref()]
|
||||
_, seen = announcementsForAlf[alf.feed.String()]
|
||||
a.True(seen, "alf saw himself")
|
||||
|
||||
// assert what carl saw
|
||||
_, seen = announcementsForCarl[alf.feed.Ref()]
|
||||
_, seen = announcementsForCarl[alf.feed.String()]
|
||||
a.True(seen, "carl saw alf")
|
||||
|
||||
// let bre join the room
|
||||
@@ -83,17 +85,17 @@ func TestEndpointClients(t *testing.T) {
|
||||
time.Sleep(1 * time.Second) // give some time to process new events
|
||||
|
||||
// assert bre saw the other two and herself
|
||||
_, seen = announcementsForBre[carl.feed.Ref()]
|
||||
_, seen = announcementsForBre[carl.feed.String()]
|
||||
a.True(seen, "bre saw carl")
|
||||
_, seen = announcementsForBre[alf.feed.Ref()]
|
||||
_, seen = announcementsForBre[alf.feed.String()]
|
||||
a.True(seen, "bre saw alf")
|
||||
_, seen = announcementsForBre[bre.feed.Ref()]
|
||||
_, seen = announcementsForBre[bre.feed.String()]
|
||||
a.True(seen, "bre saw herself")
|
||||
|
||||
// assert the others saw bre
|
||||
_, seen = announcementsForAlf[bre.feed.Ref()]
|
||||
_, seen = announcementsForAlf[bre.feed.String()]
|
||||
a.True(seen, "alf saw bre")
|
||||
_, seen = announcementsForCarl[bre.feed.Ref()]
|
||||
_, seen = announcementsForCarl[bre.feed.String()]
|
||||
a.True(seen, "carl saw bre")
|
||||
|
||||
// terminate server and the clients
|
||||
@@ -125,10 +127,10 @@ func logEndpointsStream(ts *testSession, src *muxrpc.ByteSource, who string, a a
|
||||
}
|
||||
ts.t.Log(who, "got endpoints:", len(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
|
||||
a[f.Ref()] = struct{}{}
|
||||
a[f.String()] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
)
|
||||
|
||||
// this tests the new room.members call
|
||||
func TestRoomMembers(t *testing.T) {
|
||||
testCases := []struct {
|
||||
Name string
|
||||
PrivacyMode roomdb.PrivacyMode
|
||||
ExternalCanConnect bool
|
||||
ExternalCanList bool
|
||||
}{
|
||||
{
|
||||
Name: "open",
|
||||
PrivacyMode: roomdb.ModeOpen,
|
||||
ExternalCanConnect: true,
|
||||
ExternalCanList: true,
|
||||
},
|
||||
{
|
||||
Name: "community",
|
||||
PrivacyMode: roomdb.ModeCommunity,
|
||||
ExternalCanConnect: true,
|
||||
ExternalCanList: false,
|
||||
},
|
||||
{
|
||||
Name: "restricted",
|
||||
PrivacyMode: roomdb.ModeRestricted,
|
||||
ExternalCanConnect: false,
|
||||
ExternalCanList: false,
|
||||
},
|
||||
}
|
||||
|
||||
for i := range testCases {
|
||||
testCase := testCases[i]
|
||||
|
||||
t.Run(testCase.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := require.New(t)
|
||||
|
||||
testInit(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
appKey := make([]byte, 32)
|
||||
rand.Read(appKey)
|
||||
|
||||
netOpts := []roomsrv.Option{
|
||||
roomsrv.WithAppKey(appKey),
|
||||
roomsrv.WithContext(ctx),
|
||||
}
|
||||
|
||||
session := makeNamedTestBot(t, "srv", ctx, netOpts)
|
||||
|
||||
aliceKey, err := keys.NewKeyPair(nil)
|
||||
r.NoError(err)
|
||||
|
||||
bobKey, err := keys.NewKeyPair(nil)
|
||||
r.NoError(err)
|
||||
|
||||
_, err = session.srv.Members.Add(ctx, aliceKey.Feed, roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
_, err = session.srv.Members.Add(ctx, bobKey.Feed, roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
err = session.srv.Config.SetPrivacyMode(ctx, testCase.PrivacyMode)
|
||||
r.NoError(err)
|
||||
|
||||
t.Run("member", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := require.New(t)
|
||||
|
||||
bobSession := makeNamedTestBot(t, "bob", ctx, append(netOpts,
|
||||
roomsrv.WithKeyPair(bobKey),
|
||||
))
|
||||
|
||||
// allow bots to dial the remote
|
||||
// side-effect of re-using a room-server as the client
|
||||
_, err = bobSession.srv.Members.Add(ctx, session.srv.Whoami(), roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
err = bobSession.srv.Network.Connect(ctx, session.srv.Network.GetListenAddr())
|
||||
r.NoError(err, "connect bob to the Server")
|
||||
|
||||
t.Log("letting handshaking settle..")
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
clientForServer, ok := bobSession.srv.Network.GetEndpointFor(session.srv.Whoami())
|
||||
r.True(ok)
|
||||
|
||||
src, err := clientForServer.Source(ctx, muxrpc.TypeString, muxrpc.Method{"room", "members"})
|
||||
r.NoError(err)
|
||||
|
||||
var responses []server.Member
|
||||
for src.Next(ctx) {
|
||||
bytes, err := src.Bytes()
|
||||
r.NoError(err)
|
||||
|
||||
var members []server.Member
|
||||
err = json.Unmarshal(bytes, &members)
|
||||
r.NoError(err)
|
||||
responses = append(responses, members...)
|
||||
}
|
||||
|
||||
r.NoError(src.Err())
|
||||
r.Equal(
|
||||
[]server.Member{
|
||||
{
|
||||
ID: aliceKey.Feed,
|
||||
},
|
||||
{
|
||||
ID: bobKey.Feed,
|
||||
},
|
||||
},
|
||||
responses,
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("external", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := require.New(t)
|
||||
|
||||
carolKey, err := keys.NewKeyPair(nil)
|
||||
r.NoError(err)
|
||||
|
||||
carolSession := makeNamedTestBot(t, "carol", ctx, append(netOpts,
|
||||
roomsrv.WithKeyPair(carolKey),
|
||||
))
|
||||
|
||||
// allow bots to dial the remote
|
||||
// side-effect of re-using a room-server as the client
|
||||
_, err = carolSession.srv.Members.Add(ctx, session.srv.Whoami(), roomdb.RoleMember)
|
||||
r.NoError(err)
|
||||
|
||||
err = carolSession.srv.Network.Connect(ctx, session.srv.Network.GetListenAddr())
|
||||
r.NoError(err, "connect carol to the Server")
|
||||
|
||||
t.Log("letting handshaking settle..")
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
clientForServer, ok := carolSession.srv.Network.GetEndpointFor(session.srv.Whoami())
|
||||
if testCase.ExternalCanConnect {
|
||||
r.True(ok)
|
||||
} else {
|
||||
r.False(ok)
|
||||
return
|
||||
}
|
||||
|
||||
src, err := clientForServer.Source(ctx, muxrpc.TypeString, muxrpc.Method{"room", "members"})
|
||||
r.NoError(err)
|
||||
|
||||
var responses []server.Member
|
||||
for src.Next(ctx) {
|
||||
bytes, err := src.Bytes()
|
||||
r.NoError(err)
|
||||
|
||||
var members []server.Member
|
||||
err = json.Unmarshal(bytes, &members)
|
||||
r.NoError(err)
|
||||
responses = append(responses, members...)
|
||||
}
|
||||
|
||||
if testCase.ExternalCanList {
|
||||
r.NoError(src.Err())
|
||||
r.Equal(
|
||||
[]server.Member{
|
||||
{
|
||||
ID: aliceKey.Feed,
|
||||
},
|
||||
{
|
||||
ID: bobKey.Feed,
|
||||
},
|
||||
},
|
||||
responses,
|
||||
)
|
||||
} else {
|
||||
r.EqualError(src.Err(), "muxrpc CallError: Error - external users are not allowed to list members: roomdb: object not found")
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -11,10 +13,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"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
|
||||
@@ -71,7 +73,7 @@ func TestStaleMembers(t *testing.T) {
|
||||
// restart srh
|
||||
oldSrh := srh.feed
|
||||
srh = ts.makeTestClient("srh")
|
||||
r.True(oldSrh.Equal(&srh.feed))
|
||||
r.True(oldSrh.Equal(srh.feed))
|
||||
t.Log("restarted srh")
|
||||
|
||||
time.Sleep(1 * time.Second) // let server respond
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -7,13 +9,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
|
||||
tunserv "github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
)
|
||||
|
||||
func TestTunnelServerSimple(t *testing.T) {
|
||||
@@ -66,7 +68,7 @@ func TestTunnelServerSimple(t *testing.T) {
|
||||
a.Nil(endpointB, "should not have an endpoint on B")
|
||||
err = endpointB.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.Error(err)
|
||||
t.Log(srvWho.ID.Ref())
|
||||
t.Log(srvWho.ID.String())
|
||||
}
|
||||
|
||||
endpointA, has := botA.Network.GetEndpointFor(serv.Whoami())
|
||||
@@ -75,8 +77,8 @@ func TestTunnelServerSimple(t *testing.T) {
|
||||
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
r.NoError(err)
|
||||
|
||||
t.Log("server whoami:", srvWho.ID.Ref())
|
||||
a.True(serv.Whoami().Equal(&srvWho.ID))
|
||||
t.Log("server whoami:", srvWho.ID.String())
|
||||
a.True(serv.Whoami().Equal(srvWho.ID))
|
||||
|
||||
// start testing basic room stuff
|
||||
var meta tunserv.MetadataReply
|
||||
@@ -143,11 +145,11 @@ func TestRoomAnnounce(t *testing.T) {
|
||||
|
||||
err = endpointA.Async(ctx, &srvWho, muxrpc.TypeJSON, muxrpc.Method{"whoami"})
|
||||
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"})
|
||||
r.NoError(err)
|
||||
a.True(serv.Whoami().Equal(&srvWho.ID))
|
||||
a.True(serv.Whoami().Equal(srvWho.ID))
|
||||
|
||||
// let B listen for changes
|
||||
newRoomMember, err := endpointB.Source(ctx, muxrpc.TypeJSON, muxrpc.Method{"tunnel", "endpoints"})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
@@ -17,25 +19,25 @@ import (
|
||||
"time"
|
||||
|
||||
_ "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"
|
||||
"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/level"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/sqlite"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/testutils"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/repo"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb/sqlite"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -165,7 +167,7 @@ func (ts *testSession) makeTestClient(name string) testClient {
|
||||
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
|
||||
_, err := ts.srv.Members.GetByFeed(ts.ctx, client.Feed)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package go_test
|
||||
|
||||
import (
|
||||
@@ -13,16 +17,16 @@ import (
|
||||
"time"
|
||||
|
||||
"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"
|
||||
"go.cryptoscope.co/muxrpc/v2"
|
||||
"go.cryptoscope.co/muxrpc/v2/debug"
|
||||
"go.cryptoscope.co/secretstream"
|
||||
"go.mindeco.de/encodedTime"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/keys"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
tunserv "github.com/ssb-ngi-pointer/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/internal/maybemod/keys"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
tunserv "github.com/ssbc/go-ssb-room/v2/muxrpc/handlers/tunnel/server"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
)
|
||||
|
||||
func TestWebsocketDialing(t *testing.T) {
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
node_modules
|
||||
testrun
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package nodejs_test
|
||||
|
||||
import (
|
||||
@@ -7,9 +11,9 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/aliases"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb/mockdb"
|
||||
)
|
||||
|
||||
func TestGoServerJSClientAliases(t *testing.T) {
|
||||
@@ -47,7 +51,7 @@ func TestGoServerJSClientAliases(t *testing.T) {
|
||||
r.Equal(1, aliasesDB.RegisterCallCount(), "register call count")
|
||||
_, name, ref, signature := aliasesDB.RegisterArgsForCall(0)
|
||||
a.Equal("alice", name, "wrong alias registered")
|
||||
a.Equal(alice.Ref(), ref.Ref())
|
||||
a.Equal(alice.String(), ref.String())
|
||||
|
||||
var aliasReq aliases.Confirmation
|
||||
aliasReq.Alias = name
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: Unlicense
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
|
||||
SPDX-License-Identifier: Unlicense
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const Path = require('path')
|
||||
const { loadOrCreateSync } = require('ssb-keys')
|
||||
const tapSpec = require("tap-spec")
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const Path = require('path')
|
||||
const tapSpec = require('tap-spec')
|
||||
const tape = require('tape')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package nodejs_test contains test scenarios and helpers to run interoparability tests against the javascript implementation.
|
||||
@@ -19,20 +21,20 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ssbc/go-muxrpc/v2/debug"
|
||||
"github.com/ssbc/go-netwrap"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.cryptoscope.co/muxrpc/v2/debug"
|
||||
"go.cryptoscope.co/netwrap"
|
||||
"go.mindeco.de/log"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/maybemod/testutils"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomdb/mockdb"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/v2/roomsrv"
|
||||
refs "go.mindeco.de/ssb-refs"
|
||||
refs "github.com/ssbc/go-ssb-refs"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/maybemod/testutils"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/network"
|
||||
"github.com/ssbc/go-ssb-room/v2/internal/signinwithssb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomdb/mockdb"
|
||||
"github.com/ssbc/go-ssb-room/v2/roomsrv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -119,7 +121,7 @@ func (ts *testSession) startGoServer(
|
||||
if err != nil {
|
||||
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)
|
||||
}),
|
||||
)
|
||||
@@ -133,7 +135,7 @@ func (ts *testSession) startGoServer(
|
||||
|
||||
srv, err := roomsrv.New(membersDB, deniedKeysDB, aliasDB, authSessionsDB, sb, fakeConfig, netInfo, opts...)
|
||||
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.Log("bot close:", srv.Close())
|
||||
})
|
||||
@@ -141,7 +143,7 @@ func (ts *testSession) startGoServer(
|
||||
ts.done.Go(func() error {
|
||||
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
|
||||
// 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) {
|
||||
err = fmt.Errorf("go server exited: %w", err)
|
||||
ts.t.Log(err)
|
||||
@@ -185,7 +187,7 @@ func (ts *testSession) startJSClient(
|
||||
"TEST_NAME=" + name,
|
||||
"TEST_REPO=" + cmd.Dir,
|
||||
"TEST_PEERADDR=" + netwrap.GetAddr(peerAddr, "tcp").String(),
|
||||
"TEST_PEERREF=" + peerRef.Ref(),
|
||||
"TEST_PEERREF=" + peerRef.String(),
|
||||
"TEST_SESSIONSCRIPT=" + testScript,
|
||||
// "DEBUG=ssb:room:tunnel:*",
|
||||
}
|
||||
@@ -219,8 +221,8 @@ func (ts *testSession) startJSClient(
|
||||
|
||||
jsBotRef, err := refs.ParseFeedRef(pubScanner.Text())
|
||||
r.NoError(err, "failed to get %s key from JS process")
|
||||
ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.Ref())
|
||||
return *jsBotRef
|
||||
ts.t.Logf("JS %s:%d %s", name, jsBotCnt, jsBotRef.String())
|
||||
return jsBotRef
|
||||
}
|
||||
|
||||
// startJSBotAsServer returns the servers public key and it's TCP port on localhost.
|
||||
@@ -275,8 +277,8 @@ func (ts *testSession) startJSBotAsServer(name, testScriptFileName string) (*ref
|
||||
|
||||
srvRef, err := refs.ParseFeedRef(pubScanner.Text())
|
||||
r.NoError(err, "failed to get srvRef key from JS process")
|
||||
ts.t.Logf("JS %s: %s port: %d", name, srvRef.Ref(), port)
|
||||
return srvRef, port
|
||||
ts.t.Logf("JS %s: %s port: %d", name, srvRef.String(), port)
|
||||
return &srvRef, port
|
||||
}
|
||||
|
||||
func (ts *testSession) wait() {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const pull = require('pull-stream')
|
||||
const { readFileSync } = require('fs')
|
||||
const path = require("path")
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const pull = require('pull-stream')
|
||||
const path = require("path")
|
||||
const scriptname = path.basename(__filename)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user