Skip to content

Commit 389c1f3

Browse files
authored
Merge pull request #71 from reynir/fix-test-server
Fix test server
2 parents 7f43310 + 55f6405 commit 389c1f3

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/server.ml

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ type event =
3030
| Set_env of (string * string)
3131
| Start_shell of int32
3232

33+
let pp_event ppf = function
34+
| Channel_exec (c, cmd) -> Fmt.pf ppf "channel exec %lu: %S" c cmd
35+
| Channel_subsystem (c, cmd) -> Fmt.pf ppf "channel subsystem %lu: %S" c cmd
36+
| Channel_data (c, data) -> Fmt.pf ppf "channel data %lu: %d bytes" c (Cstruct.length data)
37+
| Channel_eof c -> Fmt.pf ppf "channel end-of-file %lu" c
38+
| Disconnected s -> Fmt.pf ppf "disconnected with messsage %S" s
39+
| Pty _ -> Fmt.pf ppf "pty"
40+
| Pty_set _ -> Fmt.pf ppf "pty set"
41+
| Set_env (k, v) -> Fmt.pf ppf "Set env %S=%S" k v
42+
| Start_shell c -> Fmt.pf ppf "start shell %lu" c
43+
3344
type t = {
3445
client_version : string option; (* Without crlf *)
3546
server_version : string; (* Without crlf *)

test/awa_test_server.ml

+17-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,23 @@ let rec serve t cmd =
177177
Logs.info (fun m -> m "%s" msg);
178178
let* t = Driver.disconnect t in
179179
serve t cmd end
180-
| _ -> failwith "Invalid SSH event"
180+
| Set_env (k, v) ->
181+
Logs.info (fun m -> m "Ignoring Set_env (%S, %S)" k v);
182+
serve t cmd
183+
| Pty _ | Pty_set _ ->
184+
let msg =
185+
Ssh.disconnect_msg Ssh.DISCONNECT_SERVICE_NOT_AVAILABLE
186+
"Sorry no PTY for you"
187+
in
188+
let* _ = Driver.send_msg t msg in
189+
Ok ()
190+
| Start_shell _ ->
191+
let msg =
192+
Ssh.disconnect_msg Ssh.DISCONNECT_SERVICE_NOT_AVAILABLE
193+
"Sorry no shell for you"
194+
in
195+
let* _ = Driver.send_msg t msg in
196+
Ok ()
181197

182198
let user_db =
183199
(* User foo auths by passoword *)

0 commit comments

Comments
 (0)