mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Remove fz_vpn, fz_wall, Omnibus and start restructuring apps
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
[codespell]
|
||||
skip = ./www/docs/reference/api/*.mdx,./erl_crash.dump,./apps/fz_http/erl_crash.dump,./cover,./vendor,./omnibus,*.json,yarn.lock,seeds.exs,./**/node_modules,./deps,./priv/static,./priv/plts,./**/priv/static,./.git,./www/build,./_build
|
||||
skip = ./www/docs/reference/api/*.mdx,./erl_crash.dump,./apps/*/erl_crash.dump,./cover,./vendor,*.json,yarn.lock,seeds.exs,./**/node_modules,./deps,./priv/static,./priv/plts,./**/priv/static,./.git,./www/build,./_build
|
||||
ignore-words-list = crate,keypair,keypairs,iif,statics,wee,anull
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
apps/fz_http/assets/node_modules
|
||||
apps/fz_http/priv/static/dist
|
||||
apps/fz_http/priv/cert
|
||||
apps/web/assets/node_modules
|
||||
apps/web/priv/static/dist
|
||||
apps/web/priv/cert
|
||||
_build
|
||||
**/cover
|
||||
docs
|
||||
|
||||
166
.github/workflows/omnibus_build.yml
vendored
166
.github/workflows/omnibus_build.yml
vendored
@@ -1,166 +0,0 @@
|
||||
# We're running on a self-hosted runner, so only allow one workflow to run at a
|
||||
# time.
|
||||
concurrency: build
|
||||
|
||||
name: Omnibus Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- "build/**"
|
||||
|
||||
jobs:
|
||||
draft-release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tag_name: ${{ steps.release_drafter.outputs.tag_name }}
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
id: release_drafter
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
build-package-test:
|
||||
# Doesn't really need, but don't run this stage when iterating over website
|
||||
needs: draft-release
|
||||
env:
|
||||
TELEMETRY_ENABLED: "false"
|
||||
TERMINFO: /usr/lib/terminfo
|
||||
runs-on: ${{ matrix.platform }}
|
||||
strategy:
|
||||
# Failing fast breaks the Omnibus build cache because the job is
|
||||
# interrupted abruptly, leaving behind index.lock files.
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
# ARM-based
|
||||
- amazonlinux2-arm64
|
||||
- centos9-arm64
|
||||
- debian10-arm64
|
||||
- debian11-arm64
|
||||
- fedora33-arm64
|
||||
- fedora34-arm64
|
||||
- fedora35-arm64
|
||||
- ubuntu1804-arm64
|
||||
- ubuntu2004-arm64
|
||||
|
||||
# x64-based
|
||||
- amazonlinux2-x64
|
||||
- centos7-x64
|
||||
- centos8-x64
|
||||
- centos9-x64
|
||||
- debian10-x64
|
||||
- debian11-x64
|
||||
- fedora33-x64
|
||||
- fedora34-x64
|
||||
- fedora35-x64
|
||||
- ubuntu1804-x64
|
||||
- ubuntu2004-x64
|
||||
- opensuse15-x64
|
||||
steps:
|
||||
- run: cat /sys/module/wireguard/version
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
env:
|
||||
GIT_SHA: ${{ github.sha }}
|
||||
VERSION: ${{ needs.draft-release.outputs.tag_name }}
|
||||
run: |
|
||||
echo "removing lock file in case last run sucked"
|
||||
sudo rm -f /opt/runner/omnibus-local/cache/git_cache/opt/firezone/index.lock
|
||||
|
||||
# Load newer git on CentOS 7
|
||||
if test -f /opt/rh/rh-git227/enable; then
|
||||
. /opt/rh/rh-git227/enable
|
||||
fi
|
||||
|
||||
. $HOME/.asdf/asdf.sh
|
||||
asdf update
|
||||
asdf plugin-add ruby || asdf plugin-update ruby
|
||||
asdf install ruby
|
||||
|
||||
# Needed for building assets later on
|
||||
asdf plugin-add nodejs || asdf plugin-update nodejs
|
||||
asdf install nodejs
|
||||
npm install --global yarn
|
||||
|
||||
# CentOS 7 has path issues when this runs and doesn't have the
|
||||
# devtools loaded
|
||||
if test -f /opt/rh/devtoolset-9/enable; then
|
||||
. /opt/rh/devtoolset-9/enable
|
||||
fi
|
||||
|
||||
gem install bundler
|
||||
cd omnibus
|
||||
bundle install --binstubs
|
||||
sudo mkdir -p /opt/firezone
|
||||
sudo chown -R $USER /opt/firezone
|
||||
bin/omnibus build firezone
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: firezone-${{ matrix.platform }}
|
||||
path: |
|
||||
omnibus/pkg/firezone*.deb
|
||||
omnibus/pkg/firezone*.rpm
|
||||
- name: Functional Test
|
||||
run: |
|
||||
.ci/functional_test.sh
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
sudo scripts/omnibus-uninstall.sh
|
||||
sudo rm -rf /tmp/firezone*
|
||||
rm -rf omnibus/pkg/*
|
||||
|
||||
# Publish packages to the drafted release on merges to master so we can
|
||||
# manually test them if needed. Then we can just publish the drafted release
|
||||
# and we're good to go.
|
||||
publish:
|
||||
if: startsWith(github.ref, 'refs/heads/master')
|
||||
needs:
|
||||
- build-package-test
|
||||
- draft-release
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
# ARM-based
|
||||
- amazonlinux2-arm64
|
||||
- centos9-arm64
|
||||
- debian10-arm64
|
||||
- debian11-arm64
|
||||
- fedora33-arm64
|
||||
- fedora34-arm64
|
||||
- fedora35-arm64
|
||||
- ubuntu1804-arm64
|
||||
- ubuntu2004-arm64
|
||||
|
||||
# x64-based
|
||||
- amazonlinux2-x64
|
||||
- centos7-x64
|
||||
- centos8-x64
|
||||
- centos9-x64
|
||||
- debian10-x64
|
||||
- debian11-x64
|
||||
- fedora33-x64
|
||||
- fedora34-x64
|
||||
- fedora35-x64
|
||||
- ubuntu1804-x64
|
||||
- ubuntu2004-x64
|
||||
- opensuse15-x64
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: firezone-${{ matrix.platform }}
|
||||
path: ./
|
||||
- name: Rename artifact file to tag
|
||||
run: |
|
||||
mv ./firezone*.rpm firezone_${{ needs.draft-release.outputs.tag_name }}-${{ matrix.platform }}.rpm || true
|
||||
mv ./firezone*.deb firezone_${{ needs.draft-release.outputs.tag_name }}-${{ matrix.platform }}.deb || true
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ needs.draft-release.outputs.tag_name }}
|
||||
draft: true
|
||||
files: |
|
||||
./firezone*.rpm
|
||||
./firezone*.deb
|
||||
183
.github/workflows/omnibus_publish.yml
vendored
183
.github/workflows/omnibus_publish.yml
vendored
@@ -1,183 +0,0 @@
|
||||
name: Publish to Cloudsmith
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# ARM-based
|
||||
- platform: amazonlinux2-arm64
|
||||
distro: amzn
|
||||
release: '2'
|
||||
- platform: centos9-arm64
|
||||
distro: el
|
||||
release: '9'
|
||||
- platform: debian10-arm64
|
||||
distro: debian
|
||||
release: buster
|
||||
- platform: debian11-arm64
|
||||
distro: debian
|
||||
release: bullseye
|
||||
- platform: debian10-arm64
|
||||
distro: raspbian
|
||||
release: buster
|
||||
- platform: debian11-arm64
|
||||
distro: raspbian
|
||||
release: bullseye
|
||||
- platform: fedora33-arm64
|
||||
distro: fedora
|
||||
release: '33'
|
||||
- platform: fedora34-arm64
|
||||
distro: fedora
|
||||
release: '34'
|
||||
- platform: fedora35-arm64
|
||||
distro: fedora
|
||||
release: '35'
|
||||
- platform: fedora35-arm64
|
||||
distro: fedora
|
||||
release: '36'
|
||||
- platform: ubuntu1804-arm64
|
||||
distro: ubuntu
|
||||
release: bionic
|
||||
- platform: ubuntu2004-arm64
|
||||
distro: ubuntu
|
||||
release: focal
|
||||
- platform: ubuntu2004-arm64
|
||||
distro: ubuntu
|
||||
release: hirsute
|
||||
- platform: ubuntu2004-arm64
|
||||
distro: ubuntu
|
||||
release: jammy
|
||||
|
||||
# x64-based
|
||||
- platform: amazonlinux2-x64
|
||||
distro: amzn
|
||||
release: '2'
|
||||
- platform: centos7-x64
|
||||
distro: el
|
||||
release: '7'
|
||||
- platform: centos8-x64
|
||||
distro: el
|
||||
release: '8'
|
||||
- platform: centos9-x64
|
||||
distro: el
|
||||
release: '9'
|
||||
- platform: centos8-x64
|
||||
distro: rocky
|
||||
release: '8.3'
|
||||
- platform: centos8-x64
|
||||
distro: rocky
|
||||
release: '8.4'
|
||||
- platform: centos8-x64
|
||||
distro: rocky
|
||||
release: '8.5'
|
||||
- platform: centos8-x64
|
||||
distro: rocky
|
||||
release: '8.6'
|
||||
- platform: centos8-x64
|
||||
distro: almalinux
|
||||
release: '8.3'
|
||||
- platform: centos8-x64
|
||||
distro: almalinux
|
||||
release: '8.4'
|
||||
- platform: centos8-x64
|
||||
distro: almalinux
|
||||
release: '8.5'
|
||||
- platform: debian10-x64
|
||||
distro: debian
|
||||
release: buster
|
||||
- platform: debian11-x64
|
||||
distro: debian
|
||||
release: bullseye
|
||||
- platform: fedora33-x64
|
||||
distro: fedora
|
||||
release: '33'
|
||||
- platform: fedora34-x64
|
||||
distro: fedora
|
||||
release: '34'
|
||||
- platform: fedora35-x64
|
||||
distro: fedora
|
||||
release: '35'
|
||||
- platform: fedora35-x64
|
||||
distro: fedora
|
||||
release: '36'
|
||||
- platform: ubuntu1804-x64
|
||||
distro: ubuntu
|
||||
release: bionic
|
||||
- platform: ubuntu2004-x64
|
||||
distro: ubuntu
|
||||
release: focal
|
||||
- platform: ubuntu2004-x64
|
||||
distro: ubuntu
|
||||
release: hirsute
|
||||
- platform: ubuntu2004-x64
|
||||
distro: ubuntu
|
||||
release: jammy
|
||||
- platform: opensuse15-x64
|
||||
distro: opensuse
|
||||
release: '15.1'
|
||||
- platform: opensuse15-x64
|
||||
distro: opensuse
|
||||
release: '15.2'
|
||||
- platform: opensuse15-x64
|
||||
distro: opensuse
|
||||
release: '15.3'
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
commit: ${{ github.sha }}
|
||||
workflow: omnibus_build.yml
|
||||
workflow_conclusion: success
|
||||
name: firezone-${{ matrix.platform }}
|
||||
|
||||
- name: Rename artifact file to tag
|
||||
run: |
|
||||
mv ./firezone*.rpm firezone_${{ github.ref_name }}-${{ matrix.platform }}.rpm || true
|
||||
mv ./firezone*.deb firezone_${{ github.ref_name }}-${{ matrix.platform }}.deb || true
|
||||
|
||||
- name: Check DEB
|
||||
uses: andstor/file-existence-action@v2
|
||||
id: check_deb
|
||||
with:
|
||||
files: firezone_${{ github.ref_name }}-${{ matrix.platform }}.deb
|
||||
|
||||
- name: Check RPM
|
||||
uses: andstor/file-existence-action@v2
|
||||
id: check_rpm
|
||||
with:
|
||||
files: firezone_${{ github.ref_name }}-${{ matrix.platform }}.rpm
|
||||
|
||||
- name: Pubslih RPM
|
||||
uses: cloudsmith-io/action@master
|
||||
if: steps.check_rpm.outputs.files_exists == 'true'
|
||||
with:
|
||||
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
|
||||
command: 'push'
|
||||
format: 'rpm'
|
||||
owner: 'firezone'
|
||||
repo: 'firezone'
|
||||
distro: ${{ matrix.distro }}
|
||||
release: ${{ matrix.release }}
|
||||
republish: 'true'
|
||||
file: firezone_${{ github.ref_name }}-${{ matrix.platform }}.rpm
|
||||
|
||||
- name: Publish DEB
|
||||
uses: cloudsmith-io/action@master
|
||||
if: steps.check_deb.outputs.files_exists == 'true'
|
||||
with:
|
||||
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
|
||||
command: 'push'
|
||||
format: 'deb'
|
||||
owner: 'firezone'
|
||||
repo: 'firezone'
|
||||
distro: ${{ matrix.distro }}
|
||||
release: ${{ matrix.release }}
|
||||
republish: 'true'
|
||||
file: firezone_${{ github.ref_name }}-${{ matrix.platform }}.deb
|
||||
16
.github/workflows/static_analysis.yml
vendored
16
.github/workflows/static_analysis.yml
vendored
@@ -18,11 +18,8 @@ jobs:
|
||||
node-version: '16'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: |
|
||||
apps/fz_http/assets/package-lock.json
|
||||
apps/web/assets/package-lock.json
|
||||
www/yarn.lock
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '2.7'
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9'
|
||||
@@ -42,13 +39,6 @@ jobs:
|
||||
key: ${{ github.workflow }}-${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
|
||||
restore-keys: |
|
||||
${{ github.workflow }}-${{ runner.os }}-${{ env.cache-name }}-
|
||||
- uses: actions/cache@v3.0.11
|
||||
name: Setup ruby cache
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gems-
|
||||
- uses: actions/cache@v3.0.11
|
||||
name: Setup Python cache
|
||||
with:
|
||||
@@ -58,10 +48,6 @@ jobs:
|
||||
${{ runner.os }}-pip-
|
||||
- name: Install Elixir Dependencies
|
||||
run: mix deps.get --only $MIX_ENV
|
||||
- name: Install Ruby Dependencies
|
||||
run: |
|
||||
bundle config path vendor/bundle
|
||||
bundle install --jobs 4 --retry 3
|
||||
- name: Install Python Dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
|
||||
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@@ -167,7 +167,6 @@ jobs:
|
||||
MIX_ENV: dev
|
||||
POSTGRES_HOST: localhost
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
FZ_VPN_WG_ADAPTER: FzVpn.Interface.WGAdapter.Sandbox
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
@@ -223,7 +222,7 @@ jobs:
|
||||
with:
|
||||
branch: master
|
||||
name: db-dump
|
||||
path: apps/fz_http/priv/repo/
|
||||
path: apps/web/priv/repo/
|
||||
search_artifacts: true
|
||||
workflow_conclusion: completed
|
||||
if_no_artifact_found: fail
|
||||
@@ -246,7 +245,7 @@ jobs:
|
||||
run: |
|
||||
pg_dump firezone_dev \
|
||||
-U postgres -h localhost \
|
||||
--file apps/fz_http/priv/repo/structure.sql \
|
||||
--file apps/web/priv/repo/structure.sql \
|
||||
--no-acl \
|
||||
--no-owner
|
||||
- name: Upload master branch DB dump
|
||||
@@ -254,7 +253,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: db-dump
|
||||
path: apps/fz_http/priv/repo/structure.sql
|
||||
path: apps/web/priv/repo/structure.sql
|
||||
- name: Run Seed
|
||||
run: mix ecto.seed
|
||||
acceptance-test:
|
||||
@@ -338,14 +337,14 @@ jobs:
|
||||
env:
|
||||
cache-name: cache-yarn-build-${{ env.MIX_ENV }}
|
||||
with:
|
||||
path: apps/fz_http/assets/node_modules
|
||||
path: apps/web/assets/node_modules
|
||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
|
||||
- uses: actions/cache@v3
|
||||
name: Assets Cache
|
||||
env:
|
||||
cache-name: cache-assets-build-${{ env.MIX_ENV }}
|
||||
with:
|
||||
path: apps/fz_http/priv/static/dist
|
||||
path: apps/web/priv/static/dist
|
||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
|
||||
- name: Install Dependencies
|
||||
run: mix deps.get --only $MIX_ENV
|
||||
@@ -355,11 +354,11 @@ jobs:
|
||||
run: mix compile
|
||||
- name: Install Node Dependencies
|
||||
run: |
|
||||
cd apps/fz_http/assets
|
||||
cd apps/web/assets
|
||||
yarn install --frozen-lockfile
|
||||
- name: Build Assets
|
||||
run: |
|
||||
cd apps/fz_http/assets
|
||||
cd apps/web/assets
|
||||
yarn deploy
|
||||
- name: Setup Database
|
||||
run: |
|
||||
@@ -384,7 +383,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: screenshots
|
||||
path: apps/fz_http/screenshots
|
||||
path: apps/web/screenshots
|
||||
- name: Test Report
|
||||
uses: dorny/test-reporter@v1
|
||||
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && (success() || failure()) }}
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -61,11 +61,13 @@ npm-debug.log
|
||||
/*.rpm
|
||||
|
||||
# Test screenshots
|
||||
apps/fz_http/screenshots
|
||||
apps/*/screenshots
|
||||
|
||||
# WG configs generated in acceptance tests
|
||||
*.conf
|
||||
|
||||
# Auto generated private key
|
||||
apps/fz_http/priv/wg_dev_private_key
|
||||
apps/fz_http/priv/static/uploads
|
||||
apps/web/priv/wg_dev_private_key
|
||||
|
||||
# Uploads
|
||||
apps/web/priv/static/uploads
|
||||
|
||||
@@ -29,12 +29,6 @@ repos:
|
||||
entry: codespell
|
||||
language: system
|
||||
pass_filenames: false
|
||||
- id: rubocop
|
||||
name: 'ruby: rubocop'
|
||||
entry: bundle exec rubocop
|
||||
language: system
|
||||
pass_filenames: false
|
||||
files: \.rb$
|
||||
- id: markdownlint
|
||||
name: 'nodejs: markdownlint'
|
||||
entry: ./docs/node_modules/markdownlint-cli/markdownlint.js
|
||||
@@ -52,9 +46,7 @@ repos:
|
||||
- id: check-yaml
|
||||
- id: check-merge-conflict
|
||||
- id: end-of-file-fixer
|
||||
exclude: "^omnibus/config/patches/"
|
||||
- id: trailing-whitespace
|
||||
exclude: "^omnibus/config/patches/"
|
||||
- id: check-merge-conflict
|
||||
- id: no-commit-to-branch
|
||||
args:
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.7
|
||||
Exclude:
|
||||
- "vendor/**/*"
|
||||
- "apps/fz_http/assets/node_modules/**/*"
|
||||
- "omnibus/cookbooks/firezone/attributes/default.rb"
|
||||
@@ -5,5 +5,4 @@ elixir 1.14.3-otp-25
|
||||
erlang 25.2.1
|
||||
|
||||
# Used for static analysis
|
||||
ruby 2.7.6
|
||||
python 3.9.13
|
||||
|
||||
@@ -37,23 +37,23 @@ ENV DATABASE_PASSWORD=$DATABASE_PASSWORD
|
||||
|
||||
RUN mix local.hex --force && mix local.rebar --force
|
||||
|
||||
COPY apps/fz_http/mix.exs /var/app/apps/fz_http/mix.exs
|
||||
COPY apps/fz_vpn/mix.exs /var/app/apps/fz_vpn/mix.exs
|
||||
COPY apps/fz_wall/mix.exs /var/app/apps/fz_wall/mix.exs
|
||||
COPY apps/domain/mix.exs /var/app/apps/web/mix.exs
|
||||
COPY apps/web/mix.exs /var/app/apps/web/mix.exs
|
||||
COPY apps/api/mix.exs /var/app/apps/api/mix.exs
|
||||
COPY mix.exs /var/app/mix.exs
|
||||
COPY mix.lock /var/app/mix.lock
|
||||
RUN mix do deps.get, deps.compile, compile
|
||||
|
||||
# Copy more granular, dependency management files first to prevent
|
||||
# busting the Docker build cache unnecessarily
|
||||
COPY apps/fz_http/assets/package.json /var/app/apps/fz_http/assets/package.json
|
||||
COPY apps/fz_http/assets/local_modules /var/app/apps/fz_http/assets/local_modules
|
||||
COPY apps/fz_http/assets/yarn.lock /var/app/apps/fz_http/assets/yarn.lock
|
||||
RUN cd apps/fz_http/assets && yarn install
|
||||
COPY apps/web/assets/package.json /var/app/apps/web/assets/package.json
|
||||
COPY apps/web/assets/local_modules /var/app/apps/web/assets/local_modules
|
||||
COPY apps/web/assets/yarn.lock /var/app/apps/web/assets/yarn.lock
|
||||
RUN cd apps/web/assets && yarn install
|
||||
|
||||
COPY config /var/app/config
|
||||
COPY apps /var/app/apps
|
||||
RUN cd apps/fz_http && mix phx.gen.cert
|
||||
RUN cd apps/web && mix phx.gen.cert
|
||||
|
||||
COPY scripts/dev_start.sh /var/app/dev_start.sh
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ ENV MIX_ENV="prod"
|
||||
|
||||
# install mix dependencies
|
||||
COPY mix.exs mix.lock ./
|
||||
COPY apps/fz_http/mix.exs ./apps/fz_http/mix.exs
|
||||
COPY apps/fz_vpn/mix.exs ./apps/fz_vpn/mix.exs
|
||||
COPY apps/fz_wall/mix.exs ./apps/fz_wall/mix.exs
|
||||
COPY apps/domain/mix.exs ./apps/domain/mix.exs
|
||||
COPY apps/web/mix.exs ./apps/web/mix.exs
|
||||
COPY apps/api/mix.exs ./apps/api/mix.exs
|
||||
|
||||
RUN mix deps.get --only $MIX_ENV
|
||||
RUN mkdir config
|
||||
@@ -38,12 +38,12 @@ RUN mix deps.compile
|
||||
COPY priv priv
|
||||
COPY apps apps
|
||||
|
||||
# mix phx.digest triggers fz_http compilation, need version to be set here
|
||||
# mix phx.digest triggers web compilation, need version to be set here
|
||||
ARG VERSION=0.0.0-docker
|
||||
ENV VERSION=$VERSION
|
||||
|
||||
# compile assets
|
||||
RUN cd apps/fz_http/assets \
|
||||
RUN cd apps/web/assets \
|
||||
&& yarn install --frozen-lockfile \
|
||||
&& yarn deploy \
|
||||
&& cd .. \
|
||||
|
||||
5
Gemfile
5
Gemfile
@@ -1,5 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rubocop'
|
||||
35
Gemfile.lock
35
Gemfile.lock
@@ -1,35 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
ast (2.4.2)
|
||||
json (2.6.3)
|
||||
parallel (1.22.1)
|
||||
parser (3.2.1.1)
|
||||
ast (~> 2.4.1)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.7.0)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.48.1)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.2.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.26.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.27.0)
|
||||
parser (>= 3.2.1.0)
|
||||
ruby-progressbar (1.13.0)
|
||||
unicode-display_width (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-21
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
rubocop
|
||||
|
||||
BUNDLED WITH
|
||||
2.3.14
|
||||
@@ -1,93 +0,0 @@
|
||||
defmodule FzHttp.Events do
|
||||
@moduledoc """
|
||||
Handles interfacing with other processes in the system.
|
||||
"""
|
||||
|
||||
alias FzHttp.{Devices, Rules, Users, Notifications}
|
||||
|
||||
require Logger
|
||||
|
||||
# set_config is used because devices need to be re-evaluated in case a
|
||||
# device is added to a User that's not active.
|
||||
def add("devices", device) do
|
||||
with :ok <- GenServer.call(wall_pid(), {:add_device, Devices.setting_projection(device)}),
|
||||
:ok <- GenServer.call(vpn_pid(), {:set_config, Devices.to_peer_list()}) do
|
||||
:ok
|
||||
else
|
||||
_err ->
|
||||
Notifications.add(%{
|
||||
type: :error,
|
||||
message: """
|
||||
#{device.name} was created successfully but an error occurred applying its
|
||||
configuration to the WireGuard interface. Check the logs for more
|
||||
information.
|
||||
""",
|
||||
timestamp: DateTime.utc_now(),
|
||||
user: Users.fetch_user_by_id!(device.user_id).email
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
def add("rules", rule) do
|
||||
GenServer.call(wall_pid(), {:add_rule, Rules.setting_projection(rule)})
|
||||
end
|
||||
|
||||
def add("users", user) do
|
||||
# Security note: It's important to let an exception here crash this service
|
||||
# otherwise, nft could have succeeded in adding the user's set but not the rules
|
||||
# this means that in `update_device` add_device can succeed adding the device to the user's set
|
||||
# but any rule for the user won't take effect since the user rule doesn't exists.
|
||||
GenServer.call(wall_pid(), {:add_user, Users.setting_projection(user)})
|
||||
end
|
||||
|
||||
def delete("devices", device) do
|
||||
with :ok <- GenServer.call(wall_pid(), {:delete_device, Devices.setting_projection(device)}),
|
||||
:ok <- GenServer.call(vpn_pid(), {:remove_peer, device.public_key}) do
|
||||
:ok
|
||||
else
|
||||
_err ->
|
||||
Notifications.add(%{
|
||||
type: :error,
|
||||
message: """
|
||||
#{device.name} was deleted successfully but an error occurred applying its
|
||||
configuration to the WireGuard interface. Check the logs for more
|
||||
information.
|
||||
""",
|
||||
timestamp: DateTime.utc_now(),
|
||||
user: Users.fetch_user_by_id!(device.user_id).email
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
def delete("rules", rule) do
|
||||
GenServer.call(wall_pid(), {:delete_rule, Rules.setting_projection(rule)})
|
||||
end
|
||||
|
||||
def delete("users", user) do
|
||||
GenServer.call(wall_pid(), {:delete_user, Users.setting_projection(user)})
|
||||
end
|
||||
|
||||
def set_config do
|
||||
GenServer.call(vpn_pid(), {:set_config, Devices.to_peer_list()})
|
||||
end
|
||||
|
||||
def set_rules do
|
||||
GenServer.call(
|
||||
wall_pid(),
|
||||
{:set_rules,
|
||||
%{
|
||||
users: Users.as_settings(),
|
||||
devices: Devices.as_settings(),
|
||||
rules: Rules.as_settings()
|
||||
}}
|
||||
)
|
||||
end
|
||||
|
||||
def vpn_pid do
|
||||
:global.whereis_name(:fz_vpn_server)
|
||||
end
|
||||
|
||||
def wall_pid do
|
||||
:global.whereis_name(:fz_wall_server)
|
||||
end
|
||||
end
|
||||
@@ -1,101 +0,0 @@
|
||||
defmodule FzHttp.Notifications do
|
||||
@moduledoc """
|
||||
Notification notifications for notifications live view.
|
||||
"""
|
||||
use GenServer
|
||||
|
||||
@topic "notifications_live"
|
||||
alias Phoenix.PubSub
|
||||
|
||||
def start_link(opts \\ []) do
|
||||
if opts[:name] do
|
||||
GenServer.start_link(__MODULE__, [], name: opts[:name])
|
||||
else
|
||||
GenServer.start_link(__MODULE__, [])
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a list of current notifications.
|
||||
"""
|
||||
def current, do: current(__MODULE__)
|
||||
def current(nil), do: current()
|
||||
def current(pid), do: GenServer.call(pid, :current)
|
||||
|
||||
@doc """
|
||||
Add a notification.
|
||||
"""
|
||||
def add(notification), do: add(__MODULE__, notification)
|
||||
def add(nil, notification), do: add(notification)
|
||||
def add(pid, notification), do: GenServer.call(pid, {:add, notification})
|
||||
|
||||
@doc """
|
||||
Clear all notifications.
|
||||
"""
|
||||
def clear_all, do: clear_all(__MODULE__)
|
||||
def clear_all(nil), do: clear_all()
|
||||
def clear_all(pid), do: GenServer.call(pid, :clear_all)
|
||||
|
||||
@doc """
|
||||
Clear the given notification.
|
||||
"""
|
||||
def clear(notification), do: clear(__MODULE__, notification)
|
||||
def clear(nil, notification), do: clear(notification)
|
||||
def clear(pid, notification), do: GenServer.call(pid, {:clear, notification})
|
||||
|
||||
@doc """
|
||||
Clear a notification at the given index.
|
||||
"""
|
||||
def clear_at(index), do: clear_at(__MODULE__, index)
|
||||
def clear_at(nil, index), do: clear_at(index)
|
||||
def clear_at(pid, index), do: GenServer.call(pid, {:clear_at, index})
|
||||
|
||||
defp broadcast(notifications) do
|
||||
PubSub.broadcast(
|
||||
FzHttp.PubSub,
|
||||
@topic,
|
||||
{:notifications, notifications}
|
||||
)
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def init(notifications) do
|
||||
{:ok, notifications}
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def handle_call(:current, _from, notifications) do
|
||||
{:reply, notifications, notifications}
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def handle_call({:add, notification}, _from, notifications) do
|
||||
new_notifications = [notification | notifications]
|
||||
broadcast(new_notifications)
|
||||
|
||||
{:reply, :ok, new_notifications}
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def handle_call(:clear_all, _from, _notifications) do
|
||||
broadcast([])
|
||||
|
||||
{:reply, :ok, []}
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def handle_call({:clear, notification}, _from, notifications) do
|
||||
new_notifications = Enum.reject(notifications, &(&1 == notification))
|
||||
broadcast(new_notifications)
|
||||
|
||||
{:reply, :ok, new_notifications}
|
||||
end
|
||||
|
||||
@impl GenServer
|
||||
def handle_call({:clear_at, index}, _from, notifications) do
|
||||
{_, new_notifications} = List.pop_at(notifications, index)
|
||||
broadcast(new_notifications)
|
||||
|
||||
{:reply, :ok, new_notifications}
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
[
|
||||
locals_without_parens: [],
|
||||
import_deps: [],
|
||||
inputs: [
|
||||
"*.{ex,exs}",
|
||||
"{lib,test,priv}/**/*.{ex,exs}"
|
||||
],
|
||||
plugins: []
|
||||
]
|
||||
23
apps/fz_vpn/.gitignore
vendored
23
apps/fz_vpn/.gitignore
vendored
@@ -1,23 +0,0 @@
|
||||
# The directory Mix will write compiled artifacts to.
|
||||
/_build/
|
||||
|
||||
# If you run "mix test --cover", coverage assets end up here.
|
||||
/cover/
|
||||
|
||||
# The directory Mix downloads your dependencies sources to.
|
||||
/deps/
|
||||
|
||||
# Where third-party dependencies like ExDoc output generated docs.
|
||||
/doc/
|
||||
|
||||
# Ignore .fetch files in case you like to edit your project deps locally.
|
||||
/.fetch
|
||||
|
||||
# If the VM crashes, it generates a dump, let's ignore it too.
|
||||
erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore package tarball (built via "mix hex.build").
|
||||
cf_vpn-*.tar
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user