mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Initial commit
This commit is contained in:
5
.formatter.exs
Normal file
5
.formatter.exs
Normal file
@@ -0,0 +1,5 @@
|
||||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["mix.exs", "config/*.exs"],
|
||||
subdirectories: ["apps/*"]
|
||||
]
|
||||
41
.github/scripts/release.sh
vendored
Normal file
41
.github/scripts/release.sh
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
# This script scp'd to the build host and executed to create a new release.
|
||||
|
||||
orig_dir=`pwd`
|
||||
|
||||
# Some preliminary housekeeping
|
||||
rm -rf /tmp/cloudfire
|
||||
mkdir -p /tmp/cloudfire
|
||||
cd /tmp/cloudfire
|
||||
mv ~/cloudfire_web.tar .
|
||||
tar -xf cloudfire_web.tar
|
||||
|
||||
# Start build
|
||||
echo 'Building release for system:'
|
||||
uname -a
|
||||
|
||||
# Ensure MIX_ENV is prod throughout the build
|
||||
export MIX_ENV=prod
|
||||
|
||||
# Set terminal to UTF-8
|
||||
export LC_CTYPE="en_US.UTF-8"
|
||||
|
||||
# Set required env vars for the app to boot. These will not be used.
|
||||
export DATABASE_URL="ecto://dummy:dummy@dummy/dummy"
|
||||
export SECRET_KEY_BASE="dummy"
|
||||
|
||||
# Fetch dependencies, compile, compile static assets
|
||||
mix local.hex --force
|
||||
mix local.rebar --force
|
||||
mix deps.get --only prod
|
||||
mix compile
|
||||
cd assets
|
||||
npm install
|
||||
cd ..
|
||||
npm run deploy --prefix ./assets
|
||||
mix phx.digest
|
||||
mix release
|
||||
|
||||
# XXX: Append version number to release tarball
|
||||
tar -zcf $HOME/release.tar.gz _build
|
||||
46
.github/workflows/main.yml
vendored
Normal file
46
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
- release
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
MIX_ENV: test
|
||||
POSTGRES_HOST: localhost
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:12
|
||||
ports:
|
||||
- 5432:5432
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run Static Tests
|
||||
uses: actions/setup-elixir@v1
|
||||
with:
|
||||
elixir-version: 1.10.2
|
||||
otp-version: 22.3.2
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
cd cloudfire_umbrella/
|
||||
mix deps.get --only test
|
||||
- name: Setup Database
|
||||
run: |
|
||||
cd cloudfire_umbrella
|
||||
mix ecto.create
|
||||
mix ecto.migrate
|
||||
- name: Run Tests
|
||||
run: |
|
||||
cd cloudfire_umbrella/
|
||||
mix test
|
||||
37
.gitignore
vendored
Normal file
37
.gitignore
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# macOS cruft
|
||||
.DS_Store
|
||||
|
||||
# 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 3rd-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
|
||||
|
||||
# If NPM crashes, it generates a log, let's ignore it too.
|
||||
npm-debug.log
|
||||
|
||||
# Assets should be served by a CDN, not tracked in version control
|
||||
/assets/static
|
||||
|
||||
# The directory NPM downloads your dependencies sources to.
|
||||
/assets/node_modules/
|
||||
|
||||
# Since we are building assets from assets/,
|
||||
# we ignore priv/static. You may want to comment
|
||||
# this depending on your deployment strategy.
|
||||
/priv/static/
|
||||
3
.tool-versions
Normal file
3
.tool-versions
Normal file
@@ -0,0 +1,3 @@
|
||||
elixir 1.10.2-otp-22
|
||||
erlang 22.3.2
|
||||
nodejs 10.20.0
|
||||
201
LICENSE
Normal file
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 Engineering
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# CloudFire
|
||||
|
||||
Under active development. Check back later.
|
||||
5
apps/cloudfire/.formatter.exs
Normal file
5
apps/cloudfire/.formatter.exs
Normal file
@@ -0,0 +1,5 @@
|
||||
[
|
||||
import_deps: [:ecto, :phoenix],
|
||||
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
|
||||
subdirectories: ["priv/*/migrations"]
|
||||
]
|
||||
37
apps/cloudfire/.gitignore
vendored
Normal file
37
apps/cloudfire/.gitignore
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# macOS cruft
|
||||
.DS_Store
|
||||
|
||||
# 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 3rd-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").
|
||||
cloudfire-*.tar
|
||||
|
||||
# If NPM crashes, it generates a log, let's ignore it too.
|
||||
npm-debug.log
|
||||
|
||||
# The directory NPM downloads your dependencies sources to.
|
||||
/assets/node_modules/
|
||||
|
||||
# Since we are building assets from assets/,
|
||||
# we ignore priv/static. You may want to comment
|
||||
# this depending on your deployment strategy.
|
||||
/priv/static/
|
||||
1
apps/cloudfire/.tool-versions
Normal file
1
apps/cloudfire/.tool-versions
Normal file
@@ -0,0 +1 @@
|
||||
elixir 1.9.1-otp-21
|
||||
3
apps/cloudfire/README.md
Normal file
3
apps/cloudfire/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Cloudfire
|
||||
|
||||
|
||||
9
apps/cloudfire/lib/cloudfire.ex
Normal file
9
apps/cloudfire/lib/cloudfire.ex
Normal file
@@ -0,0 +1,9 @@
|
||||
defmodule Cloudfire do
|
||||
@moduledoc """
|
||||
Cloudfire keeps the contexts that define your domain
|
||||
and business logic.
|
||||
|
||||
Contexts are also responsible for managing your data, regardless
|
||||
if it comes from the database, an external API or others.
|
||||
"""
|
||||
end
|
||||
31
apps/cloudfire/lib/cloudfire/application.ex
Normal file
31
apps/cloudfire/lib/cloudfire/application.ex
Normal file
@@ -0,0 +1,31 @@
|
||||
defmodule Cloudfire.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
def start(_type, _args) do
|
||||
# List all child processes to be supervised
|
||||
children = [
|
||||
# Start the Ecto repository
|
||||
Cloudfire.Repo,
|
||||
# Start the endpoint when the application starts
|
||||
CloudfireWeb.Endpoint
|
||||
# Starts a worker by calling: Cloudfire.Worker.start_link(arg)
|
||||
# {Cloudfire.Worker, arg},
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Cloudfire.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
# whenever the application is updated.
|
||||
def config_change(changed, _new, removed) do
|
||||
CloudfireWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
104
apps/cloudfire/lib/cloudfire/devices.ex
Normal file
104
apps/cloudfire/lib/cloudfire/devices.ex
Normal file
@@ -0,0 +1,104 @@
|
||||
defmodule Cloudfire.Devices do
|
||||
@moduledoc """
|
||||
The Devices context.
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Cloudfire.Repo
|
||||
|
||||
alias Cloudfire.Devices.Device
|
||||
|
||||
@doc """
|
||||
Returns the list of devices.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> list_devices()
|
||||
[%Device{}, ...]
|
||||
|
||||
"""
|
||||
def list_devices do
|
||||
Repo.all(Device)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a single device.
|
||||
|
||||
Raises `Ecto.NoResultsError` if the Device does not exist.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> get_device!(123)
|
||||
%Device{}
|
||||
|
||||
iex> get_device!(456)
|
||||
** (Ecto.NoResultsError)
|
||||
|
||||
"""
|
||||
def get_device!(id), do: Repo.get!(Device, id)
|
||||
|
||||
@doc """
|
||||
Creates a device.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> create_device(%{field: value})
|
||||
{:ok, %Device{}}
|
||||
|
||||
iex> create_device(%{field: bad_value})
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def create_device(attrs \\ %{}) do
|
||||
%Device{}
|
||||
|> Device.changeset(attrs)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Updates a device.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> update_device(device, %{field: new_value})
|
||||
{:ok, %Device{}}
|
||||
|
||||
iex> update_device(device, %{field: bad_value})
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def update_device(%Device{} = device, attrs) do
|
||||
device
|
||||
|> Device.changeset(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes a device.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> delete_device(device)
|
||||
{:ok, %Device{}}
|
||||
|
||||
iex> delete_device(device)
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def delete_device(%Device{} = device) do
|
||||
Repo.delete(device)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns an `%Ecto.Changeset{}` for tracking device changes.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> change_device(device)
|
||||
%Ecto.Changeset{source: %Device{}}
|
||||
|
||||
"""
|
||||
def change_device(%Device{} = device) do
|
||||
Device.changeset(device, %{})
|
||||
end
|
||||
end
|
||||
22
apps/cloudfire/lib/cloudfire/devices/device.ex
Normal file
22
apps/cloudfire/lib/cloudfire/devices/device.ex
Normal file
@@ -0,0 +1,22 @@
|
||||
defmodule Cloudfire.Devices.Device do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "devices" do
|
||||
field :name, :string
|
||||
field :public_key, :string
|
||||
field :verified_at, :utc_datetime
|
||||
field :user_id, :id
|
||||
|
||||
has_many :firewall_rules, Cloudfire.FirewallRules.FirewallRule
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(device, attrs) do
|
||||
device
|
||||
|> cast(attrs, [:name, :public_key])
|
||||
|> validate_required([:name])
|
||||
end
|
||||
end
|
||||
104
apps/cloudfire/lib/cloudfire/firewall_rules.ex
Normal file
104
apps/cloudfire/lib/cloudfire/firewall_rules.ex
Normal file
@@ -0,0 +1,104 @@
|
||||
defmodule Cloudfire.FirewallRules do
|
||||
@moduledoc """
|
||||
The FirewallRules context.
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Cloudfire.Repo
|
||||
|
||||
alias Cloudfire.FirewallRules.FirewallRule
|
||||
|
||||
@doc """
|
||||
Returns the list of firewall_rules.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> list_firewall_rules()
|
||||
[%FirewallRule{}, ...]
|
||||
|
||||
"""
|
||||
def list_firewall_rules do
|
||||
Repo.all(FirewallRule)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Gets a single firewall_rule.
|
||||
|
||||
Raises `Ecto.NoResultsError` if the Firewall rule does not exist.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> get_firewall_rule!(123)
|
||||
%FirewallRule{}
|
||||
|
||||
iex> get_firewall_rule!(456)
|
||||
** (Ecto.NoResultsError)
|
||||
|
||||
"""
|
||||
def get_firewall_rule!(id), do: Repo.get!(FirewallRule, id)
|
||||
|
||||
@doc """
|
||||
Creates a firewall_rule.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> create_firewall_rule(%{field: value})
|
||||
{:ok, %FirewallRule{}}
|
||||
|
||||
iex> create_firewall_rule(%{field: bad_value})
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def create_firewall_rule(attrs \\ %{}) do
|
||||
%FirewallRule{}
|
||||
|> FirewallRule.changeset(attrs)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Updates a firewall_rule.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> update_firewall_rule(firewall_rule, %{field: new_value})
|
||||
{:ok, %FirewallRule{}}
|
||||
|
||||
iex> update_firewall_rule(firewall_rule, %{field: bad_value})
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def update_firewall_rule(%FirewallRule{} = firewall_rule, attrs) do
|
||||
firewall_rule
|
||||
|> FirewallRule.changeset(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes a firewall_rule.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> delete_firewall_rule(firewall_rule)
|
||||
{:ok, %FirewallRule{}}
|
||||
|
||||
iex> delete_firewall_rule(firewall_rule)
|
||||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def delete_firewall_rule(%FirewallRule{} = firewall_rule) do
|
||||
Repo.delete(firewall_rule)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns an `%Ecto.Changeset{}` for tracking firewall_rule changes.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> change_firewall_rule(firewall_rule)
|
||||
%Ecto.Changeset{source: %FirewallRule{}}
|
||||
|
||||
"""
|
||||
def change_firewall_rule(%FirewallRule{} = firewall_rule) do
|
||||
FirewallRule.changeset(firewall_rule, %{})
|
||||
end
|
||||
end
|
||||
22
apps/cloudfire/lib/cloudfire/firewall_rules/firewall_rule.ex
Normal file
22
apps/cloudfire/lib/cloudfire/firewall_rules/firewall_rule.ex
Normal file
@@ -0,0 +1,22 @@
|
||||
defmodule Cloudfire.FirewallRules.FirewallRule do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "firewall_rules" do
|
||||
field :destination, :string
|
||||
field :enabled, :boolean, default: false
|
||||
field :port, :string
|
||||
field :protocol, :string
|
||||
|
||||
belongs_to :device, Cloudfire.Devices.Device
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(firewall_rule, attrs) do
|
||||
firewall_rule
|
||||
|> cast(attrs, [:destination, :port, :protocol, :enabled])
|
||||
|> validate_required([:destination, :port, :protocol, :enabled])
|
||||
end
|
||||
end
|
||||
5
apps/cloudfire/lib/cloudfire/repo.ex
Normal file
5
apps/cloudfire/lib/cloudfire/repo.ex
Normal file
@@ -0,0 +1,5 @@
|
||||
defmodule Cloudfire.Repo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :cloudfire,
|
||||
adapter: Ecto.Adapters.Postgres
|
||||
end
|
||||
21
apps/cloudfire/lib/cloudfire/user.ex
Normal file
21
apps/cloudfire/lib/cloudfire/user.ex
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule Cloudfire.User do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "users" do
|
||||
field :email, :string
|
||||
field :confirmed_at, :utc_datetime
|
||||
field :last_signed_in_at, :utc_datetime
|
||||
field :password_digest, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(user, attrs \\ %{}) do
|
||||
user
|
||||
|> cast(attrs, [:email, :confirmed_at, :password_digest, :last_signed_in_at])
|
||||
|> validate_required([:email, :last_signed_in_at])
|
||||
|> unique_constraint(:email)
|
||||
end
|
||||
end
|
||||
69
apps/cloudfire/lib/cloudfire_web.ex
Normal file
69
apps/cloudfire/lib/cloudfire_web.ex
Normal file
@@ -0,0 +1,69 @@
|
||||
defmodule CloudfireWeb do
|
||||
@moduledoc """
|
||||
The entrypoint for defining your web interface, such
|
||||
as controllers, views, channels and so on.
|
||||
|
||||
This can be used in your application as:
|
||||
|
||||
use CloudfireWeb, :controller
|
||||
use CloudfireWeb, :view
|
||||
|
||||
The definitions below will be executed for every view,
|
||||
controller, etc, so keep them short and clean, focused
|
||||
on imports, uses and aliases.
|
||||
|
||||
Do NOT define functions inside the quoted expressions
|
||||
below. Instead, define any helper function in modules
|
||||
and import those modules here.
|
||||
"""
|
||||
|
||||
def controller do
|
||||
quote do
|
||||
use Phoenix.Controller, namespace: CloudfireWeb
|
||||
|
||||
import Plug.Conn
|
||||
import CloudfireWeb.Gettext
|
||||
alias CloudfireWeb.Router.Helpers, as: Routes
|
||||
end
|
||||
end
|
||||
|
||||
def view do
|
||||
quote do
|
||||
use Phoenix.View,
|
||||
root: "lib/cloudfire_web/templates",
|
||||
namespace: CloudfireWeb
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
|
||||
|
||||
# Use all HTML functionality (forms, tags, etc)
|
||||
use Phoenix.HTML
|
||||
|
||||
import CloudfireWeb.ErrorHelpers
|
||||
import CloudfireWeb.Gettext
|
||||
alias CloudfireWeb.Router.Helpers, as: Routes
|
||||
end
|
||||
end
|
||||
|
||||
def router do
|
||||
quote do
|
||||
use Phoenix.Router
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
end
|
||||
end
|
||||
|
||||
def channel do
|
||||
quote do
|
||||
use Phoenix.Channel
|
||||
import CloudfireWeb.Gettext
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
When used, dispatch to the appropriate controller/view/etc.
|
||||
"""
|
||||
defmacro __using__(which) when is_atom(which) do
|
||||
apply(__MODULE__, which, [])
|
||||
end
|
||||
end
|
||||
33
apps/cloudfire/lib/cloudfire_web/channels/user_socket.ex
Normal file
33
apps/cloudfire/lib/cloudfire_web/channels/user_socket.ex
Normal file
@@ -0,0 +1,33 @@
|
||||
defmodule CloudfireWeb.UserSocket do
|
||||
use Phoenix.Socket
|
||||
|
||||
## Channels
|
||||
# channel "room:*", CloudfireWeb.RoomChannel
|
||||
|
||||
# Socket params are passed from the client and can
|
||||
# be used to verify and authenticate a user. After
|
||||
# verification, you can put default assigns into
|
||||
# the socket that will be set for all channels, ie
|
||||
#
|
||||
# {:ok, assign(socket, :user_id, verified_user_id)}
|
||||
#
|
||||
# To deny connection, return `:error`.
|
||||
#
|
||||
# See `Phoenix.Token` documentation for examples in
|
||||
# performing token verification on connect.
|
||||
def connect(_params, socket, _connect_info) do
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
# Socket id's are topics that allow you to identify all sockets for a given user:
|
||||
#
|
||||
# def id(socket), do: "user_socket:#{socket.assigns.user_id}"
|
||||
#
|
||||
# Would allow you to broadcast a "disconnect" event and terminate
|
||||
# all active sockets and channels for a given user:
|
||||
#
|
||||
# CloudfireWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
|
||||
#
|
||||
# Returning `nil` makes this socket anonymous.
|
||||
def id(_socket), do: nil
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
defmodule CloudfireWeb.DeviceController do
|
||||
use CloudfireWeb, :controller
|
||||
|
||||
alias Cloudfire.Devices
|
||||
alias Cloudfire.Devices.Device
|
||||
|
||||
plug CloudfireWeb.Plugs.Authenticator
|
||||
|
||||
def index(conn, _params) do
|
||||
devices = Devices.list_devices()
|
||||
render(conn, "index.html", devices: devices)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = Devices.change_device(%Device{})
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
device = Devices.get_device!(id)
|
||||
render(conn, "show.html", device: device)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
device = Devices.get_device!(id)
|
||||
changeset = Devices.change_device(device)
|
||||
render(conn, "edit.html", device: device, changeset: changeset)
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "device" => device_params}) do
|
||||
device = Devices.get_device!(id)
|
||||
|
||||
case Devices.update_device(device, device_params) do
|
||||
{:ok, device} ->
|
||||
conn
|
||||
|> put_flash(:info, "Device updated successfully.")
|
||||
|> redirect(to: Routes.device_path(conn, :show, device))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "edit.html", device: device, changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
device = Devices.get_device!(id)
|
||||
{:ok, _device} = Devices.delete_device(device)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Device deleted successfully.")
|
||||
|> redirect(to: Routes.device_path(conn, :index))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,68 @@
|
||||
defmodule CloudfireWeb.FirewallRuleController do
|
||||
use CloudfireWeb, :controller
|
||||
|
||||
alias Cloudfire.FirewallRules
|
||||
alias Cloudfire.FirewallRules.FirewallRule
|
||||
alias Cloudfire.Devices
|
||||
|
||||
plug CloudfireWeb.Plugs.Authenticator
|
||||
|
||||
def index(conn, %{"device_id" => device_id}) do
|
||||
device = Devices.get_device!(device_id)
|
||||
|
||||
render(conn, "index.html", device: device, firewall_rules: device.firewall_rules)
|
||||
end
|
||||
|
||||
def new(conn, %{"device_id" => device_id}) do
|
||||
device = Devices.get_device!(device_id)
|
||||
|
||||
changeset = FirewallRules.change_firewall_rule(%FirewallRule{device_id: device_id})
|
||||
render(conn, "new.html", changeset: changeset, device: device)
|
||||
end
|
||||
|
||||
def create(conn, %{"firewall_rule" => firewall_rule_params}) do
|
||||
case FirewallRules.create_firewall_rule(firewall_rule_params) do
|
||||
{:ok, firewall_rule} ->
|
||||
conn
|
||||
|> put_flash(:info, "Firewall rule created successfully.")
|
||||
|> redirect(to: Routes.firewall_rule_path(conn, :show, firewall_rule))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
firewall_rule = FirewallRules.get_firewall_rule!(id)
|
||||
render(conn, "show.html", firewall_rule: firewall_rule)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
firewall_rule = FirewallRules.get_firewall_rule!(id)
|
||||
changeset = FirewallRules.change_firewall_rule(firewall_rule)
|
||||
render(conn, "edit.html", firewall_rule: firewall_rule, changeset: changeset)
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "firewall_rule" => firewall_rule_params}) do
|
||||
firewall_rule = FirewallRules.get_firewall_rule!(id)
|
||||
|
||||
case FirewallRules.update_firewall_rule(firewall_rule, firewall_rule_params) do
|
||||
{:ok, firewall_rule} ->
|
||||
conn
|
||||
|> put_flash(:info, "Firewall rule updated successfully.")
|
||||
|> redirect(to: Routes.firewall_rule_path(conn, :show, firewall_rule))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "edit.html", firewall_rule: firewall_rule, changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
firewall_rule = FirewallRules.get_firewall_rule!(id)
|
||||
{:ok, _firewall_rule} = FirewallRules.delete_firewall_rule(firewall_rule)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Firewall rule deleted successfully.")
|
||||
|> redirect(to: Routes.firewall_rule_path(conn, :index, firewall_rule.device))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
defmodule CloudfireWeb.PageController do
|
||||
use CloudfireWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
render(conn, "index.html")
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,79 @@
|
||||
defmodule CloudfireWeb.UserController do
|
||||
@moduledoc """
|
||||
Implements the CRUD for a User
|
||||
"""
|
||||
|
||||
use CloudfireWeb, :controller
|
||||
alias Cloudfire.{Repo, User}
|
||||
|
||||
plug CloudfireWeb.Plugs.Authenticator when action in [:show, :edit, :update, :delete]
|
||||
|
||||
# GET /users/new
|
||||
def new(conn, _params) do
|
||||
changeset = User.changeset(%User{})
|
||||
conn
|
||||
|> render("new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
# POST /users
|
||||
def create(conn, params) do
|
||||
changeset = User.changeset(%User{}, params)
|
||||
|
||||
case Repo.insert(changeset) do
|
||||
{:ok, user} ->
|
||||
conn
|
||||
|> assign(:current_user, user)
|
||||
|> put_flash(:info, "User created successfully")
|
||||
|> redirect(to: Routes.device_path(conn, :index))
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Error creating user.")
|
||||
|> render("new.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /user/edit
|
||||
def edit(conn, _params) do
|
||||
changeset = User.changeset(conn.current_user)
|
||||
conn
|
||||
|> render("edit.html", changeset: changeset)
|
||||
end
|
||||
|
||||
# GET /user
|
||||
def show(conn, _params) do
|
||||
conn
|
||||
|> render("show.html", user: conn.current_user)
|
||||
end
|
||||
|
||||
# PATCH /user
|
||||
def update(conn, params) do
|
||||
changeset = User.changeset(conn.current_user, params)
|
||||
|
||||
case Repo.update(changeset) do
|
||||
{:ok, user} ->
|
||||
conn
|
||||
|> assign(:current_user, user)
|
||||
|> put_flash(:info, "User updated successfully.")
|
||||
|> redirect(to: Routes.user_path(conn, :show, conn.current_user))
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Error updating user.")
|
||||
|> render("edit.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /user
|
||||
def delete(conn, _params) do
|
||||
case Repo.delete(conn.current_user) do
|
||||
{:ok, _user} ->
|
||||
conn
|
||||
|> assign(:current_user, nil)
|
||||
|> put_flash(:info, "User deleted successfully.")
|
||||
|> redirect(to: Routes.page_path(conn, :index))
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Error deleting User.")
|
||||
|> redirect(to: Routes.user_path(:show, conn.current_user))
|
||||
end
|
||||
end
|
||||
end
|
||||
47
apps/cloudfire/lib/cloudfire_web/endpoint.ex
Normal file
47
apps/cloudfire/lib/cloudfire_web/endpoint.ex
Normal file
@@ -0,0 +1,47 @@
|
||||
defmodule CloudfireWeb.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :cloudfire
|
||||
|
||||
# The session will be stored in the cookie and signed,
|
||||
# this means its contents can be read but not tampered with.
|
||||
# Set :encryption_salt if you would also like to encrypt it.
|
||||
@session_options [
|
||||
store: :cookie,
|
||||
key: "_cloudfire_key",
|
||||
signing_salt: "Z9eq8iof"
|
||||
]
|
||||
|
||||
socket "/socket", CloudfireWeb.UserSocket,
|
||||
websocket: true,
|
||||
longpoll: false
|
||||
|
||||
# Serve at "/" the static files from "priv/static" directory.
|
||||
#
|
||||
# You should set gzip to true if you are running phx.digest
|
||||
# when deploying your static files in production.
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :cloudfire,
|
||||
gzip: false,
|
||||
only: ~w(css fonts images js favicon.ico robots.txt)
|
||||
|
||||
# Code reloading can be explicitly enabled under the
|
||||
# :code_reloader configuration of your endpoint.
|
||||
if code_reloading? do
|
||||
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
|
||||
plug Phoenix.LiveReloader
|
||||
plug Phoenix.CodeReloader
|
||||
end
|
||||
|
||||
plug Plug.RequestId
|
||||
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
|
||||
|
||||
plug Plug.Parsers,
|
||||
parsers: [:urlencoded, :multipart, :json],
|
||||
pass: ["*/*"],
|
||||
json_decoder: Phoenix.json_library()
|
||||
|
||||
plug Plug.MethodOverride
|
||||
plug Plug.Head
|
||||
plug Plug.Session, @session_options
|
||||
plug CloudfireWeb.Router
|
||||
end
|
||||
24
apps/cloudfire/lib/cloudfire_web/gettext.ex
Normal file
24
apps/cloudfire/lib/cloudfire_web/gettext.ex
Normal file
@@ -0,0 +1,24 @@
|
||||
defmodule CloudfireWeb.Gettext do
|
||||
@moduledoc """
|
||||
A module providing Internationalization with a gettext-based API.
|
||||
|
||||
By using [Gettext](https://hexdocs.pm/gettext),
|
||||
your module gains a set of macros for translations, for example:
|
||||
|
||||
import CloudfireWeb.Gettext
|
||||
|
||||
# Simple translation
|
||||
gettext("Here is the string to translate")
|
||||
|
||||
# Plural translation
|
||||
ngettext("Here is the string to translate",
|
||||
"Here are the strings to translate",
|
||||
3)
|
||||
|
||||
# Domain-based translation
|
||||
dgettext("errors", "Here is the error message to translate")
|
||||
|
||||
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
||||
"""
|
||||
use Gettext, otp_app: :cloudfire
|
||||
end
|
||||
15
apps/cloudfire/lib/cloudfire_web/plugs/authenticator.ex
Normal file
15
apps/cloudfire/lib/cloudfire_web/plugs/authenticator.ex
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule CloudfireWeb.Plugs.Authenticator do
|
||||
@moduledoc """
|
||||
Loads the user's session from cookie
|
||||
"""
|
||||
|
||||
import Plug.Conn
|
||||
alias Cloudfire.User
|
||||
|
||||
def init(default), do: default
|
||||
|
||||
def call(conn, _default) do
|
||||
user = %User{email: "dev_user@cloudfire.network"}
|
||||
assign(conn, :current_user, user)
|
||||
end
|
||||
end
|
||||
33
apps/cloudfire/lib/cloudfire_web/router.ex
Normal file
33
apps/cloudfire/lib/cloudfire_web/router.ex
Normal file
@@ -0,0 +1,33 @@
|
||||
defmodule CloudfireWeb.Router do
|
||||
use CloudfireWeb, :router
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
plug :fetch_session
|
||||
plug :fetch_flash
|
||||
plug :protect_from_forgery
|
||||
plug :put_secure_browser_headers
|
||||
end
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", CloudfireWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :index
|
||||
|
||||
resources "/user", UserController, singleton: true, only: [:show, :edit, :update, :delete]
|
||||
resources "/users", UserController, only: [:new, :create]
|
||||
resources "/devices", DeviceController, except: [:create] do
|
||||
resources "/firewall_rules", FirewallRuleController, only: [:new, :index, :create]
|
||||
end
|
||||
resources "/firewall_rules", FirewallRuleController, only: [:show, :update, :delete, :edit]
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
# scope "/api", CloudfireWeb do
|
||||
# pipe_through :api
|
||||
# end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
<h1>Edit Device</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.device_path(@conn, :update, @device)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.device_path(@conn, :index) %></span>
|
||||
@@ -0,0 +1,15 @@
|
||||
<%= form_for @changeset, @action, fn f -> %>
|
||||
<%= if @changeset.action do %>
|
||||
<div class="alert alert-danger">
|
||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= label f, :name %>
|
||||
<%= text_input f, :name %>
|
||||
<%= error_tag f, :name %>
|
||||
|
||||
<div>
|
||||
<%= submit "Save" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,30 @@
|
||||
<h1>Listing Devices</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Verified at</th>
|
||||
<th>Public key</th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for device <- @devices do %>
|
||||
<tr>
|
||||
<td><%= device.name %></td>
|
||||
<td><%= device.verified_at %></td>
|
||||
<td><%= device.public_key %></td>
|
||||
|
||||
<td>
|
||||
<span><%= link "Show", to: Routes.device_path(@conn, :show, device) %></span>
|
||||
<span><%= link "Edit", to: Routes.device_path(@conn, :edit, device) %></span>
|
||||
<span><%= link "Delete", to: Routes.device_path(@conn, :delete, device), method: :delete, data: [confirm: "Are you sure?"] %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<span><%= link "New Device", to: Routes.device_path(@conn, :new) %></span>
|
||||
@@ -0,0 +1,25 @@
|
||||
<h1>New Device</h1>
|
||||
|
||||
Add the following to your Wireguard configuration file:
|
||||
|
||||
<!-- TODO: Actually generate this -->
|
||||
<pre>
|
||||
<code>
|
||||
[Peer]
|
||||
PublicKey = S1yT3gj0rLFcz4o7qGAbQqs8aFh7R3nCMF+WU0nlWGs=
|
||||
AllowedIPs = 0.0.0.0/0, ::/0
|
||||
Endpoint = 104.238.182.24:51820
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
When we receive a connection from your device, we'll prompt you verify it here.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Waiting for device connection...
|
||||
</div>
|
||||
|
||||
<span><%= link "Back", to: Routes.device_path(@conn, :index) %></span>
|
||||
@@ -0,0 +1,21 @@
|
||||
<h1>Show Device</h1>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Name:</strong>
|
||||
<%= @device.name %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Verified at:</strong>
|
||||
<%= @device.verified_at %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Public key:</strong>
|
||||
<%= @device.public_key %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<span><%= link "Edit", to: Routes.device_path(@conn, :edit, @device) %></span>
|
||||
<span><%= link "Back", to: Routes.device_path(@conn, :index) %></span>
|
||||
@@ -0,0 +1,5 @@
|
||||
<h1>Edit Firewall rule</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.firewall_rule_path(@conn, :update, @firewall_rule)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.firewall_rule_path(@conn, :index, @firewall_rule.device) %></span>
|
||||
@@ -0,0 +1,27 @@
|
||||
<%= form_for @changeset, @action, fn f -> %>
|
||||
<%= if @changeset.action do %>
|
||||
<div class="alert alert-danger">
|
||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= label f, :destination %>
|
||||
<%= text_input f, :destination %>
|
||||
<%= error_tag f, :destination %>
|
||||
|
||||
<%= label f, :port %>
|
||||
<%= text_input f, :port %>
|
||||
<%= error_tag f, :port %>
|
||||
|
||||
<%= label f, :protocol %>
|
||||
<%= text_input f, :protocol %>
|
||||
<%= error_tag f, :protocol %>
|
||||
|
||||
<%= label f, :enabled %>
|
||||
<%= checkbox f, :enabled %>
|
||||
<%= error_tag f, :enabled %>
|
||||
|
||||
<div>
|
||||
<%= submit "Save" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,32 @@
|
||||
<h1>Listing Firewall rules</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Destination</th>
|
||||
<th>Port</th>
|
||||
<th>Protocol</th>
|
||||
<th>Enabled</th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for firewall_rule <- @firewall_rules do %>
|
||||
<tr>
|
||||
<td><%= firewall_rule.destination %></td>
|
||||
<td><%= firewall_rule.port %></td>
|
||||
<td><%= firewall_rule.protocol %></td>
|
||||
<td><%= firewall_rule.enabled %></td>
|
||||
|
||||
<td>
|
||||
<span><%= link "Show", to: Routes.firewall_rule_path(@conn, :show, firewall_rule) %></span>
|
||||
<span><%= link "Edit", to: Routes.firewall_rule_path(@conn, :edit, firewall_rule) %></span>
|
||||
<span><%= link "Delete", to: Routes.firewall_rule_path(@conn, :delete, firewall_rule), method: :delete, data: [confirm: "Are you sure?"] %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<span><%= link "New Firewall rule", to: Routes.firewall_rule_path(@conn, :new, @device) %></span>
|
||||
@@ -0,0 +1,5 @@
|
||||
<h1>New Firewall rule</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.firewall_rule_path(@conn, :create, @device)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.firewall_rule_path(@conn, :index, @device) %></span>
|
||||
@@ -0,0 +1,28 @@
|
||||
<h1>Show Firewall rule</h1>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<strong>Destination:</strong>
|
||||
<%= @firewall_rule.destination %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Port:</strong>
|
||||
<%= @firewall_rule.port %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Protocol:</strong>
|
||||
<%= @firewall_rule.protocol %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Enabled:</strong>
|
||||
<%= @firewall_rule.enabled %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<span><%= link "Edit", to: Routes.firewall_rule_path(@conn, :edit, @firewall_rule) %></span>
|
||||
<span><%= link "Back", to: Routes.firewall_rule_path(@conn, :index, @firewall_rule.device) %></span>
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Cloudfire</title>
|
||||
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
|
||||
<%= csrf_meta_tag() %>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<section class="container">
|
||||
<nav role="navigation">
|
||||
<ul>
|
||||
<li><a href="<%= Routes.device_path(@conn, :index) %>">Devices</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<a href="<%= CloudfireWeb.Endpoint.url() %>" class="cf-logo">
|
||||
<img src="<%= Routes.static_path(@conn, "/images/logo.svg") %>" alt="Cloudfire Logo"/>
|
||||
</a>
|
||||
</section>
|
||||
</header>
|
||||
<main role="main" class="container">
|
||||
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
|
||||
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
||||
<%= render @view_module, @view_template, assigns %>
|
||||
</main>
|
||||
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
Welcome!
|
||||
25
apps/cloudfire/lib/cloudfire_web/templates/user/new.html.eex
Normal file
25
apps/cloudfire/lib/cloudfire_web/templates/user/new.html.eex
Normal file
@@ -0,0 +1,25 @@
|
||||
<h3>Sign Up</h3>
|
||||
|
||||
<%= form_for @changeset, Routes.user_path(@conn, :create), fn f -> %>
|
||||
<%= if f.errors do %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<label>
|
||||
Email: <%= text_input f, :email %>
|
||||
</label>
|
||||
|
||||
<br>
|
||||
|
||||
<label>
|
||||
Password: <%= text_input f, :password %>
|
||||
</label>
|
||||
|
||||
<br>
|
||||
|
||||
<label>
|
||||
Password Confirmation: <%= text_input f, :password_confirmation %>
|
||||
</label>
|
||||
|
||||
<%= submit "Submit" %>
|
||||
<% end %>
|
||||
3
apps/cloudfire/lib/cloudfire_web/views/device_view.ex
Normal file
3
apps/cloudfire/lib/cloudfire_web/views/device_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.DeviceView do
|
||||
use CloudfireWeb, :view
|
||||
end
|
||||
44
apps/cloudfire/lib/cloudfire_web/views/error_helpers.ex
Normal file
44
apps/cloudfire/lib/cloudfire_web/views/error_helpers.ex
Normal file
@@ -0,0 +1,44 @@
|
||||
defmodule CloudfireWeb.ErrorHelpers do
|
||||
@moduledoc """
|
||||
Conveniences for translating and building error messages.
|
||||
"""
|
||||
|
||||
use Phoenix.HTML
|
||||
|
||||
@doc """
|
||||
Generates tag for inlined form input errors.
|
||||
"""
|
||||
def error_tag(form, field) do
|
||||
Enum.map(Keyword.get_values(form.errors, field), fn error ->
|
||||
content_tag(:span, translate_error(error), class: "help-block")
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Translates an error message using gettext.
|
||||
"""
|
||||
def translate_error({msg, opts}) do
|
||||
# When using gettext, we typically pass the strings we want
|
||||
# to translate as a static argument:
|
||||
#
|
||||
# # Translate "is invalid" in the "errors" domain
|
||||
# dgettext("errors", "is invalid")
|
||||
#
|
||||
# # Translate the number of files with plural rules
|
||||
# dngettext("errors", "1 file", "%{count} files", count)
|
||||
#
|
||||
# Because the error messages we show in our forms and APIs
|
||||
# are defined inside Ecto, we need to translate them dynamically.
|
||||
# This requires us to call the Gettext module passing our gettext
|
||||
# backend as first argument.
|
||||
#
|
||||
# Note we use the "errors" domain, which means translations
|
||||
# should be written to the errors.po file. The :count option is
|
||||
# set by Ecto and indicates we should also apply plural rules.
|
||||
if count = opts[:count] do
|
||||
Gettext.dngettext(CloudfireWeb.Gettext, "errors", msg, msg, count, opts)
|
||||
else
|
||||
Gettext.dgettext(CloudfireWeb.Gettext, "errors", msg, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
16
apps/cloudfire/lib/cloudfire_web/views/error_view.ex
Normal file
16
apps/cloudfire/lib/cloudfire_web/views/error_view.ex
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule CloudfireWeb.ErrorView do
|
||||
use CloudfireWeb, :view
|
||||
|
||||
# If you want to customize a particular status code
|
||||
# for a certain format, you may uncomment below.
|
||||
# def render("500.html", _assigns) do
|
||||
# "Internal Server Error"
|
||||
# end
|
||||
|
||||
# By default, Phoenix returns the status message from
|
||||
# the template name. For example, "404.html" becomes
|
||||
# "Not Found".
|
||||
def template_not_found(template, _assigns) do
|
||||
Phoenix.Controller.status_message_from_template(template)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.FirewallRuleView do
|
||||
use CloudfireWeb, :view
|
||||
end
|
||||
3
apps/cloudfire/lib/cloudfire_web/views/layout_view.ex
Normal file
3
apps/cloudfire/lib/cloudfire_web/views/layout_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.LayoutView do
|
||||
use CloudfireWeb, :view
|
||||
end
|
||||
3
apps/cloudfire/lib/cloudfire_web/views/page_view.ex
Normal file
3
apps/cloudfire/lib/cloudfire_web/views/page_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.PageView do
|
||||
use CloudfireWeb, :view
|
||||
end
|
||||
3
apps/cloudfire/lib/cloudfire_web/views/user_view.ex
Normal file
3
apps/cloudfire/lib/cloudfire_web/views/user_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.UserView do
|
||||
use CloudfireWeb, :view
|
||||
end
|
||||
67
apps/cloudfire/mix.exs
Normal file
67
apps/cloudfire/mix.exs
Normal file
@@ -0,0 +1,67 @@
|
||||
defmodule Cloudfire.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :cloudfire,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.5",
|
||||
elixirc_paths: elixirc_paths(Mix.env()),
|
||||
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
|
||||
start_permanent: Mix.env() == :prod,
|
||||
aliases: aliases(),
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
# Configuration for the OTP application.
|
||||
#
|
||||
# Type `mix help compile.app` for more information.
|
||||
def application do
|
||||
[
|
||||
mod: {Cloudfire.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
]
|
||||
end
|
||||
|
||||
# Specifies which paths to compile per environment.
|
||||
defp elixirc_paths(:test), do: ["lib", "test/support"]
|
||||
defp elixirc_paths(_), do: ["lib"]
|
||||
|
||||
# Specifies your project dependencies.
|
||||
#
|
||||
# Type `mix help deps` for examples and options.
|
||||
defp deps do
|
||||
[
|
||||
{:phoenix, "~> 1.4.12"},
|
||||
{:phoenix_pubsub, "~> 1.1"},
|
||||
{:phoenix_ecto, "~> 4.0"},
|
||||
{:ecto_sql, "~> 3.1"},
|
||||
{:ecto_network, "~> 1.3.0"}, # Exposes Postgres inet, cidr, macaddr types
|
||||
{:postgrex, ">= 0.0.0"},
|
||||
{:phoenix_html, "~> 2.11"},
|
||||
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
||||
{:gettext, "~> 0.11"},
|
||||
{:jason, "~> 1.0"},
|
||||
{:plug_cowboy, "~> 2.0"}
|
||||
]
|
||||
end
|
||||
|
||||
# Aliases are shortcuts or tasks specific to the current project.
|
||||
# For example, to create, migrate and run the seeds file at once:
|
||||
#
|
||||
# $ mix ecto.setup
|
||||
#
|
||||
# See the documentation for `Mix` for more info on aliases.
|
||||
defp aliases do
|
||||
[
|
||||
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
|
||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||
test: ["ecto.create --quiet", "ecto.migrate", "test"]
|
||||
]
|
||||
end
|
||||
end
|
||||
97
apps/cloudfire/priv/gettext/en/LC_MESSAGES/errors.po
Normal file
97
apps/cloudfire/priv/gettext/en/LC_MESSAGES/errors.po
Normal file
@@ -0,0 +1,97 @@
|
||||
## `msgid`s in this file come from POT (.pot) files.
|
||||
##
|
||||
## Do not add, change, or remove `msgid`s manually here as
|
||||
## they're tied to the ones in the corresponding POT file
|
||||
## (with the same domain).
|
||||
##
|
||||
## Use `mix gettext.extract --merge` or `mix gettext.merge`
|
||||
## to merge POT files into PO files.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: en\n"
|
||||
|
||||
## From Ecto.Changeset.cast/4
|
||||
msgid "can't be blank"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.unique_constraint/3
|
||||
msgid "has already been taken"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.put_change/3
|
||||
msgid "is invalid"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_acceptance/3
|
||||
msgid "must be accepted"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_format/3
|
||||
msgid "has invalid format"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_subset/3
|
||||
msgid "has an invalid entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_exclusion/3
|
||||
msgid "is reserved"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_confirmation/3
|
||||
msgid "does not match confirmation"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.no_assoc_constraint/3
|
||||
msgid "is still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
msgid "are still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_length/3
|
||||
msgid "should be %{count} character(s)"
|
||||
msgid_plural "should be %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have %{count} item(s)"
|
||||
msgid_plural "should have %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at least %{count} character(s)"
|
||||
msgid_plural "should be at least %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at least %{count} item(s)"
|
||||
msgid_plural "should have at least %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at most %{count} character(s)"
|
||||
msgid_plural "should be at most %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at most %{count} item(s)"
|
||||
msgid_plural "should have at most %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
## From Ecto.Changeset.validate_number/3
|
||||
msgid "must be less than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be less than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be equal to %{number}"
|
||||
msgstr ""
|
||||
95
apps/cloudfire/priv/gettext/errors.pot
Normal file
95
apps/cloudfire/priv/gettext/errors.pot
Normal file
@@ -0,0 +1,95 @@
|
||||
## This is a PO Template file.
|
||||
##
|
||||
## `msgid`s here are often extracted from source code.
|
||||
## Add new translations manually only if they're dynamic
|
||||
## translations that can't be statically extracted.
|
||||
##
|
||||
## Run `mix gettext.extract` to bring this file up to
|
||||
## date. Leave `msgstr`s empty as changing them here has no
|
||||
## effect: edit them in PO (`.po`) files instead.
|
||||
|
||||
## From Ecto.Changeset.cast/4
|
||||
msgid "can't be blank"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.unique_constraint/3
|
||||
msgid "has already been taken"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.put_change/3
|
||||
msgid "is invalid"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_acceptance/3
|
||||
msgid "must be accepted"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_format/3
|
||||
msgid "has invalid format"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_subset/3
|
||||
msgid "has an invalid entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_exclusion/3
|
||||
msgid "is reserved"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_confirmation/3
|
||||
msgid "does not match confirmation"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.no_assoc_constraint/3
|
||||
msgid "is still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
msgid "are still associated with this entry"
|
||||
msgstr ""
|
||||
|
||||
## From Ecto.Changeset.validate_length/3
|
||||
msgid "should be %{count} character(s)"
|
||||
msgid_plural "should be %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have %{count} item(s)"
|
||||
msgid_plural "should have %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at least %{count} character(s)"
|
||||
msgid_plural "should be at least %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at least %{count} item(s)"
|
||||
msgid_plural "should have at least %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should be at most %{count} character(s)"
|
||||
msgid_plural "should be at most %{count} character(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "should have at most %{count} item(s)"
|
||||
msgid_plural "should have at most %{count} item(s)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
## From Ecto.Changeset.validate_number/3
|
||||
msgid "must be less than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be less than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be greater than or equal to %{number}"
|
||||
msgstr ""
|
||||
|
||||
msgid "must be equal to %{number}"
|
||||
msgstr ""
|
||||
4
apps/cloudfire/priv/repo/migrations/.formatter.exs
Normal file
4
apps/cloudfire/priv/repo/migrations/.formatter.exs
Normal file
@@ -0,0 +1,4 @@
|
||||
[
|
||||
import_deps: [:ecto_sql],
|
||||
inputs: ["*.exs"]
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
defmodule Cloudfire.Repo.Migrations.CreateUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:users) do
|
||||
add :email, :string
|
||||
add :confirmed_at, :utc_datetime
|
||||
add :password_digest, :string
|
||||
add :last_signed_in_at, :utc_datetime
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:users, [:email])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
defmodule Cloudfire.Repo.Migrations.CreateDevices do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:devices) do
|
||||
add :name, :string
|
||||
add :verified_at, :utc_datetime
|
||||
add :public_key, :string
|
||||
add :user_id, references(:users, on_delete: :delete_all)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:devices, [:user_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
defmodule Cloudfire.Repo.Migrations.CreateFirewallRules do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:firewall_rules) do
|
||||
add :destination, :inet
|
||||
add :port, :string
|
||||
add :protocol, :string
|
||||
add :enabled, :boolean, default: false, null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
11
apps/cloudfire/priv/repo/seeds.exs
Normal file
11
apps/cloudfire/priv/repo/seeds.exs
Normal file
@@ -0,0 +1,11 @@
|
||||
# Script for populating the database. You can run it as:
|
||||
#
|
||||
# mix run priv/repo/seeds.exs
|
||||
#
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# Cloudfire.Repo.insert!(%Cloudfire.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
6
apps/cloudfire/test/cloudfire/devices_test.exs
Normal file
6
apps/cloudfire/test/cloudfire/devices_test.exs
Normal file
@@ -0,0 +1,6 @@
|
||||
defmodule Cloudfire.DevicesTest do
|
||||
use Cloudfire.DataCase
|
||||
|
||||
describe "devices" do
|
||||
end
|
||||
end
|
||||
6
apps/cloudfire/test/cloudfire/firewall_rules_test.exs
Normal file
6
apps/cloudfire/test/cloudfire/firewall_rules_test.exs
Normal file
@@ -0,0 +1,6 @@
|
||||
defmodule Cloudfire.FirewallRulesTest do
|
||||
use Cloudfire.DataCase
|
||||
|
||||
describe "firewall_rules" do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,71 @@
|
||||
defmodule CloudfireWeb.DeviceControllerTest do
|
||||
use CloudfireWeb.ConnCase
|
||||
|
||||
alias Cloudfire.Devices
|
||||
|
||||
@create_attrs %{name: "some name"}
|
||||
@update_attrs %{name: "some updated name"}
|
||||
@invalid_attrs %{name: nil}
|
||||
|
||||
def fixture(:device) do
|
||||
{:ok, device} = Devices.create_device(@create_attrs)
|
||||
device
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all devices", %{conn: conn} do
|
||||
conn = get(conn, Routes.device_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Devices"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new device" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.device_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Device"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit device" do
|
||||
setup [:create_device]
|
||||
|
||||
test "renders form for editing chosen device", %{conn: conn, device: device} do
|
||||
conn = get(conn, Routes.device_path(conn, :edit, device))
|
||||
assert html_response(conn, 200) =~ "Edit Device"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update device" do
|
||||
setup [:create_device]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, device: device} do
|
||||
conn = put(conn, Routes.device_path(conn, :update, device), device: @update_attrs)
|
||||
assert redirected_to(conn) == Routes.device_path(conn, :show, device)
|
||||
|
||||
conn = get(conn, Routes.device_path(conn, :show, device))
|
||||
assert html_response(conn, 200) =~ "some updated name"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, device: device} do
|
||||
conn = put(conn, Routes.device_path(conn, :update, device), device: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Device"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete device" do
|
||||
setup [:create_device]
|
||||
|
||||
test "deletes chosen device", %{conn: conn, device: device} do
|
||||
conn = delete(conn, Routes.device_path(conn, :delete, device))
|
||||
assert redirected_to(conn) == Routes.device_path(conn, :index)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.device_path(conn, :show, device))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_device(_) do
|
||||
device = fixture(:device)
|
||||
{:ok, device: device}
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
defmodule CloudfireWeb.FirewallRuleControllerTest do
|
||||
use CloudfireWeb.ConnCase
|
||||
|
||||
describe "index" do
|
||||
end
|
||||
|
||||
describe "new firewall_rule" do
|
||||
end
|
||||
|
||||
describe "create firewall_rule" do
|
||||
end
|
||||
|
||||
describe "edit firewall_rule" do
|
||||
end
|
||||
|
||||
describe "update firewall_rule" do
|
||||
end
|
||||
|
||||
describe "delete firewall_rule" do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
defmodule CloudfireWeb.PageControllerTest do
|
||||
use CloudfireWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, "/")
|
||||
assert html_response(conn, 200) =~ "Welcome!"
|
||||
end
|
||||
end
|
||||
14
apps/cloudfire/test/cloudfire_web/views/error_view_test.exs
Normal file
14
apps/cloudfire/test/cloudfire_web/views/error_view_test.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule CloudfireWeb.ErrorViewTest do
|
||||
use CloudfireWeb.ConnCase, async: true
|
||||
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(CloudfireWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(CloudfireWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
defmodule CloudfireWeb.LayoutViewTest do
|
||||
use CloudfireWeb.ConnCase, async: true
|
||||
|
||||
# When testing helpers, you may want to import Phoenix.HTML and
|
||||
# use functions such as safe_to_string() to convert the helper
|
||||
# result into an HTML string.
|
||||
# import Phoenix.HTML
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
defmodule CloudfireWeb.PageViewTest do
|
||||
use CloudfireWeb.ConnCase, async: true
|
||||
end
|
||||
39
apps/cloudfire/test/support/channel_case.ex
Normal file
39
apps/cloudfire/test/support/channel_case.ex
Normal file
@@ -0,0 +1,39 @@
|
||||
defmodule CloudfireWeb.ChannelCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
channel tests.
|
||||
|
||||
Such tests rely on `Phoenix.ChannelTest` and also
|
||||
import other functionality to make it easier
|
||||
to build common data structures and query the data layer.
|
||||
|
||||
Finally, if the test case interacts with the database,
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use CloudfireWeb.ChannelCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
using do
|
||||
quote do
|
||||
# Import conveniences for testing with channels
|
||||
use Phoenix.ChannelTest
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint CloudfireWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
40
apps/cloudfire/test/support/conn_case.ex
Normal file
40
apps/cloudfire/test/support/conn_case.ex
Normal file
@@ -0,0 +1,40 @@
|
||||
defmodule CloudfireWeb.ConnCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
tests that require setting up a connection.
|
||||
|
||||
Such tests rely on `Phoenix.ConnTest` and also
|
||||
import other functionality to make it easier
|
||||
to build common data structures and query the data layer.
|
||||
|
||||
Finally, if the test case interacts with the database,
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use CloudfireWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
using do
|
||||
quote do
|
||||
# Import conveniences for testing with connections
|
||||
use Phoenix.ConnTest
|
||||
alias CloudfireWeb.Router.Helpers, as: Routes
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint CloudfireWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
end
|
||||
end
|
||||
55
apps/cloudfire/test/support/data_case.ex
Normal file
55
apps/cloudfire/test/support/data_case.ex
Normal file
@@ -0,0 +1,55 @@
|
||||
defmodule Cloudfire.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
|
||||
You may define functions here to be used as helpers in
|
||||
your tests.
|
||||
|
||||
Finally, if the test case interacts with the database,
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use Cloudfire.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias Cloudfire.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import Cloudfire.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Cloudfire.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
@doc """
|
||||
A helper that transforms changeset errors into a map of messages.
|
||||
|
||||
assert {:error, changeset} = Accounts.create_user(%{password: "short"})
|
||||
assert "password is too short" in errors_on(changeset).password
|
||||
assert %{password: ["password is too short"]} = errors_on(changeset)
|
||||
|
||||
"""
|
||||
def errors_on(changeset) do
|
||||
Ecto.Changeset.traverse_errors(changeset, fn {message, opts} ->
|
||||
Regex.replace(~r"%{(\w+)}", message, fn _, key ->
|
||||
opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
2
apps/cloudfire/test/test_helper.exs
Normal file
2
apps/cloudfire/test/test_helper.exs
Normal file
@@ -0,0 +1,2 @@
|
||||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Cloudfire.Repo, :manual)
|
||||
4
apps/firewall_daemon/.formatter.exs
Normal file
4
apps/firewall_daemon/.formatter.exs
Normal file
@@ -0,0 +1,4 @@
|
||||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
||||
24
apps/firewall_daemon/.gitignore
vendored
Normal file
24
apps/firewall_daemon/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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").
|
||||
firewall_daemon-*.tar
|
||||
|
||||
21
apps/firewall_daemon/README.md
Normal file
21
apps/firewall_daemon/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# FirewallDaemon
|
||||
|
||||
**TODO: Add description**
|
||||
|
||||
## Installation
|
||||
|
||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||
by adding `firewall_daemon` to your list of dependencies in `mix.exs`:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
[
|
||||
{:firewall_daemon, "~> 0.1.0"}
|
||||
]
|
||||
end
|
||||
```
|
||||
|
||||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
||||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
||||
be found at [https://hexdocs.pm/firewall_daemon](https://hexdocs.pm/firewall_daemon).
|
||||
|
||||
18
apps/firewall_daemon/lib/firewall_daemon.ex
Normal file
18
apps/firewall_daemon/lib/firewall_daemon.ex
Normal file
@@ -0,0 +1,18 @@
|
||||
defmodule FirewallDaemon do
|
||||
@moduledoc """
|
||||
Documentation for FirewallDaemon.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Hello world.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> FirewallDaemon.hello()
|
||||
:world
|
||||
|
||||
"""
|
||||
def hello do
|
||||
:world
|
||||
end
|
||||
end
|
||||
19
apps/firewall_daemon/lib/firewall_daemon/application.ex
Normal file
19
apps/firewall_daemon/lib/firewall_daemon/application.ex
Normal file
@@ -0,0 +1,19 @@
|
||||
defmodule FirewallDaemon.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
# Starts a worker by calling: FirewallDaemon.Worker.start_link(arg)
|
||||
# {FirewallDaemon.Worker, arg}
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: FirewallDaemon.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
||||
34
apps/firewall_daemon/mix.exs
Normal file
34
apps/firewall_daemon/mix.exs
Normal file
@@ -0,0 +1,34 @@
|
||||
defmodule FirewallDaemon.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :firewall_daemon,
|
||||
version: "0.1.0",
|
||||
build_path: "../../_build",
|
||||
config_path: "../../config/config.exs",
|
||||
deps_path: "../../deps",
|
||||
lockfile: "../../mix.lock",
|
||||
elixir: "~> 1.9",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger],
|
||||
mod: {FirewallDaemon.Application, []}
|
||||
]
|
||||
end
|
||||
|
||||
# Run "mix help deps" to learn about dependencies.
|
||||
defp deps do
|
||||
[
|
||||
# {:dep_from_hexpm, "~> 0.3.0"},
|
||||
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
|
||||
# {:sibling_app_in_umbrella, in_umbrella: true}
|
||||
]
|
||||
end
|
||||
end
|
||||
8
apps/firewall_daemon/test/firewall_daemon_test.exs
Normal file
8
apps/firewall_daemon/test/firewall_daemon_test.exs
Normal file
@@ -0,0 +1,8 @@
|
||||
defmodule FirewallDaemonTest do
|
||||
use ExUnit.Case
|
||||
doctest FirewallDaemon
|
||||
|
||||
test "greets the world" do
|
||||
assert FirewallDaemon.hello() == :world
|
||||
end
|
||||
end
|
||||
1
apps/firewall_daemon/test/test_helper.exs
Normal file
1
apps/firewall_daemon/test/test_helper.exs
Normal file
@@ -0,0 +1 @@
|
||||
ExUnit.start()
|
||||
5
assets/.babelrc
Normal file
5
assets/.babelrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"presets": [
|
||||
"@babel/preset-env"
|
||||
]
|
||||
}
|
||||
3
assets/css/app.css
Normal file
3
assets/css/app.css
Normal file
@@ -0,0 +1,3 @@
|
||||
/* This file is for your main application css. */
|
||||
|
||||
@import "./phoenix.css";
|
||||
135
assets/css/phoenix.css
Normal file
135
assets/css/phoenix.css
Normal file
File diff suppressed because one or more lines are too long
17
assets/js/app.js
Normal file
17
assets/js/app.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// We need to import the CSS so that webpack will load it.
|
||||
// The MiniCssExtractPlugin is used to separate it out into
|
||||
// its own CSS file.
|
||||
import css from "../css/app.css"
|
||||
|
||||
// webpack automatically bundles all modules in your
|
||||
// entry points. Those entry points can be configured
|
||||
// in "webpack.config.js".
|
||||
//
|
||||
// Import dependencies
|
||||
//
|
||||
import "phoenix_html"
|
||||
|
||||
// Import local files
|
||||
//
|
||||
// Local files can be imported directly using relative paths, for example:
|
||||
// import socket from "./socket"
|
||||
63
assets/js/socket.js
Normal file
63
assets/js/socket.js
Normal file
@@ -0,0 +1,63 @@
|
||||
// NOTE: The contents of this file will only be executed if
|
||||
// you uncomment its entry in "assets/js/app.js".
|
||||
|
||||
// To use Phoenix channels, the first step is to import Socket,
|
||||
// and connect at the socket path in "lib/web/endpoint.ex".
|
||||
//
|
||||
// Pass the token on params as below. Or remove it
|
||||
// from the params if you are not using authentication.
|
||||
import {Socket} from "phoenix"
|
||||
|
||||
let socket = new Socket("/socket", {params: {token: window.userToken}})
|
||||
|
||||
// When you connect, you'll often need to authenticate the client.
|
||||
// For example, imagine you have an authentication plug, `MyAuth`,
|
||||
// which authenticates the session and assigns a `:current_user`.
|
||||
// If the current user exists you can assign the user's token in
|
||||
// the connection for use in the layout.
|
||||
//
|
||||
// In your "lib/web/router.ex":
|
||||
//
|
||||
// pipeline :browser do
|
||||
// ...
|
||||
// plug MyAuth
|
||||
// plug :put_user_token
|
||||
// end
|
||||
//
|
||||
// defp put_user_token(conn, _) do
|
||||
// if current_user = conn.assigns[:current_user] do
|
||||
// token = Phoenix.Token.sign(conn, "user socket", current_user.id)
|
||||
// assign(conn, :user_token, token)
|
||||
// else
|
||||
// conn
|
||||
// end
|
||||
// end
|
||||
//
|
||||
// Now you need to pass this token to JavaScript. You can do so
|
||||
// inside a script tag in "lib/web/templates/layout/app.html.eex":
|
||||
//
|
||||
// <script>window.userToken = "<%= assigns[:user_token] %>";</script>
|
||||
//
|
||||
// You will need to verify the user token in the "connect/3" function
|
||||
// in "lib/web/channels/user_socket.ex":
|
||||
//
|
||||
// def connect(%{"token" => token}, socket, _connect_info) do
|
||||
// # max_age: 1209600 is equivalent to two weeks in seconds
|
||||
// case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
|
||||
// {:ok, user_id} ->
|
||||
// {:ok, assign(socket, :user, user_id)}
|
||||
// {:error, reason} ->
|
||||
// :error
|
||||
// end
|
||||
// end
|
||||
//
|
||||
// Finally, connect to the socket:
|
||||
socket.connect()
|
||||
|
||||
// Now that you are connected, you can join channels with a topic:
|
||||
let channel = socket.channel("topic:subtopic", {})
|
||||
channel.join()
|
||||
.receive("ok", resp => { console.log("Joined successfully", resp) })
|
||||
.receive("error", resp => { console.log("Unable to join", resp) })
|
||||
|
||||
export default socket
|
||||
7434
assets/package-lock.json
generated
Normal file
7434
assets/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
assets/package.json
Normal file
24
assets/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"repository": {},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"deploy": "webpack --mode production",
|
||||
"watch": "webpack --mode development --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"phoenix": "file:../deps/phoenix",
|
||||
"phoenix_html": "file:../deps/phoenix_html"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"babel-loader": "^8.1.0",
|
||||
"copy-webpack-plugin": "^5.1.1",
|
||||
"css-loader": "^3.5.2",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
||||
"terser-webpack-plugin": "^2.3.5",
|
||||
"webpack": "4.41.5",
|
||||
"webpack-cli": "^3.3.11"
|
||||
}
|
||||
}
|
||||
41
assets/webpack.config.js
Normal file
41
assets/webpack.config.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
|
||||
module.exports = (env, options) => ({
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({ cache: true, parallel: true, sourceMap: false }),
|
||||
new OptimizeCSSAssetsPlugin({})
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
'./js/app.js': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
|
||||
},
|
||||
output: {
|
||||
filename: 'app.js',
|
||||
path: path.resolve(__dirname, '../priv/static/js')
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader']
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
|
||||
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
|
||||
]
|
||||
});
|
||||
39
config/config.exs
Normal file
39
config/config.exs
Normal file
@@ -0,0 +1,39 @@
|
||||
# This file is responsible for configuring your umbrella
|
||||
# and **all applications** and their dependencies with the
|
||||
# help of the Config module.
|
||||
#
|
||||
# Note that all applications in your umbrella share the
|
||||
# same configuration and dependencies, which is why they
|
||||
# all use the same configuration file. If you want different
|
||||
# configurations or dependencies per app, it is best to
|
||||
# move said applications out of the umbrella.
|
||||
import Config
|
||||
|
||||
# Sample configuration:
|
||||
#
|
||||
# config :logger, :console,
|
||||
# level: :info,
|
||||
# format: "$date $time [$level] $metadata$message\n",
|
||||
# metadata: [:user_id]
|
||||
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
config :cloudfire,
|
||||
ecto_repos: [Cloudfire.Repo]
|
||||
|
||||
# Configures the endpoint
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
secret_key_base: "5OVYJ83AcoQcPmdKNksuBhJFBhjHD1uUa9mDOHV/6EIdBQ6pXksIhkVeWIzFk5SD",
|
||||
render_errors: [view: CloudfireWeb.ErrorView, accepts: ~w(html json)],
|
||||
pubsub: [name: Cloudfire.PubSub, adapter: Phoenix.PubSub.PG2]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{Mix.env()}.exs"
|
||||
76
config/dev.exs
Normal file
76
config/dev.exs
Normal file
@@ -0,0 +1,76 @@
|
||||
import Config
|
||||
|
||||
# Configure your database
|
||||
config :cloudfire, Cloudfire.Repo,
|
||||
username: "cloudfire",
|
||||
password: "postgres",
|
||||
database: "cloudfire_dev",
|
||||
hostname: "localhost",
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10
|
||||
|
||||
# For development, we disable any cache and enable
|
||||
# debugging and code reloading.
|
||||
#
|
||||
# The watchers configuration can be used to run external
|
||||
# watchers to your application. For example, we use it
|
||||
# with webpack to recompile .js and .css sources.
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
http: [port: 4000],
|
||||
debug_errors: true,
|
||||
code_reloader: true,
|
||||
check_origin: false,
|
||||
watchers: [
|
||||
node: [
|
||||
"node_modules/webpack/bin/webpack.js",
|
||||
"--mode",
|
||||
"development",
|
||||
"--watch-stdin",
|
||||
cd: Path.expand("../assets", __DIR__)
|
||||
]
|
||||
]
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# In order to use HTTPS in development, a self-signed
|
||||
# certificate can be generated by running the following
|
||||
# Mix task:
|
||||
#
|
||||
# mix phx.gen.cert
|
||||
#
|
||||
# Note that this task requires Erlang/OTP 20 or later.
|
||||
# Run `mix help phx.gen.cert` for more information.
|
||||
#
|
||||
# The `http:` config above can be replaced with:
|
||||
#
|
||||
# https: [
|
||||
# port: 4001,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: "priv/cert/selfsigned_key.pem",
|
||||
# certfile: "priv/cert/selfsigned.pem"
|
||||
# ],
|
||||
#
|
||||
# If desired, both `http:` and `https:` keys can be
|
||||
# configured to run both http and https servers on
|
||||
# different ports.
|
||||
|
||||
# Watch static and templates for browser reloading.
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||
~r"priv/gettext/.*(po)$",
|
||||
~r"lib/cloudfire_web/(live|views)/.*(ex)$",
|
||||
~r"lib/cloudfire_web/templates/.*(eex)$"
|
||||
]
|
||||
]
|
||||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
config :logger, :console, format: "[$level] $message\n"
|
||||
|
||||
# Set a higher stacktrace during development. Avoid configuring such
|
||||
# in production as building large stacktraces may be expensive.
|
||||
config :phoenix, :stacktrace_depth, 20
|
||||
|
||||
# Initialize plugs at runtime for faster development compilation
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
55
config/prod.exs
Normal file
55
config/prod.exs
Normal file
@@ -0,0 +1,55 @@
|
||||
import Config
|
||||
|
||||
# For production, don't forget to configure the url host
|
||||
# to something meaningful, Phoenix uses this information
|
||||
# when generating URLs.
|
||||
#
|
||||
# Note we also include the path to a cache manifest
|
||||
# containing the digested version of static files. This
|
||||
# manifest is generated by the `mix phx.digest` task,
|
||||
# which you should run after static files are built and
|
||||
# before starting your production server.
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
url: [host: "example.com", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Do not print debug messages in production
|
||||
config :logger, level: :info
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
# to the previous section and set your `:url` port to 443:
|
||||
#
|
||||
# config :cloudfire, CloudfireWeb.Endpoint,
|
||||
# ...
|
||||
# url: [host: "example.com", port: 443],
|
||||
# https: [
|
||||
# port: 443,
|
||||
# cipher_suite: :strong,
|
||||
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
|
||||
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH"),
|
||||
# transport_options: [socket_opts: [:inet6]]
|
||||
# ]
|
||||
#
|
||||
# The `cipher_suite` is set to `:strong` to support only the
|
||||
# latest and more secure SSL ciphers. This means old browsers
|
||||
# and clients may not be supported. You can set it to
|
||||
# `:compatible` for wider support.
|
||||
#
|
||||
# `:keyfile` and `:certfile` expect an absolute path to the key
|
||||
# and cert in disk or a relative path inside priv, for example
|
||||
# "priv/ssl/server.key". For all supported SSL configuration
|
||||
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
|
||||
#
|
||||
# We also recommend setting `force_ssl` in your endpoint, ensuring
|
||||
# no data is ever sent via http, always redirecting to https:
|
||||
#
|
||||
# config :cloudfire, CloudfireWeb.Endpoint,
|
||||
# force_ssl: [hsts: true]
|
||||
#
|
||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||
|
||||
# Finally import the config/prod.secret.exs which loads secrets
|
||||
# and configuration from environment variables.
|
||||
import_config "prod.secret.exs"
|
||||
41
config/prod.secret.exs
Normal file
41
config/prod.secret.exs
Normal file
@@ -0,0 +1,41 @@
|
||||
# In this file, we load production configuration and secrets
|
||||
# from environment variables. You can also hardcode secrets,
|
||||
# although such is generally not recommended and you have to
|
||||
# remember to add this file to your .gitignore.
|
||||
import Config
|
||||
|
||||
database_url =
|
||||
System.get_env("DATABASE_URL") ||
|
||||
raise """
|
||||
environment variable DATABASE_URL is missing.
|
||||
For example: ecto://USER:PASS@HOST/DATABASE
|
||||
"""
|
||||
|
||||
config :cloudfire, Cloudfire.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
|
||||
secret_key_base =
|
||||
System.get_env("SECRET_KEY_BASE") ||
|
||||
raise """
|
||||
environment variable SECRET_KEY_BASE is missing.
|
||||
You can generate one by calling: mix phx.gen.secret
|
||||
"""
|
||||
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
http: [
|
||||
port: String.to_integer(System.get_env("PORT") || "4000"),
|
||||
transport_options: [socket_opts: [:inet6]]
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
|
||||
# ## Using releases (Elixir v1.9+)
|
||||
#
|
||||
# If you are doing OTP releases, you need to instruct Phoenix
|
||||
# to start each relevant endpoint:
|
||||
#
|
||||
config :cloudfire, CloudfireWeb.Endpoint, server: true
|
||||
#
|
||||
# Then you can assemble a release by calling `mix release`.
|
||||
# See `mix help release` for more information.
|
||||
32
config/test.exs
Normal file
32
config/test.exs
Normal file
@@ -0,0 +1,32 @@
|
||||
import Config
|
||||
|
||||
defmodule DBConfig do
|
||||
def config(db_url) when is_nil(db_url) do
|
||||
[
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
database: "cloudfire_test",
|
||||
hostname: System.get_env("POSTGRES_HOST", "localhost"),
|
||||
pool: Ecto.Adapters.SQL.Sandbox
|
||||
]
|
||||
end
|
||||
def config(db_url) do
|
||||
[
|
||||
url: db_url,
|
||||
pool: Ecto.Adapters.SQL.Sandbox
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
# Configure your database
|
||||
db_url = System.get_env("DATABASE_URL")
|
||||
config :cloudfire, Cloudfire.Repo, DBConfig.config(db_url)
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :cloudfire, CloudfireWeb.Endpoint,
|
||||
http: [port: 4002],
|
||||
server: false
|
||||
|
||||
# Print only warnings and errors during test
|
||||
config :logger, level: :warn
|
||||
21
mix.exs
Normal file
21
mix.exs
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule CloudfireUmbrella.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
apps_path: "apps",
|
||||
version: "0.1.0",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
# Dependencies listed here are available only for this
|
||||
# project and cannot be accessed from applications inside
|
||||
# the apps folder.
|
||||
#
|
||||
# Run "mix help deps" for examples and options.
|
||||
defp deps do
|
||||
[]
|
||||
end
|
||||
end
|
||||
25
mix.lock
Normal file
25
mix.lock
Normal file
@@ -0,0 +1,25 @@
|
||||
%{
|
||||
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
|
||||
"cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "04fd8c6a39edc6aaa9c26123009200fc61f92a3a94f3178c527b70b767c6e605"},
|
||||
"cowlib": {:hex, :cowlib, "2.8.0", "fd0ff1787db84ac415b8211573e9a30a3ebe71b5cbff7f720089972b2319c8a4", [:rebar3], [], "hexpm", "79f954a7021b302186a950a32869dbc185523d99d3e44ce430cd1f3289f41ed4"},
|
||||
"db_connection": {:hex, :db_connection, "2.2.1", "caee17725495f5129cb7faebde001dc4406796f12a62b8949f4ac69315080566", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "2b02ece62d9f983fcd40954e443b7d9e6589664380e5546b2b9b523cd0fb59e1"},
|
||||
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"},
|
||||
"ecto": {:hex, :ecto, "3.4.1", "ca5b5f6314eebd7fa2e52c6d78abb1ef955005dd60cc7a047b963ee23ee14a6c", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "748a317a2eacac0b7b6540cb7d2198b79457ede9cec2b4d1582117f90ac309d5"},
|
||||
"ecto_network": {:hex, :ecto_network, "1.3.0", "1e77fa37c20e0f6a426d3862732f3317b0fa4c18f123d325f81752a491d7304e", [:mix], [{:ecto_sql, ">= 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 0.0.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.14.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "053a5e46ef2837e8ea5ea97c82fa0f5494699209eddd764e663c85f11b2865bd"},
|
||||
"ecto_sql": {:hex, :ecto_sql, "3.4.2", "3d842665a81ba2137b62aa70151afe81dae44824cd09b2076a255937ab4e2dc9", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f2b064102467e1525314a464b6fea0707ff28ee132a15006727ccf51b73492ff"},
|
||||
"file_system": {:hex, :file_system, "0.2.8", "f632bd287927a1eed2b718f22af727c5aeaccc9a98d8c2bd7bff709e851dc986", [:mix], [], "hexpm", "97a3b6f8d63ef53bd0113070102db2ce05352ecf0d25390eb8d747c2bde98bca"},
|
||||
"gettext": {:hex, :gettext, "0.17.4", "f13088e1ec10ce01665cf25f5ff779e7df3f2dc71b37084976cf89d1aa124d5c", [:mix], [], "hexpm", "3c75b5ea8288e2ee7ea503ff9e30dfe4d07ad3c054576a6e60040e79a801e14d"},
|
||||
"jason": {:hex, :jason, "1.2.0", "10043418c42d2493d0ee212d3fddd25d7ffe484380afad769a0a38795938e448", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "116747dbe057794c3a3e4e143b7c8390b29f634e16c78a7f59ba75bfa6852e7f"},
|
||||
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"},
|
||||
"phoenix": {:hex, :phoenix, "1.4.16", "2cbbe0c81e6601567c44cc380c33aa42a1372ac1426e3de3d93ac448a7ec4308", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "856cc1a032fa53822737413cf51aa60e750525d7ece7d1c0576d90d7c0f05c24"},
|
||||
"phoenix_ecto": {:hex, :phoenix_ecto, "4.1.0", "a044d0756d0464c5a541b4a0bf4bcaf89bffcaf92468862408290682c73ae50d", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "c5e666a341ff104d0399d8f0e4ff094559b2fde13a5985d4cb5023b2c2ac558b"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "2.14.1", "7dabafadedb552db142aacbd1f11de1c0bbaa247f90c449ca549d5e30bbc66b4", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "536d5200ad37fecfe55b3241d90b7a8c3a2ca60cd012fc065f776324fa9ab0a9"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.1", "274a4b07c4adbdd7785d45a8b0bb57634d0b4f45b18d2c508b26c0344bd59b8f", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "41b4103a2fa282cfd747d377233baf213c648fdcc7928f432937676532490eee"},
|
||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm", "1f13f9f0f3e769a667a6b6828d29dec37497a082d195cc52dbef401a9b69bf38"},
|
||||
"plug": {:hex, :plug, "1.10.0", "6508295cbeb4c654860845fb95260737e4a8838d34d115ad76cd487584e2fc4d", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "422a9727e667be1bf5ab1de03be6fa0ad67b775b2d84ed908f3264415ef29d4a"},
|
||||
"plug_cowboy": {:hex, :plug_cowboy, "2.1.2", "8b0addb5908c5238fac38e442e81b6fcd32788eaa03246b4d55d147c47c5805e", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "7d722581ce865a237e14da6d946f92704101740a256bd13ec91e63c0b122fc70"},
|
||||
"plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"},
|
||||
"postgrex": {:hex, :postgrex, "0.15.3", "5806baa8a19a68c4d07c7a624ccdb9b57e89cbc573f1b98099e3741214746ae4", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4737ce62a31747b4c63c12b20c62307e51bb4fcd730ca0c32c280991e0606c90"},
|
||||
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
|
||||
"telemetry": {:hex, :telemetry, "0.4.1", "ae2718484892448a24470e6aa341bc847c3277bfb8d4e9289f7474d752c09c7f", [:rebar3], [], "hexpm", "4738382e36a0a9a2b6e25d67c960e40e1a2c95560b9f936d8e29de8cd858480f"},
|
||||
}
|
||||
Reference in New Issue
Block a user