Format config.ml

This commit is contained in:
jeltz 2022-08-29 21:14:06 +02:00
parent 397eebb638
commit 2a837d831d
Signed by: jeltz
GPG key ID: 800882B66C0C3326

View file

@ -7,45 +7,34 @@ type zone =
| ZoneList of zone list
| ZoneExclude of zone
type addrs =
| ZoneName of string
| Ipv4 of V4.Prefix.t
| Ipv6 of V6.Prefix.t
type addrs = ZoneName of string | Ipv4 of V4.Prefix.t | Ipv6 of V6.Prefix.t
type l4_rule =
| TcpRule of { sport: int list; dport: int list }
| UdpRule of { sport: int list; dport: int list }
| TcpRule of { sport : int list; dport : int list }
| UdpRule of { sport : int list; dport : int list }
| IcmpRule
type rule = { src: addrs list; dest: addrs list; l4: l4_rule }
type config = { zones: (string * zone) list; rules: rule list }
type rule = { src : addrs list; dest : addrs list; l4 : l4_rule }
type config = { zones : (string * zone list) list; rules : rule list }
(* TODO *)
let zone_of_json _ =
Zone "xxx"
let zone_of_json _ = [ Zone "xxx" ]
let addrs_of_json json =
let open Yojson.Basic.Util in
let value = json |> to_string in
let addrs = ZoneName value in
let addrs = match V6.Prefix.of_string value with
| Ok p -> Ipv6 p
| Error _ -> addrs
let addrs =
match V6.Prefix.of_string value with Ok p -> Ipv6 p | Error _ -> addrs
in
match V4.Prefix.of_string value with
| Ok p -> Ipv4 p
| Error _ -> addrs
match V4.Prefix.of_string value with Ok p -> Ipv4 p | Error _ -> addrs
let addrs_list_of_json json =
let open Yojson.Basic.Util in
let elems = json |> to_list in
List.map addrs_of_json elems
let to_list_force = function
| `List l -> l
| _ -> []
let to_list_force = function `List l -> l | _ -> []
let to_int_list json =
let open Yojson.Basic.Util in