Merge branch 'master' into portal-latest

This commit is contained in:
Filip Rysavy 2022-02-09 16:52:43 +01:00
commit 831f466703
No known key found for this signature in database
GPG Key ID: EA1F430401C92D99
26 changed files with 2981 additions and 583 deletions

View File

@ -0,0 +1,23 @@
name: Test - packages/health-check
on:
pull_request:
paths:
- packages/health-check/**
defaults:
run:
working-directory: packages/health-check
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
- run: yarn
- run: yarn jest

View File

@ -34,68 +34,8 @@ For the purposes of complying with our code license, you can use the following S
`fb6c9320bc7e01fbb9cd8d8c3caaa371386928793c736837832e634aaaa484650a3177d6714a`
### MongoDB Setup
Mongo needs a couple of extra steps in order to start a secure cluster.
- Open port 27017 on all nodes that will take part in the cluster. Ideally, you would only open the port for the other
nodes in the cluster.
- Manually add a `mgkey` file under `./docker/data/mongo` with the respective secret (
see [Mongo's keyfile access control](https://docs.mongodb.com/manual/tutorial/enforce-keyfile-access-control-in-existing-replica-set/)
for details).
- Manually run an initialisation `docker run` with extra environment variables that will initialise the admin user with
a password (example below).
- During the initialisation run mentioned above, we need to make two extra steps within the container:
- Change the ownership of `mgkey` to `mongodb:mongodb`
- Change its permissions to 400
- After these steps are done we can open a mongo shell on the primary node and run `rs.add()` in order to add the new
node to the cluster. If you don't know which node is primary, log onto any server and jump into the Mongo's container
(`docker exec -it mongo mongo -u admin -p`) and then get the status of the replica set (`rs.status()`).
Example initialisation docker run command:
```
docker run \
--rm \
--name mg \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=<admin username> \
-e MONGO_INITDB_ROOT_PASSWORD=<admin password> \
-v /home/user/skynet-webportal/docker/data/mongo/db:/data/db \
-v /home/user/skynet-webportal/docker/data/mongo/mgkey:/data/mgkey \
mongo --keyFile=/data/mgkey --replSet=skynet
```
Regular docker run command:
```
docker run \
--rm \
--name mg \
-p 27017:27017 \
-v /home/user/skynet-webportal/docker/data/mongo/db:/data/db \
-v /home/user/skynet-webportal/docker/data/mongo/mgkey:/data/mgkey \
mongo --keyFile=/data/mgkey --replSet=skynet
```
Cluster initialisation mongo command:
```
rs.initiate(
{
_id : "skynet",
members: [
{ _id : 0, host : "mongo:27017" }
]
}
)
```
Add more nodes when they are ready:
```
rs.add("second.node.net:27017")
```
## Running a Portal
For those interested in running a Webportal, head over to our developer docs [here](https://docs.siasky.net/webportal-management/overview.) to learn more.
## Contributing
@ -109,6 +49,3 @@ Verify the Cypress test suite by doing the following:
1. In one terminal screen run `GATSBY_API_URL=https://siasky.net website serve`
1. In a second terminal screen run `yarn cypress run`
## Setting up complete skynet server
A setup guide with installation scripts can be found in [setup-scripts/README.md](./setup-scripts/README.md).

View File

@ -0,0 +1 @@
- Remove outdated portal setup documentation and point to developer docs.

View File

@ -23,7 +23,6 @@ services:
- ABUSE_SPONSOR=${ABUSE_SPONSOR}
- BLOCKER_HOST=10.10.10.110
- BLOCKER_PORT=4000
- BLOCKER_AUTH_HEADER=${BLOCKER_AUTH_HEADER}
- EMAIL_SERVER=${EMAIL_SERVER}
- EMAIL_USERNAME=${EMAIL_USERNAME}
- EMAIL_PASSWORD=${EMAIL_PASSWORD}

View File

@ -25,7 +25,8 @@
"dns": {
"provider": {
"name": "route53"
}
},
"ttl": "30m"
}
}
}

View File

@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@fontsource/sora": "4.5.1",
"@fontsource/source-sans-pro": "4.5.2",
"@fontsource/sora": "4.5.2",
"@fontsource/source-sans-pro": "4.5.3",
"@stripe/react-stripe-js": "1.7.0",
"@stripe/stripe-js": "1.22.0",
"classnames": "2.3.1",
@ -20,25 +20,25 @@
"formik": "2.2.9",
"http-status-codes": "2.2.0",
"ky": "0.28.7",
"next": "12.0.9",
"next": "12.0.10",
"normalize.css": "8.0.1",
"pretty-bytes": "5.6.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-toastify": "8.1.0",
"react-toastify": "8.1.1",
"skynet-js": "3.0.2",
"stripe": "8.200.0",
"swr": "1.2.0",
"stripe": "8.202.0",
"swr": "1.2.1",
"yup": "0.32.11"
},
"devDependencies": {
"@tailwindcss/forms": "0.4.0",
"@tailwindcss/typography": "0.5.1",
"autoprefixer": "10.4.2",
"eslint": "8.7.0",
"eslint-config-next": "12.0.9",
"postcss": "8.4.5",
"eslint": "8.8.0",
"eslint-config-next": "12.0.10",
"postcss": "8.4.6",
"prettier": "2.5.1",
"tailwindcss": "3.0.11"
"tailwindcss": "3.0.19"
}
}

View File

@ -53,15 +53,15 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"
"@fontsource/sora@4.5.1":
version "4.5.1"
resolved "https://registry.yarnpkg.com/@fontsource/sora/-/sora-4.5.1.tgz#2bf6a815074fe4db61930050f0db392bc3ccbb8e"
integrity sha512-NCtO8MWU/t+Q3Gnm8Yjb3i8gLlayIUH/cWr8dz3GiNO82fCUs8RWov6hCFpUg5LMdTnVHNUjgtN1Xn1JsXqt4w==
"@fontsource/source-sans-pro@4.5.2":
"@fontsource/sora@4.5.2":
version "4.5.2"
resolved "https://registry.yarnpkg.com/@fontsource/source-sans-pro/-/source-sans-pro-4.5.2.tgz#3c6cccb29e24d784b851cc6914cd9a5f967f8f3b"
integrity sha512-uN2iIKDbpHpGZjUT+/kkwS67MPDn2tfFXBCkHjzu7JQPA6kIHZeOyKseshvZ/pyrCYqnAL9cAot5Nygt08/HRQ==
resolved "https://registry.yarnpkg.com/@fontsource/sora/-/sora-4.5.2.tgz#ea7ad9e0f238ac8878fa9fe1aa6147444fcaa6b7"
integrity sha512-KD7WpqNvnviMyfBsQKEWsKtMve/uP4Hpq/rxfvOWggURMEEGSTciDarEwxs9HIbj/C7u4mCKjFQSFYLteG2+xQ==
"@fontsource/source-sans-pro@4.5.3":
version "4.5.3"
resolved "https://registry.yarnpkg.com/@fontsource/source-sans-pro/-/source-sans-pro-4.5.3.tgz#bdb1eeed5db70bcd1f68cd1e8c859834f0e6bc67"
integrity sha512-9xWGu3ArKsjf6+WVrNoCUywybTB3rIidpvOI2tByQpzYVOupFUv6qohyrjDrVvPb6XHJQTD0NIzisR7RKhiP7A==
"@humanwhocodes/config-array@^0.9.2":
version "0.9.2"
@ -77,72 +77,72 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
"@next/env@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.0.9.tgz#4c9e9eef00226145d9629a846b8cc31878e1328c"
integrity sha512-oBlkyDop0Stf7MPIzETGv5r0YT/G/weBrknoPOUTaa5qwOeGjuy6gsOVc/SBtrBkOoBmRpD+fFhQJPvmo1mS+g==
"@next/env@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.0.10.tgz#561640fd62279218ccd2798ae907bae8d94a7730"
integrity sha512-mQVj0K6wQ5WEk/sL9SZ+mJXJUaG7el8CpZ6io1uFe9GgNTSC7EgUyNGqM6IQovIFc5ukF4O/hqsdh3S/DCgT2g==
"@next/eslint-plugin-next@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-12.0.9.tgz#86edc490141fe3495765224d6cc25be158881802"
integrity sha512-Pi7eV7Omt4wkY1UI9Kvv3KQLvAkmWKb5EHePCE1fyR+LeYmKCNYtjVst3QTDkNeULbpPwnDqIISWu+x2y5G9EA==
"@next/eslint-plugin-next@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-12.0.10.tgz#521ab5d05a89e818528668df8a3edb8f9df2c547"
integrity sha512-PbGRnV5HGSfRGLjf8uTh1MaWgLwnjKjWiGVjK752ifITJbZ28/5AmLAFT2shDYeux8BHgpgVll5QXu7GN3YLFw==
dependencies:
glob "7.1.7"
"@next/swc-android-arm64@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-12.0.9.tgz#2cdbcc1814471044ea0e057b475090d25654833c"
integrity sha512-aVqgsEn5plmUH2X58sjzhHsH/6majucWTMaaBEs7hHO2+GCwCZc7zaLH4XCBMKPES9Yaja8/pYUbvZQE9DqgFw==
"@next/swc-android-arm64@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-12.0.10.tgz#fd9d716433cc9d361021b0052f8b002bcaff948d"
integrity sha512-xYwXGkNhzZZsM5MD7KRwF5ZNiC8OLPtVMUiagpPnwENg8Hb0GSQo/NbYWXM8YrawEwp9LaZ7OXiuRKPh2JyBdA==
"@next/swc-darwin-arm64@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.0.9.tgz#ea200929d7116de12c6f3b13ff75f9522c2153e3"
integrity sha512-uAgRKm4a2nVdyBiPPJokvmDD1saugOvxljz9ld2ih0CCg5S9vBhqaj3kPGCQBj9hSu3q+Lng2CHnQqG3ga1jzA==
"@next/swc-darwin-arm64@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.0.10.tgz#34b2d0dc62eb89efb9176af111e3820a11fdb3f0"
integrity sha512-f2zngulkpIJKWHckhRi7X8GZ+J/tNgFF7lYIh7Qx15JH0OTBsjkqxORlkzy+VZyHJ5sWTCaI6HYYd3ow6qkEEg==
"@next/swc-darwin-x64@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-12.0.9.tgz#32800a7a9aff4bfd2038b0bce3657ece8708a87b"
integrity sha512-fDOs2lZIyrAdU18IxMA5orBPn9qLbOdu55gXSTNZOhyRJ8ugtbUAejsK7OL0boJy0CCHPAdVRXm01Mwk8tZ9RQ==
"@next/swc-darwin-x64@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-12.0.10.tgz#a4306795159293c7d4d58a2c88ce1710ff0a8baa"
integrity sha512-Qykcu/gVC5oTvOQoRBhyuS5GYm5SbcgrFTsaLFkGBmEkg9eMQRiaCswk4IafpDXVzITkVFurzSM28q3tLW2qUw==
"@next/swc-linux-arm-gnueabihf@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.0.9.tgz#da012dfb69ad2abc3d4045395581b650048bdd7c"
integrity sha512-/ni0p9DBvATUML9RQ1ycQuf05uOYKdzA6iI8+eRsARjpGbFVUFbge7XPzlj9g2Q9YWgoN8CSjFGnKRlyky5uHA==
"@next/swc-linux-arm-gnueabihf@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.0.10.tgz#1ad15af3d5fca2fef57894d61e16f73aee61ec2e"
integrity sha512-EhqrTFsIXAXN9B/fiiW/QKUK/lSLCXRsLalkUp58KDfMqVLLlj1ORbESAcswiNQOChLuHQSldGEEtOBPQZcd9A==
"@next/swc-linux-arm64-gnu@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.0.9.tgz#fe704c0a1cb048ef19d4a24b2c990574c96c933b"
integrity sha512-AphxilJDf95rUxJDHgM9Ww1DaYXZWqTvoKwXeej/0SgSvICcRZrLaFDrkojdXz0Rxr4igX2OdYR1S4/Hj1jWOQ==
"@next/swc-linux-arm64-gnu@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.0.10.tgz#a84a92d0e1a179c4346c9ed8f22e26f708101ad6"
integrity sha512-kqGtC72g3+JYXZbY2ca6digXR5U6AQ6Dzv4eAxYluMePLHjI/Xye1mf9dwVsgmeXfrD/IRDp5K/3A6UNvBm4oQ==
"@next/swc-linux-arm64-musl@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.0.9.tgz#b2bb68940903cd64f7875979ed9907e946dc4f3e"
integrity sha512-K5jbvNNzF3mRjWmPdxP5Bg87i7FHivfBj/L0KJlxpkLSC8sffBJDmB6jtMnI7wiPj9J6vmLkbGtSosln78xAlQ==
"@next/swc-linux-arm64-musl@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.0.10.tgz#973ec96c77f845bd0a6eecbf1892caa1ee4defaf"
integrity sha512-bG9zTSNwnSgc1Un/7oz1ZVN4UeXsTWrsQhAGWU78lLLCn4Zj9HQoUCRCGLt0OVs2DBZ+WC8CzzFliQ1SKipVbg==
"@next/swc-linux-x64-gnu@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.0.9.tgz#b700ba095551d4f6e830b92d4593a3b6e73bba82"
integrity sha512-bJZ9bkMkQzsY+UyWezEZ77GWQ4TzwKeXdayX3U3+aEkL8k5C6eKBXlidWdrhu0teLmaUXIyWerWrLnJzwGXdfw==
"@next/swc-linux-x64-gnu@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.0.10.tgz#efcc7f8252ea8225834760eaf09350f1bead73f7"
integrity sha512-c79PcfWtyThiYRa1+3KVfDq0zXaI8o1d6dQWNVqDrtLz5HKM/rbjLdvoNuxDwUeZhxI/d9CtyH6GbuKPw5l/5A==
"@next/swc-linux-x64-musl@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.0.9.tgz#678460266f544b52f1190ef0c3494e436608591e"
integrity sha512-SR9p0R+v1T32DTXPVAXZw31pmJAkSDotC6Afy+mfC0xrEL3pp95R8sGXYAAUCEPkQp0MEeUOVy2LrToe92X7hQ==
"@next/swc-linux-x64-musl@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.0.10.tgz#c2a73d939dfd310acc1892a0a132762500dd5757"
integrity sha512-g/scgn+21/MLfizOCZOZt+MxNj2/8Tdlwjvy+QZcSUPZRUI2Y5o3HwBvI1f/bSci+NGRU+bUAO0NFtRJ9MzH5w==
"@next/swc-win32-arm64-msvc@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.0.9.tgz#f70e5bd0821ca168aeef117e51ab870265ceeeb1"
integrity sha512-mzQ1A8vfHhJrvEy5KJZGZWEByXthyKfWofvFaf+oo/5nJl/0Bz1ODP2ajSmbLG++77Eo2AROgbm9pkW1ucvG2A==
"@next/swc-win32-arm64-msvc@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.0.10.tgz#2316af5f612cde1691abdf2571ff40ec32ea3429"
integrity sha512-gl6B/ravwMeY5Nv4Il2/ARYJQ6u+KPRwGMjS1ZrNudIKlNn4YBeXh5A4cIVm+dHaff6/O/lGOa5/SUYDMZpkww==
"@next/swc-win32-ia32-msvc@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.0.9.tgz#0b853793754642cde9f9099087d4a86b6a99a24d"
integrity sha512-MpD2vj1zjo1u3J3wiz3pEKse19Etz+P0GL6XfQkB/9a84vJQ1JWMaWBjmIdivzZv718Il2pRSSx8hymwPfguYQ==
"@next/swc-win32-ia32-msvc@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.0.10.tgz#98a4f74d164871cfaccb0df6efddf2b7bcbaa54b"
integrity sha512-7RVpZ3tSThC6j+iZB0CUYmFiA3kXmN+pE7QcfyAxFaflKlaZoWNMKHIEZDuxSJc6YmQ6kyxsjqxVay2F5+/YCg==
"@next/swc-win32-x64-msvc@12.0.9":
version "12.0.9"
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.0.9.tgz#f7d3b59000082cf65c84fdc61930b708aa5446e5"
integrity sha512-1c/sxp/4Qz4F6rCxiYqAnrmghCOFt5hHZ9Kd+rXFW5Mqev4C4XDOUMHdBH55HgnJZqngYhOE0r/XNkCtsIojig==
"@next/swc-win32-x64-msvc@12.0.10":
version "12.0.10"
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.0.10.tgz#5c0ba98b695c4be44d8793aff42971a0dac65c2d"
integrity sha512-oUIWRKd24jFLRWUYO1CZmML5+32BcpVfqhimGaaZIXcOkfQW+iqiAzdqsv688zaGtyKGeB9ZtiK3NDf+Q0v+Vw==
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
@ -525,10 +525,10 @@ chalk@^4.0.0, chalk@^4.1.2:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chokidar@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==
chokidar@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
@ -781,12 +781,12 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eslint-config-next@12.0.9:
version "12.0.9"
resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.0.9.tgz#97ca3f651d8eabbaa8a5b3a6e48cc942c3b518d3"
integrity sha512-mhpFUsdctLw9PPOVF6S45n7uEzeRth9Xub6CbsKG8Bmr4QFTs1vhbFjp3cjdFIxjMQNuY8hcu66XFlvBB768Iw==
eslint-config-next@12.0.10:
version "12.0.10"
resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.0.10.tgz#f201f8f4514018f7ef46f454f56b81cf5c790379"
integrity sha512-l1er6mwSo1bltjLwmd71p5BdT6k/NQxV1n4lKZI6xt3MDMrq7ChUBr+EecxOry8GC/rCRUtPpH8Ygs0BJc5YLg==
dependencies:
"@next/eslint-plugin-next" "12.0.9"
"@next/eslint-plugin-next" "12.0.10"
"@rushstack/eslint-patch" "^1.0.8"
"@typescript-eslint/parser" "^5.0.0"
eslint-import-resolver-node "^0.3.4"
@ -911,10 +911,10 @@ eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.1.0, eslint-visitor-keys@^3.2
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.2.0.tgz#6fbb166a6798ee5991358bc2daa1ba76cc1254a1"
integrity sha512-IOzT0X126zn7ALX0dwFiUQEdsfzrm4+ISsQS8nukaJXwEyYKRSnEIIDULYg1mCtGp7UUXgfGl7BIolXREQK+XQ==
eslint@8.7.0:
version "8.7.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.7.0.tgz#22e036842ee5b7cf87b03fe237731675b4d3633c"
integrity sha512-ifHYzkBGrzS2iDU7KjhCAVMGCvF6M3Xfs8X8b37cgrUlDt6bWRTpRh6T/gtSXv1HJ/BUGgmjvNvOEGu85Iif7w==
eslint@8.8.0:
version "8.8.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.8.0.tgz#9762b49abad0cb4952539ffdb0a046392e571a2d"
integrity sha512-H3KXAzQGBH1plhYS3okDix2ZthuYJlQQEGE5k0IKuEqUSiyu4AmxxlJ2MtTYeJ3xB4jDhcYCwGOg2TXYdnDXlQ==
dependencies:
"@eslint/eslintrc" "^1.0.5"
"@humanwhocodes/config-array" "^0.9.2"
@ -1005,10 +1005,10 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
fast-glob@^3.1.1, fast-glob@^3.2.7:
version "3.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1"
integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==
fast-glob@^3.1.1, fast-glob@^3.2.11:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
@ -1352,6 +1352,13 @@ is-core-module@^2.8.0:
dependencies:
has "^1.0.3"
is-core-module@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211"
integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==
dependencies:
has "^1.0.3"
is-date-object@^1.0.1:
version "1.0.5"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f"
@ -1674,7 +1681,7 @@ nanoclone@^0.2.1:
resolved "https://registry.yarnpkg.com/nanoclone/-/nanoclone-0.2.1.tgz#dd4090f8f1a110d26bb32c49ed2f5b9235209ed4"
integrity sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA==
nanoid@^3.1.30:
nanoid@^3.1.30, nanoid@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c"
integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==
@ -1684,28 +1691,28 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
next@12.0.9:
version "12.0.9"
resolved "https://registry.yarnpkg.com/next/-/next-12.0.9.tgz#4eb3006b63bb866f5c2918ca0003e98f4259e063"
integrity sha512-omfYqoR/DvbdOIJ6SS1unKJ4mGIxUPs0RPa7wr/Mft22OCKgJhuG+aI9KFYi5ZJBwoFQk1vqaMKpWz5qr+dN0Q==
next@12.0.10:
version "12.0.10"
resolved "https://registry.yarnpkg.com/next/-/next-12.0.10.tgz#fcc4584177418bd777ce157f3165b7ba5e7708f7"
integrity sha512-1y3PpGzpb/EZzz1jgne+JfZXKAVJUjYXwxzrADf/LWN+8yi9o79vMLXpW3mevvCHkEF2sBnIdjzNn16TJrINUw==
dependencies:
"@next/env" "12.0.9"
"@next/env" "12.0.10"
caniuse-lite "^1.0.30001283"
postcss "8.4.5"
styled-jsx "5.0.0"
use-subscription "1.5.1"
optionalDependencies:
"@next/swc-android-arm64" "12.0.9"
"@next/swc-darwin-arm64" "12.0.9"
"@next/swc-darwin-x64" "12.0.9"
"@next/swc-linux-arm-gnueabihf" "12.0.9"
"@next/swc-linux-arm64-gnu" "12.0.9"
"@next/swc-linux-arm64-musl" "12.0.9"
"@next/swc-linux-x64-gnu" "12.0.9"
"@next/swc-linux-x64-musl" "12.0.9"
"@next/swc-win32-arm64-msvc" "12.0.9"
"@next/swc-win32-ia32-msvc" "12.0.9"
"@next/swc-win32-x64-msvc" "12.0.9"
"@next/swc-android-arm64" "12.0.10"
"@next/swc-darwin-arm64" "12.0.10"
"@next/swc-darwin-x64" "12.0.10"
"@next/swc-linux-arm-gnueabihf" "12.0.10"
"@next/swc-linux-arm64-gnu" "12.0.10"
"@next/swc-linux-arm64-musl" "12.0.10"
"@next/swc-linux-x64-gnu" "12.0.10"
"@next/swc-linux-x64-musl" "12.0.10"
"@next/swc-win32-arm64-msvc" "12.0.10"
"@next/swc-win32-ia32-msvc" "12.0.10"
"@next/swc-win32-x64-msvc" "12.0.10"
node-releases@^2.0.1:
version "2.0.1"
@ -1867,7 +1874,7 @@ path-key@^3.1.0:
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
path-parse@^1.0.6:
path-parse@^1.0.6, path-parse@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
@ -1917,15 +1924,7 @@ postcss-nested@5.0.6:
dependencies:
postcss-selector-parser "^6.0.6"
postcss-selector-parser@^6.0.6:
version "6.0.8"
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.8.tgz#f023ed7a9ea736cd7ef70342996e8e78645a7914"
integrity sha512-D5PG53d209Z1Uhcc0qAZ5U3t5HagH3cxu+WLZ22jt3gLUpXM4eXXfiO14jiDWST3NNooX/E8wISfOhZ9eIjGTQ==
dependencies:
cssesc "^3.0.0"
util-deprecate "^1.0.2"
postcss-selector-parser@^6.0.7:
postcss-selector-parser@^6.0.6, postcss-selector-parser@^6.0.9:
version "6.0.9"
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.9.tgz#ee71c3b9ff63d9cd130838876c13a2ec1a992b2f"
integrity sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ==
@ -1947,6 +1946,15 @@ postcss@8.4.5:
picocolors "^1.0.0"
source-map-js "^1.0.1"
postcss@8.4.6:
version "8.4.6"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.6.tgz#c5ff3c3c457a23864f32cb45ac9b741498a09ae1"
integrity sha512-OovjwIzs9Te46vlEx7+uXB0PLijpwjXGKXjVGGPIGubGpq7uh5Xgf6D6FiJ/SzJMBosHDp6a2hiXOS97iBXcaA==
dependencies:
nanoid "^3.2.0"
picocolors "^1.0.0"
source-map-js "^1.0.2"
prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@ -2029,10 +2037,10 @@ react-is@^16.7.0, react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
react-toastify@8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-8.1.0.tgz#acaca4e8c4415c8474562dd84a14e6f390ed7f17"
integrity sha512-M+Q3rTmEw/53Csr7NsV/YnldJe4c7uERcY7Tma9mvLU98QT2VhIkKwjBzzxZkJRk/oBKyUAtkyMjMgO00hx6gQ==
react-toastify@8.1.1:
version "8.1.1"
resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-8.1.1.tgz#79fada2487bcd2ca9b5910015f8d6f78cc65c984"
integrity sha512-KQa+j+JHjy69xpPYheaWUq3SjVw1sV2D7/QsXW6Tpo2x9HhUCvASezAMYDmLhfAYoSnaXUVnTNFAgZQA75SExQ==
dependencies:
clsx "^1.1.1"
@ -2084,13 +2092,14 @@ resolve-from@^5.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
resolve@^1.20.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
resolve@^1.20.0, resolve@^1.22.0:
version "1.22.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
dependencies:
is-core-module "^2.2.0"
path-parse "^1.0.6"
is-core-module "^2.8.1"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"
resolve@^2.0.0-next.3:
version "2.0.0-next.3"
@ -2199,10 +2208,10 @@ slash@^3.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
source-map-js@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.1.tgz#a1741c131e3c77d048252adfa24e23b908670caf"
integrity sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==
source-map-js@^1.0.1, source-map-js@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
string.prototype.matchall@^4.0.6:
version "4.0.6"
@ -2251,10 +2260,10 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
stripe@8.200.0:
version "8.200.0"
resolved "https://registry.yarnpkg.com/stripe/-/stripe-8.200.0.tgz#be5abc86a9e91cd83e1bff86ac814fae9c465a21"
integrity sha512-oM6jBvsIwY3x9cuNUSytwQ3daGuo2xxcMM6diUrNZhvOm5hbY2AvP2JPWW8RPMK0OHFskmYbWTKMJ1wg7AvLSQ==
stripe@8.202.0:
version "8.202.0"
resolved "https://registry.yarnpkg.com/stripe/-/stripe-8.202.0.tgz#884760713a690983d5a3128ea3cbeb677ee2645f"
integrity sha512-3YGHVnUatEn/At5+aRy+REdB2IyVa96/zls2xvQrKFTgaJzRu1MsJcK0GKg0p2B0y0VqlZo9gmdDEqphSHHvtA==
dependencies:
"@types/node" ">=8.1.0"
qs "^6.6.0"
@ -2278,25 +2287,30 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"
swr@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/swr/-/swr-1.2.0.tgz#8649f6e9131ce94bbcf7ffd65c21334da3d1ec20"
integrity sha512-C3IXeKOREn0jQ1ewXRENE7ED7jjGbFTakwB64eLACkCqkF/A0N2ckvpCTftcaSYi5yV36PzoehgVCOVRmtECcA==
supports-preserve-symlinks-flag@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
tailwindcss@3.0.11:
version "3.0.11"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.0.11.tgz#c4e96cada1f693cba66269eef80c74d22331c767"
integrity sha512-JyMsQ2kPqpOvG8ow535XpauXj3wz3nQqcy2tVlXj4FQ0eNlsdzvlAqpRA3q5rPLboWirNG6r2DqKczwjW2uc8Q==
swr@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/swr/-/swr-1.2.1.tgz#c21a4fe2139cb1c4630450589b5b5add947a9d41"
integrity sha512-1cuWXqJqXcFwbgONGCY4PHZ8v05009JdHsC3CIC6u7d00kgbMswNr1sHnnhseOBxtzVqcCNpOHEgVDciRer45w==
tailwindcss@3.0.19:
version "3.0.19"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.0.19.tgz#cd789953e6762af2e80c5a3e5d6da3a975ee8215"
integrity sha512-rjsdfz/qZya5xQ0OVynEMETgWq1CacmftgMYeXXh6bRM5vxsNwRSbMJsCCIjq/w67om9VP/AFMolOwiE+5VKig==
dependencies:
arg "^5.0.1"
chalk "^4.1.2"
chokidar "^3.5.2"
chokidar "^3.5.3"
color-name "^1.1.4"
cosmiconfig "^7.0.1"
detective "^5.2.0"
didyoumean "^1.2.2"
dlv "^1.1.3"
fast-glob "^3.2.7"
fast-glob "^3.2.11"
glob-parent "^6.0.2"
is-glob "^4.0.3"
normalize-path "^3.0.0"
@ -2304,10 +2318,10 @@ tailwindcss@3.0.11:
postcss-js "^4.0.0"
postcss-load-config "^3.1.0"
postcss-nested "5.0.6"
postcss-selector-parser "^6.0.7"
postcss-selector-parser "^6.0.9"
postcss-value-parser "^4.2.0"
quick-lru "^5.1.1"
resolve "^1.20.0"
resolve "^1.22.0"
text-table@^0.2.0:
version "0.2.0"

View File

@ -7,10 +7,10 @@ WORKDIR /usr/app
ENV PATH="/usr/app/bin:${PATH}"
# schedule critical checks to run every 5 minutes (any failures will disable server)
RUN echo '*/5 * * * * /usr/app/bin/cli run critical > /dev/stdout' >> /etc/crontabs/root
RUN echo '*/5 * * * * source /etc/environment ; /usr/app/bin/cli run critical >> /proc/1/fd/1' >> /etc/crontabs/root
# schedule extended checks to run on every hour (optional checks, report only)
RUN echo '0 * * * * /usr/app/bin/cli run extended > /dev/stdout' >> /etc/crontabs/root
RUN echo '0 * * * * source /etc/environment ; /usr/app/bin/cli run extended >> /proc/1/fd/1' >> /etc/crontabs/root
COPY package.json yarn.lock ./
@ -23,16 +23,18 @@ COPY bin bin
EXPOSE 3100
ENV NODE_ENV production
# 1. start dnsmasq in the background with:
# 1. get public server ip and save it in /etc/environment (passed to cron tasks as env variable)
# 2. start dnsmasq in the background with:
# - alias PORTAL_DOMAIN with current server ip so it overrides potential load balancer request
# - default docker nameserver 127.0.0.11 for any other request
# 2. replace docker nameserver with dnsmasq nameserver in /etc/resolv.conf
# 3. start crond in the background to schedule periodic health checks
# 4. start the health-check api service
# 3. replace docker nameserver with dnsmasq nameserver in /etc/resolv.conf
# 4. start crond in the background to schedule periodic health checks
# 5. start the health-check api service
CMD [ "sh", "-c", \
"serverip=$(node src/whatismyip.js) ; \
dnsmasq --no-resolv --log-facility=/var/log/dnsmasq.log --address=/$PORTAL_DOMAIN/$serverip --server=127.0.0.11 ; \
echo \"$(sed 's/127.0.0.11/127.0.0.1/' /etc/resolv.conf)\" > /etc/resolv.conf ; \
crond ; \
"export serverip=$(node src/whatismyip.js) && \
echo \"export serverip=${serverip}\" >> /etc/environment && \
dnsmasq --no-resolv --log-facility=/var/log/dnsmasq.log --address=/$PORTAL_DOMAIN/$serverip --server=127.0.0.11 && \
echo \"$(sed 's/127.0.0.11/127.0.0.1/' /etc/resolv.conf)\" > /etc/resolv.conf && \
crond && \
node src/index.js" \
]

