Skip to content

Commit

Permalink
Merge pull request #71 from reynir/fix-test-server
Browse files Browse the repository at this point in the history
Fix test server
  • Loading branch information
hannesm authored Feb 8, 2024
2 parents 7f43310 + 55f6405 commit 389c1f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ type event =
| Set_env of (string * string)
| Start_shell of int32

let pp_event ppf = function
| Channel_exec (c, cmd) -> Fmt.pf ppf "channel exec %lu: %S" c cmd
| Channel_subsystem (c, cmd) -> Fmt.pf ppf "channel subsystem %lu: %S" c cmd
| Channel_data (c, data) -> Fmt.pf ppf "channel data %lu: %d bytes" c (Cstruct.length data)
| Channel_eof c -> Fmt.pf ppf "channel end-of-file %lu" c
| Disconnected s -> Fmt.pf ppf "disconnected with messsage %S" s
| Pty _ -> Fmt.pf ppf "pty"
| Pty_set _ -> Fmt.pf ppf "pty set"
| Set_env (k, v) -> Fmt.pf ppf "Set env %S=%S" k v
| Start_shell c -> Fmt.pf ppf "start shell %lu" c

type t = {
client_version : string option; (* Without crlf *)
server_version : string; (* Without crlf *)
Expand Down
18 changes: 17 additions & 1 deletion test/awa_test_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,23 @@ let rec serve t cmd =
Logs.info (fun m -> m "%s" msg);
let* t = Driver.disconnect t in
serve t cmd end
| _ -> failwith "Invalid SSH event"
| Set_env (k, v) ->
Logs.info (fun m -> m "Ignoring Set_env (%S, %S)" k v);
serve t cmd
| Pty _ | Pty_set _ ->
let msg =
Ssh.disconnect_msg Ssh.DISCONNECT_SERVICE_NOT_AVAILABLE
"Sorry no PTY for you"
in
let* _ = Driver.send_msg t msg in
Ok ()
| Start_shell _ ->
let msg =
Ssh.disconnect_msg Ssh.DISCONNECT_SERVICE_NOT_AVAILABLE
"Sorry no shell for you"
in
let* _ = Driver.send_msg t msg in
Ok ()

let user_db =
(* User foo auths by passoword *)
Expand Down

0 comments on commit 389c1f3

Please sign in to comment.