forked from syndicate-lang/marketplace-ssh-2014
Use a function instead of a macro
This commit is contained in:
parent
7ae447253d
commit
92bf8d8ed9
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue