user admin
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
simple-log
|
||||
"private/library.rkt"
|
||||
"private/player.rkt"
|
||||
"private/server.rkt")
|
||||
"private/server.rkt"
|
||||
"private/users.rkt")
|
||||
|
||||
(provide run-web-player)
|
||||
|
||||
@@ -29,6 +30,14 @@
|
||||
(caddr line)))
|
||||
'())))
|
||||
|
||||
(define (configuration-list value defaults)
|
||||
(cond
|
||||
((list? value) (map (lambda (item) (format "~a" item)) value))
|
||||
((and (string? value)
|
||||
(not (string=? (string-trim value) "")))
|
||||
(map string-trim (string-split value ";")))
|
||||
(else defaults)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Provided functions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -41,12 +50,25 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(define/contract (run-web-player music-paths
|
||||
#:allowed-agent-ids [allowed-agent-ids '()]
|
||||
#:users [users '()]
|
||||
#:local-networks
|
||||
[local-networks
|
||||
'("127.0.0.0/8" "::1/128"
|
||||
"10.0.0.0/8" "172.16.0.0/12"
|
||||
"192.168.0.0/16")]
|
||||
#:trusted-proxies
|
||||
[trusted-proxies '("127.0.0.0/8" "::1/128")]
|
||||
#:session-seconds [session-seconds 43200]
|
||||
#:listen-ip [listen-ip "127.0.0.1"]
|
||||
#:port [port 8080]
|
||||
#:dlna-port [dlna-port 8734]
|
||||
#:launch-browser? [launch-browser? #t])
|
||||
(->* ((listof library-spec/c))
|
||||
(#:allowed-agent-ids (listof string?)
|
||||
#:users (listof (cons/c string? string?))
|
||||
#:local-networks (listof string?)
|
||||
#:trusted-proxies (listof string?)
|
||||
#:session-seconds exact-positive-integer?
|
||||
#:listen-ip string?
|
||||
#:port exact-positive-integer?
|
||||
#:dlna-port exact-positive-integer?
|
||||
@@ -55,7 +77,12 @@
|
||||
(let* ((libraries (make-music-libraries music-paths))
|
||||
(player (make-player libraries
|
||||
#:allowed-agent-ids allowed-agent-ids
|
||||
#:dlna-port dlna-port)))
|
||||
#:dlna-port dlna-port))
|
||||
(auth-manager
|
||||
(make-auth-manager users
|
||||
#:local-networks local-networks
|
||||
#:trusted-proxies trusted-proxies
|
||||
#:session-seconds session-seconds)))
|
||||
(info-rkt-web-player
|
||||
"Starting with ~a music library/libraries on http://~a:~a/"
|
||||
(length libraries)
|
||||
@@ -65,6 +92,7 @@
|
||||
void
|
||||
(λ ()
|
||||
(serve-player player
|
||||
#:auth-manager auth-manager
|
||||
#:listen-ip listen-ip
|
||||
#:port port
|
||||
#:launch-browser? launch-browser?))
|
||||
@@ -134,6 +162,25 @@
|
||||
#:when (not (eq? (cdr entry) #f)))
|
||||
(car entry)))
|
||||
|
||||
(define configured-users
|
||||
(for/list ((entry (in-list (ini-section-key-values config 'users)))
|
||||
#:when (string? (cdr entry)))
|
||||
entry))
|
||||
|
||||
(define local-networks
|
||||
(configuration-list
|
||||
(ini-get config 'authentication 'local-networks "")
|
||||
'("127.0.0.0/8" "::1/128"
|
||||
"10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16")))
|
||||
|
||||
(define trusted-proxies
|
||||
(configuration-list
|
||||
(ini-get config 'authentication 'trusted-proxies "")
|
||||
'("127.0.0.0/8" "::1/128")))
|
||||
|
||||
(define session-seconds
|
||||
(ini-get config 'authentication 'session-seconds 43200))
|
||||
|
||||
(define all-libraries
|
||||
(append configured-libraries
|
||||
music-paths
|
||||
@@ -143,6 +190,10 @@
|
||||
(run-web-player
|
||||
all-libraries
|
||||
#:allowed-agent-ids allowed-agent-ids
|
||||
#:users configured-users
|
||||
#:local-networks local-networks
|
||||
#:trusted-proxies trusted-proxies
|
||||
#:session-seconds session-seconds
|
||||
#:listen-ip (or listen-ip
|
||||
(ini-get config 'server 'listen-ip "127.0.0.1"))
|
||||
#:port (or port
|
||||
|
||||
Reference in New Issue
Block a user