diff options
| author | Caian Benedicto <caianbene@gmail.com> | 2024-12-14 15:18:25 -0300 |
|---|---|---|
| committer | Caian Benedicto <caianbene@gmail.com> | 2024-12-14 15:18:25 -0300 |
| commit | 275318dae2056737f101054b8e4527091fb0e73f (patch) | |
| tree | b150a087acdc8d4f000c74b365cb28fa8b425506 /src | |
| parent | 48d225002427e874a3b02ee0ba88ba6169304c52 (diff) | |
| download | invidious-275318dae2056737f101054b8e4527091fb0e73f.tar.gz invidious-275318dae2056737f101054b8e4527091fb0e73f.tar.bz2 invidious-275318dae2056737f101054b8e4527091fb0e73f.zip | |
Change socket_binding to a nested configuration in YAML
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 11 | ||||
| -rw-r--r-- | src/invidious/config.cr | 9 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index afbffcde..8b0ab911 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -250,14 +250,13 @@ Kemal.config.app_name = "Invidious" Kemal.run do |config| if CONFIG.socket_binding socket_binding = CONFIG.socket_binding.not_nil! - if File.exists?(socket_binding) - File.delete(socket_binding) + if File.exists?(socket_binding.path) + File.delete(socket_binding.path) end # Create a socket and set its desired permissions - tokens = socket_binding.rpartition(',') - server = UNIXServer.new(tokens[0]) - perms = tokens[2].to_i(base: 8) - File.chmod(tokens[0], perms) + server = UNIXServer.new(socket_binding.path) + perms = socket_binding.permissions.to_i(base: 8) + File.chmod(socket_binding.path, perms) config.server.not_nil!.bind server else Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.config.host_binding : CONFIG.host_binding diff --git a/src/invidious/config.cr b/src/invidious/config.cr index feda3958..b15cf832 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -8,6 +8,13 @@ struct DBConfig property dbname : String end +struct SocketBindingConfig + include YAML::Serializable + + property path : String + property permissions : String +end + struct ConfigPreferences include YAML::Serializable @@ -139,7 +146,7 @@ class Config # Host to bind (overridden by command line argument) property host_binding : String = "0.0.0.0" # Path and permissions to make Invidious listen on a UNIX socket instead of a TCP port - Example: /tmp/invidious.sock,777 - property socket_binding : String? = nil + property socket_binding : SocketBindingConfig? = nil # Pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool of `pool_size`) property pool_size : Int32 = 100 # HTTP Proxy configuration |
