From 92bf8d8ed932caf802d7161647b75a3808f130ef Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 21 Jun 2021 15:07:10 +0200 Subject: [PATCH] Use a function instead of a macro --- syndicate-ssh/new-server.rkt | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/syndicate-ssh/new-server.rkt b/syndicate-ssh/new-server.rkt index dd9bf5a..fc17a48 100644 --- a/syndicate-ssh/new-server.rkt +++ b/syndicate-ssh/new-server.rkt @@ -73,26 +73,22 @@ (log-error "Invalid peer identification string ~v" remote-identification) (stop-actor-system)])]) - (define-syntax-rule (auth-method m p x) - (begin - (assert (SshAuthenticationMethodAcceptable m)) - (during (Observe (:pattern (SshAuthenticationAcceptable m ,(DLit $r) ,_)) _) - (match (parse-SshAuthRequest r) - [p (assert (SshAuthenticationAcceptable m r x))] - [_ (assert (SshAuthenticationAcceptable m r #f))])))) + (define (auth-method m f) + (assert (SshAuthenticationMethodAcceptable m)) + (during (Observe (:pattern (SshAuthenticationAcceptable m ,(DLit $r) ,_)) _) + (assert (SshAuthenticationAcceptable m r (f (parse-SshAuthRequest r)))))) (auth-method (SshAuthMethod-none) - (SshAuthRequest-none username) - (equal? username "guest")) + (match-lambda [(SshAuthRequest-none "guest") #t] + [_ #f])) (auth-method (SshAuthMethod-password) - (SshAuthRequest-password username password) - (and (equal? username "user") - (equal? password "password"))) + (match-lambda [(SshAuthRequest-password "user" "password") #t] + [_ #f])) (auth-method (SshAuthMethod-publickey) - (SshAuthRequest-publickey username key) - (and (equal? username "tonyg") - (equal? (->preserve key) - (public-key->pieces test-user-public)))) + (match-lambda [(SshAuthRequest-publickey "tonyg" key) + (equal? (->preserve key) + (public-key->pieces test-user-public))] + [_ #f])) (during (SshAuthenticatedUser $user-name #"ssh-connection") (run-repl-instance conn-ds user-name))