View File

@ -6,6 +6,16 @@ require("yargs/yargs")(process.argv.slice(2))
.help()
.demandCommand()
.strict(true)
.command(
"__authenticate", // Internal only function - this function will be removed when API keys are implemented
false, // hide this function cli help
() => {},
async () => {
const { getAuthCookie } = require("../src/utils");
console.log(await getAuthCookie(true));
}
)
.command(
"enable",
"Mark portal as enabled",

View File

@ -18,6 +18,7 @@
"yargs": "^17.3.1"
},
"devDependencies": {
"jest": "^27.5.1",
"prettier": "^2.5.1"
}
}

View File

@ -1,13 +1,28 @@
const got = require("got");
const { ipCheckService, ipRegex } = require("../utils");
const getCurrentAddress = async () => {
// use serverip env variable when available (set via Dockerfile)
if (process.env.serverip) {
if (ipRegex.test(process.env.serverip)) return process.env.serverip;
// log error to console for future reference but do not break
console.log(`Environment variable serverip contains invalid ip: "${process.env.serverip}"`);
}
try {
const { body } = await got("http://whatismyip.akamai.com");
if (body) return body;
throw new Error("whatismyip.akamai.com responded with empty body");
const { body } = await got(`http://${ipCheckService}`);
if (ipRegex.test(body)) {
console.info(`Server public ip: ${body} (source: ${ipCheckService})`);
return body;
}
throw new Error(`${ipCheckService} responded with invalid ip: "${body}"`);
} catch (error) {
console.log(error.message);
return "-- error fetching ip address from whatismyip.akamai.com --";
console.log(error.message); // log error to console for future reference
return null;
}
};
@ -15,7 +30,8 @@ module.exports = async function middleware() {
const ip = await getCurrentAddress();
return (check) => {
if (check.ip && check.ip !== ip) {
// check only if current ip and check ip are provided
if (ip && check.ip && check.ip !== ip) {
check.up = false;
check.errors = check.errors ?? [];
check.errors.push({

View File

@ -42,4 +42,10 @@ server.listen(port, host, (error) => {
if (error) throw error;
console.info(`Server listening at http://${host}:${port} (NODE_ENV: ${process.env.NODE_ENV})`);
const { ipRegex } = require("./utils");
if (ipRegex.test(process.env.serverip)) {
console.info(`Server public ip: ${process.env.serverip}`);
}
});

View File

@ -1,4 +1,7 @@
const got = require("got");
const ipCheckService = "whatismyip.akamai.com";
const ipRegex = new RegExp(
`^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$`
);
/**
* Get the time between start and now in milliseconds
@ -45,24 +48,37 @@ function ensureValidJSON(object) {
* Authenticate with given credentials and return auth cookie
* Creates new account if username does not exist
* Only authenticates when portal is set to authenticated users only mode
* @param {boolean} forceAuth forcibly ensure authentication with test credentials
*/
function getAuthCookie() {
function getAuthCookie(forceAuth = false) {
// cache auth promise so only one actual request will be made
if (getAuthCookie.cache) return getAuthCookie.cache;
// do not authenticate if it is not necessary
if (!["authenticated", "subscription"].includes(process.env.ACCOUNTS_LIMIT_ACCESS)) return {};
// accounts disabled, do not try to authenticate
if (!isPortalModuleEnabled("a")) return "";
// do not authenticate if it is not required by portal limit access rule
if (!forceAuth && !["authenticated", "subscription"].includes(process.env.ACCOUNTS_LIMIT_ACCESS)) return "";
const portalDomain = process.env.PORTAL_DOMAIN;
const email = process.env.ACCOUNTS_TEST_USER_EMAIL;
const password = process.env.ACCOUNTS_TEST_USER_PASSWORD;
if (!email) throw new Error("ACCOUNTS_TEST_USER_EMAIL cannot be empty");
if (!password) throw new Error("ACCOUNTS_TEST_USER_PASSWORD cannot be empty");
try {
if (!portalDomain) throw new Error("PORTAL_DOMAIN cannot be empty");
if (!email) throw new Error("ACCOUNTS_TEST_USER_EMAIL cannot be empty");
if (!password) throw new Error("ACCOUNTS_TEST_USER_PASSWORD cannot be empty");
} catch (error) {
console.log(error.message);
process.exit(1);
}
async function authenticate() {
const got = require("got");
try {
// authenticate with given test user credentials
const response = await got.post(`${process.env.SKYNET_DASHBOARD_URL}/api/login`, {
const response = await got.post(`https://account.${process.env.PORTAL_DOMAIN}/api/login`, {
json: { email, password },
});
@ -84,7 +100,7 @@ function getAuthCookie() {
// 401 means that service worked but user could not have been authenticated
if (error.response && error.response.statusCode === 401) {
// sign up with the given credentials
await got.post(`${process.env.SKYNET_DASHBOARD_URL}/api/user`, {
await got.post(`https://account.${process.env.PORTAL_DOMAIN}/api/user`, {
json: { email, password },
});
@ -114,4 +130,6 @@ module.exports = {
ensureValidJSON,
getAuthCookie,
isPortalModuleEnabled,
ipCheckService,
ipRegex,
};

View File

@ -0,0 +1,19 @@
describe("ipRegex", () => {
const { ipRegex } = require("./utils");
test("should test true for valid ip", () => {
expect(ipRegex.test("8.8.8.8")).toEqual(true);
expect(ipRegex.test("127.0.0.1")).toEqual(true);
expect(ipRegex.test("192.168.0.1")).toEqual(true);
expect(ipRegex.test("10.10.10.10")).toEqual(true);
expect(ipRegex.test("135.124.12.47")).toEqual(true);
});
test("should test false for invalid ip", () => {
expect(ipRegex.test("888.8.8.8")).toEqual(false);
expect(ipRegex.test("....")).toEqual(false);
expect(ipRegex.test(null)).toEqual(false);
expect(ipRegex.test("foo")).toEqual(false);
expect(ipRegex.test("")).toEqual(false);
});
});

View File

@ -1,13 +1,18 @@
const http = require("http");
const { ipCheckService, ipRegex } = require("./utils");
const request = http.request({ host: "whatismyip.akamai.com" }, (response) => {
const request = http.request({ host: ipCheckService }, (response) => {
response.on("data", (data) => {
process.stdout.write(data);
if (ipRegex.test(data)) {
process.stdout.write(data);
} else {
throw new Error(`${ipCheckService} responded with invalid ip: "${data}"`);
}
});
});
request.on("error", (error) => {
console.error(error);
throw error; // throw error to exit with code 1
});
request.end();

File diff suppressed because it is too large Load Diff

View File

@ -104,3 +104,10 @@
gitlab: https://gitlab.com/ayoung_j
linkedin: https://www.linkedin.com/in/ajeon/
twitter: https://twitter.com/ayoung_jeon
- name: Michał Leszczyk
position: Full Stack Developer
image: ./team/michal-leszczyk.jpg
social:
github: https://github.com/meeh0w
linkedin: https://www.linkedin.com/in/micha%C5%82-leszczyk/

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View File

@ -44,7 +44,6 @@ module.exports = {
`gatsby-plugin-svgr`,
`gatsby-plugin-robots-txt`,
`gatsby-transformer-sharp`,
`gatsby-transformer-json`,
`gatsby-transformer-yaml`,
{
resolve: `gatsby-transformer-remark`,

View File

@ -5,38 +5,37 @@
"version": "0.1.0",
"author": "Skynet Labs.",
"dependencies": {
"@fontsource/sora": "4.5.1",
"@fontsource/source-sans-pro": "4.5.2",
"@svgr/webpack": "6.2.0",
"@fontsource/sora": "4.5.2",
"@fontsource/source-sans-pro": "4.5.3",
"@svgr/webpack": "6.2.1",
"bytes": "3.1.2",
"classnames": "2.3.1",
"copy-text-to-clipboard": "3.0.1",
"crypto-browserify": "3.12.0",
"framer-motion": "6.2.3",
"gatsby": "4.5.4",
"framer-motion": "6.2.4",
"gatsby": "4.7.1",
"gatsby-background-image": "1.6.0",
"gatsby-plugin-image": "2.6.0",
"gatsby-plugin-manifest": "4.6.0",
"gatsby-plugin-image": "2.7.0",
"gatsby-plugin-manifest": "4.7.0",
"gatsby-plugin-matomo": "0.11.0",
"gatsby-plugin-offline": "5.6.0",
"gatsby-plugin-postcss": "5.6.0",
"gatsby-plugin-offline": "5.7.0",
"gatsby-plugin-postcss": "5.7.0",
"gatsby-plugin-purgecss": "6.1.0",
"gatsby-plugin-react-helmet": "5.6.0",
"gatsby-plugin-react-helmet": "5.7.0",
"gatsby-plugin-robots-txt": "1.7.0",
"gatsby-plugin-sharp": "4.6.0",
"gatsby-plugin-sitemap": "5.6.0",
"gatsby-plugin-sharp": "4.7.0",
"gatsby-plugin-sitemap": "5.7.0",
"gatsby-plugin-svgr": "3.0.0-beta.0",
"gatsby-remark-classes": "1.0.2",
"gatsby-remark-copy-linked-files": "5.6.0",
"gatsby-remark-images": "6.6.0",
"gatsby-remark-prismjs": "6.6.0",
"gatsby-remark-responsive-iframe": "5.6.0",
"gatsby-remark-smartypants": "5.6.0",
"gatsby-source-filesystem": "4.6.0",
"gatsby-transformer-json": "4.6.0",
"gatsby-transformer-remark": "5.6.0",
"gatsby-transformer-sharp": "4.6.0",
"gatsby-transformer-yaml": "4.6.0",
"gatsby-remark-copy-linked-files": "5.7.0",
"gatsby-remark-images": "6.7.0",
"gatsby-remark-prismjs": "6.7.0",
"gatsby-remark-responsive-iframe": "5.7.0",
"gatsby-remark-smartypants": "5.7.0",
"gatsby-source-filesystem": "4.7.0",
"gatsby-transformer-remark": "5.7.0",
"gatsby-transformer-sharp": "4.7.0",
"gatsby-transformer-yaml": "4.7.0",
"gbimage-bridge": "0.2.1",
"http-status-codes": "2.2.0",
"jsonp": "0.2.1",
@ -46,12 +45,12 @@
"path-browserify": "1.0.1",
"polished": "4.1.4",
"popmotion": "11.0.3",
"postcss": "8.4.5",
"postcss": "8.4.6",
"preact-svg-loader": "0.2.1",
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-dropzone": "11.5.1",
"react-dropzone": "12.0.2",
"react-helmet": "6.1.0",
"react-share": "4.4.0",
"react-svg-loader": "3.0.3",
@ -59,16 +58,16 @@
"react-use": "17.3.2",
"skynet-js": "4.0.23-beta",
"stream-browserify": "3.0.0",
"swr": "1.2.0"
"swr": "1.2.1"
},
"devDependencies": {
"@tailwindcss/typography": "0.5.1",
"autoprefixer": "10.4.2",
"cross-env": "7.0.3",
"cypress": "9.3.1",
"cypress": "9.4.1",
"cypress-file-upload": "5.0.8",
"prettier": "2.5.1",
"tailwindcss": "3.0.11"
"tailwindcss": "3.0.19"
},
"keywords": [
"gatsby"

View File

@ -26,7 +26,7 @@ const Navigation = ({ mode, uri }) => {
const windowSize = useWindowSize();
const isWindowTop = useWindowTop();
const { data: accounts } = useAccounts();
const accountsUrl = useAccountsUrl();
const createAccountsUrl = useAccountsUrl();
React.useEffect(() => {
setOpen(false);
@ -90,18 +90,18 @@ const Navigation = ({ mode, uri }) => {
{showLoginNavigation && (
<>
<Link href={`${accountsUrl}/auth/login`} className="button-link-primary">
<Link href={createAccountsUrl("/auth/login")} className="button-link-primary">
Log in
</Link>
<Link href={`${accountsUrl}/auth/registration`} className="button-primary">
<Link href={createAccountsUrl("/auth/registration")} className="button-primary">
Sign up
</Link>
</>
)}
{showAccountNavigation && (
<Link href={accountsUrl} className="button-primary">
<Link href={createAccountsUrl()} className="button-primary">
My account
</Link>
)}
@ -144,18 +144,18 @@ const Navigation = ({ mode, uri }) => {
<div className="flex items-center justify-center px-4 space-x-6">
{showLoginNavigation && (
<>
<Link href={`${accountsUrl}/auth/login`} className="button-secondary-light">
<Link href={createAccountsUrl("auth/login")} className="button-secondary-light">
Log in
</Link>
<Link href={`${accountsUrl}/auth/registration`} className="button-primary">
<Link href={createAccountsUrl("/auth/registration")} className="button-primary">
Sign up
</Link>
</>
)}
{showAccountNavigation && (
<Link href={accountsUrl} className="button-primary">
<Link href={createAccountsUrl()} className="button-primary">
My account
</Link>
)}

View File

@ -22,11 +22,11 @@ const getRootDirectory = (file) => {
};
const RegistrationLink = () => {
const accountsUrl = useAccountsUrl();
const createAccountsUrl = useAccountsUrl();
return (
<Link
href={`${accountsUrl}/auth/registration`}
href={createAccountsUrl("auth/registration")}
className="uppercase underline-primary hover:text-primary transition-colors duration-200"
>
Sign up
@ -35,11 +35,11 @@ const RegistrationLink = () => {
};
const LogInLink = () => {
const accountsUrl = useAccountsUrl();
const createAccountsUrl = useAccountsUrl();
return (
<Link
href={`${accountsUrl}/auth/login`}
href={createAccountsUrl("auth/login")}
className="uppercase underline-primary hover:text-primary transition-colors duration-200"
>
Log in
@ -91,7 +91,10 @@ const Uploader = () => {
}
}, [uploads]);
const { getRootProps, getInputProps, isDragActive, inputRef } = useDropzone({ onDrop: handleDrop });
const { getRootProps, getInputProps, isDragActive, inputRef } = useDropzone({
onDrop: handleDrop,
useFsAccessApi: false,
});
const inputElement = inputRef.current;
React.useEffect(() => {

View File

@ -3,6 +3,7 @@ import skynetClient from "./skynetClient";
export default function useAccountsUrl() {
const [url, setUrl] = React.useState("");
const createAccountsUrl = React.useCallback((path = "") => url && new URL(path, url).toString(), [url]);
React.useEffect(() => {
(async function resolve() {
@ -14,5 +15,5 @@ export default function useAccountsUrl() {
})();
}, [setUrl]);
return url;
return createAccountsUrl;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,9 @@
# Skynet Portal Setup Scripts
> :warning: This documentation is outdated and should be used for reference
only. Portal setup documentation is located at
https://docs.siasky.net/webportal-management/overview.
This directory contains a setup guide and scripts that will install and
configure some basic requirements for running a Skynet Portal. The assumption is
that we are working with a Debian Buster Minimal system or similar.

View File

@ -27,7 +27,7 @@ if len(sys.argv) > 2:
CONTAINER_NAME = sys.argv[2]
# sc_precision is the number of hastings per siacoin
sc_precision = 10 ** 24
sc_precision = 10**24
# Environment variable globals
setup_done = False