mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2025-07-06 03:34:42 -04:00
Add a comment about our usage of List.hd (which can fail) and String.split_on_char
This commit is contained in:
parent
ad1afe99ee
commit
3dc545681d
1 changed files with 2 additions and 0 deletions
2
dao.ml
2
dao.ml
|
@ -81,6 +81,8 @@ let vifs client domid =
|
||||||
let get_client_ip () =
|
let get_client_ip () =
|
||||||
let* str = Xen_os.Xs.read handle (Fmt.str "%s/%d/ip" path device_id) in
|
let* str = Xen_os.Xs.read handle (Fmt.str "%s/%d/ip" path device_id) in
|
||||||
let client_ip = List.hd (String.split_on_char ' ' str) in
|
let client_ip = List.hd (String.split_on_char ' ' str) in
|
||||||
|
(* XXX(dinosaure): it's safe to use [List.hd] here,
|
||||||
|
[String.split_on_char] can not return an empty list. *)
|
||||||
Lwt.return_some (vif, Ipaddr.V4.of_string_exn client_ip)
|
Lwt.return_some (vif, Ipaddr.V4.of_string_exn client_ip)
|
||||||
in
|
in
|
||||||
Lwt.catch get_client_ip @@ function
|
Lwt.catch get_client_ip @@ function
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue