Limit number of concurrent logins
This commit is contained in:
parent
f70354c683
commit
cf7563e5ed
|
@ -17,6 +17,8 @@
|
|||
|
||||
(define *user-states* (make-hash))
|
||||
|
||||
(define *login-limit* (make-semaphore 3))
|
||||
|
||||
(define *interaction* (make-room 'interaction))
|
||||
(spy-on *interaction*)
|
||||
|
||||
|
@ -120,9 +122,23 @@
|
|||
(close-input-port in)
|
||||
(close-output-port out)))
|
||||
|
||||
(define (limited-repl-shell username in out)
|
||||
(call-with-semaphore *login-limit*
|
||||
(lambda () (repl-shell username in out))
|
||||
(lambda () (reject-login username in out))))
|
||||
|
||||
(define (reject-login username in out)
|
||||
(parameterize ((current-input-port in)
|
||||
(current-output-port out)
|
||||
(current-error-port out))
|
||||
(printf "Hello, ~a - unfortunately, the system is too busy to accept your\n" username)
|
||||
(printf "login right now. Please try again later.\n")
|
||||
(close-input-port in)
|
||||
(close-output-port out)))
|
||||
|
||||
(define (t-server)
|
||||
(define s (tcp-listen 2322 4 #t))
|
||||
(printf "Accepting...\n")
|
||||
(tcp-pty-ssh-server s repl-shell #:prompt *prompt*))
|
||||
(tcp-pty-ssh-server s limited-repl-shell #:prompt *prompt*))
|
||||
|
||||
(t-server)
|
||||
|
|
Loading…
Reference in New Issue