summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/config.cr21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/invidious/config.cr b/src/invidious/config.cr
index b15cf832..6578709e 100644
--- a/src/invidious/config.cr
+++ b/src/invidious/config.cr
@@ -145,7 +145,7 @@ class Config
property port : Int32 = 3000
# 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
+ # Path and permissions to make Invidious listen on a UNIX socket instead of a TCP port
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
@@ -258,6 +258,25 @@ class Config
end
end
+ # Check if the socket configuration is valid
+ if config.socket_binding
+ sb = config.socket_binding.not_nil!
+ if sb.path.ends_with?("/") || File.directory?(sb.path)
+ puts "Config: The socket path " + sb.path + " must not be a directory!"
+ exit(1)
+ end
+ d = File.dirname(sb.path)
+ if !File.directory?(d)
+ puts "Config: Socket directory " + sb.path + " does not exist or is not a directory!"
+ exit(1)
+ end
+ p = sb.permissions.to_i?(base: 8)
+ if !p || p < 0 || p > 0o777
+ puts "Config: Socket permissions must be an octal between 0 and 777!"
+ exit(1)
+ end
+ end
+
return config
end
end