Skip to content

Commit

Permalink
add check origin env variable (#323)
Browse files Browse the repository at this point in the history
* Add check origin env variable

* Fix thumbnailer spec
  • Loading branch information
gBillal authored Jan 15, 2024
1 parent 6ff50c1 commit 29ecb64
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ If you want to configure some aspects of `ex_nvr`, you can set the following env
| EXNVR_ADMIN_PASSWORD | The password of the admin user to create on first startup. Defaults to: `P@ssw0rd`. |
| SECRET_KEY_BASE | A 64 byte key that's used by **Pheonix** to encrypt cookies |
| EXNVR_URL | The `url` to use for generating URLs. The `host` is used as a default value for `check_origin` of the websocket. Defaults to: `http://localhost:4000` |
| EXNVR_CHECK_ORIGIN | if the transport should check the origin of requests when the origin header is present. May be true, false or a list of hosts that are allowed. Defaults to `true`. |
| EXNVR_HTTP_PORT | Http `port`, defaults to: `4000` |
| EXNVR_CORS_ALLOWED_ORIGINS | A space separated allowed origins for `CORS` requests. defaults to: `*` |
| EXNVR_ENABLE_HTTPS | Enable `https`, default: `false` |
Expand Down
2 changes: 1 addition & 1 deletion apps/ex_nvr/lib/ex_nvr/pipeline/output/thumbnailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule ExNVR.Pipeline.Output.Thumbnailer do
"Could not make directory or directory not writable '#{state.dest}', error: #{inspect(reason)}"
)

{[start_timer: {:check_directory, @interval}], state}
{[spec: spec, start_timer: {:check_directory, @interval}], state}
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ defmodule ExNVR.Pipeline.Source.RTSP.ConnectionManager do
|> min(@max_back_off_in_ms)
|> trunc()

Membrane.Logger.info("Retry rtsp connection in #{delay} ms")

{:backoff, delay, connection_status}
else
Membrane.Logger.debug("ConnectionManager: Max reconnect attempts reached. Hibernating")
Expand Down
2 changes: 1 addition & 1 deletion apps/ex_nvr/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ExNVR.MixProject do
def project do
[
app: :ex_nvr,
version: "0.8.0",
version: "0.9.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
Expand Down
2 changes: 1 addition & 1 deletion apps/ex_nvr_web/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ExNVRWeb.MixProject do
def project do
[
app: :ex_nvr_web,
version: "0.8.0",
version: "0.9.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
Expand Down
11 changes: 4 additions & 7 deletions apps/ex_nvr_web/priv/static/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: ExNVR API
description: Manage ExNVR via API endpoints
version: 0.8.0
version: 0.9.0
servers:
- url: '{protocol}://{host}:{port}'
variables:
Expand Down Expand Up @@ -831,14 +831,11 @@ components:
default: false
description: A boolean value to signal that when reaching the override_on_full_disk_threshold on the storage_address disk usage percentage the 30 oldest recordings would be deleted
override_on_full_disk_threshold:
type: float
type: number
default: 90.0
minimum: 0.0
maximum: 100.0
description: A float value where if storage_address storage usage percentage reaches this value the 30 oldest recordings will be deleted
oneOf:
- minimum: 0
maximum: 100
exclusiveMinimum: true
exclusiveMaximum: true
required: [storage_address]
Error:
type: object
Expand Down
10 changes: 9 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,21 @@ if config_env() == :prod do

url = URI.parse(System.get_env("EXNVR_URL", "http://localhost:4000"))

check_origin =
case System.get_env("EXNVR_CHECK_ORIGIN", "true") do
"true" -> true
"false" -> false
origins -> String.split(origins, ",")
end

config :ex_nvr_web, ExNVRWeb.Endpoint,
http: [
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: String.to_integer(System.get_env("EXNVR_HTTP_PORT") || "4000")
],
secret_key_base: secret_key_base,
url: [scheme: url.scheme, host: url.host, port: url.port]
url: [scheme: url.scheme, host: url.host, port: url.port],
check_origin: check_origin

## SSL Support
enable_ssl = String.to_existing_atom(System.get_env("EXNVR_ENABLE_HTTPS", "false"))
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule ExNVR.Umbrella.MixProject do
use Mix.Project

@version "0.8.0"
@version "0.9.0"

def project do
[
Expand Down

0 comments on commit 29ecb64

Please sign in to comment.