File tree Expand file tree Collapse file tree 2 files changed +30
-20
lines changed Expand file tree Collapse file tree 2 files changed +30
-20
lines changed Original file line number Diff line number Diff line change 1
- open Mirage
1
+ (* mirage >= 4.6.0 & < 4.6.1 *)
2
2
3
- let port =
4
- let doc =
5
- Key.Arg. info ~doc: " Set the port where the relay will listen."
6
- [ " p" ; " port" ]
7
- in
8
- Key. (create " port" Arg. (opt int 9000 doc))
3
+ open Mirage
9
4
10
- let secure_port =
11
- let doc =
12
- Key.Arg. info ~doc: " The port of the relay where secured rooms are available."
13
- [ " secure-port" ]
14
- in
15
- Key. (create " secure_port" Arg. (opt int 9001 doc))
5
+ let setup = runtime_arg ~pos: __POS__ " Unikernel.K.setup"
16
6
17
7
let bob =
18
- foreign " Unikernel.Make"
8
+ main " Unikernel.Make" ~runtime_args: [ setup ]
19
9
~packages:
20
10
[
21
11
package " bob" ~pin: " git+https://github.com/dinosaure/bob.git" ;
22
12
package " spoke" ~sublibs: [ " core" ];
23
13
package " psq" ;
24
14
]
25
- ~keys: [ Key. v port; Key. v secure_port ]
26
15
(time @-> stackv4v6 @-> job)
27
16
28
17
let time = default_time
Original file line number Diff line number Diff line change 1
1
open Lwt.Infix
2
2
3
+ module K = struct
4
+ open Cmdliner
5
+
6
+ let port =
7
+ let doc =
8
+ Arg. info ~doc: " Set the port where the relay will listen." [ " p" ; " port" ]
9
+ in
10
+ Arg. (value & opt int 9000 doc)
11
+
12
+ let secure_port =
13
+ let doc =
14
+ Arg. info
15
+ ~doc: " The port of the relay where the secured rooms are available."
16
+ [ " secure-port" ]
17
+ in
18
+ Arg. (value & opt int 9001 doc)
19
+
20
+ type t = { port : int ; secure_port : int }
21
+
22
+ let v port secure_port = { port; secure_port }
23
+ let setup = Term. (const v $ port $ secure_port)
24
+ end
25
+
3
26
module Psq =
4
27
Psq. Make
5
28
(String )
@@ -444,14 +467,12 @@ module Make (Time : Mirage_time.S) (Stack : Tcpip.Stack.V4V6) = struct
444
467
445
468
module Bob_clear = Make (Stack. TCP )
446
469
447
- let start _time stack =
470
+ let start _time stack { K. port; K. secure_port } =
448
471
let rooms = Bob.Secured. make () in
449
472
let handshake socket = Lwt. return (Ok (socket, Stack.TCP. dst socket)) in
450
473
Lwt. join
451
474
[
452
- Bob_clear. relay ~port: (Key_gen. port () ) ~handshake (Stack. tcp stack)
453
- rooms;
454
- Secured. secure_room ~port: (Key_gen. secure_port () ) (Stack. tcp stack)
455
- rooms;
475
+ Bob_clear. relay ~port ~handshake (Stack. tcp stack) rooms;
476
+ Secured. secure_room ~port: secure_port (Stack. tcp stack) rooms;
456
477
]
457
478
end
You can’t perform that action at this time.
0 commit comments