Format config.ml
This commit is contained in:
parent
397eebb638
commit
2a837d831d
1 changed files with 10 additions and 21 deletions
31
config.ml
31
config.ml
|
@ -7,45 +7,34 @@ type zone =
|
||||||
| ZoneList of zone list
|
| ZoneList of zone list
|
||||||
| ZoneExclude of zone
|
| ZoneExclude of zone
|
||||||
|
|
||||||
type addrs =
|
type addrs = ZoneName of string | Ipv4 of V4.Prefix.t | Ipv6 of V6.Prefix.t
|
||||||
| ZoneName of string
|
|
||||||
| Ipv4 of V4.Prefix.t
|
|
||||||
| Ipv6 of V6.Prefix.t
|
|
||||||
|
|
||||||
type l4_rule =
|
type l4_rule =
|
||||||
| TcpRule of { sport: int list; dport: int list }
|
| TcpRule of { sport : int list; dport : int list }
|
||||||
| UdpRule of { sport: int list; dport: int list }
|
| UdpRule of { sport : int list; dport : int list }
|
||||||
| IcmpRule
|
| IcmpRule
|
||||||
|
|
||||||
type rule = { src: addrs list; dest: addrs list; l4: l4_rule }
|
type rule = { src : addrs list; dest : addrs list; l4 : l4_rule }
|
||||||
|
type config = { zones : (string * zone list) list; rules : rule list }
|
||||||
type config = { zones: (string * zone) list; rules: rule list }
|
|
||||||
|
|
||||||
|
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
let zone_of_json _ =
|
let zone_of_json _ = [ Zone "xxx" ]
|
||||||
Zone "xxx"
|
|
||||||
|
|
||||||
let addrs_of_json json =
|
let addrs_of_json json =
|
||||||
let open Yojson.Basic.Util in
|
let open Yojson.Basic.Util in
|
||||||
let value = json |> to_string in
|
let value = json |> to_string in
|
||||||
let addrs = ZoneName value in
|
let addrs = ZoneName value in
|
||||||
let addrs = match V6.Prefix.of_string value with
|
let addrs =
|
||||||
| Ok p -> Ipv6 p
|
match V6.Prefix.of_string value with Ok p -> Ipv6 p | Error _ -> addrs
|
||||||
| Error _ -> addrs
|
|
||||||
in
|
in
|
||||||
match V4.Prefix.of_string value with
|
match V4.Prefix.of_string value with Ok p -> Ipv4 p | Error _ -> addrs
|
||||||
| Ok p -> Ipv4 p
|
|
||||||
| Error _ -> addrs
|
|
||||||
|
|
||||||
let addrs_list_of_json json =
|
let addrs_list_of_json json =
|
||||||
let open Yojson.Basic.Util in
|
let open Yojson.Basic.Util in
|
||||||
let elems = json |> to_list in
|
let elems = json |> to_list in
|
||||||
List.map addrs_of_json elems
|
List.map addrs_of_json elems
|
||||||
|
|
||||||
let to_list_force = function
|
let to_list_force = function `List l -> l | _ -> []
|
||||||
| `List l -> l
|
|
||||||
| _ -> []
|
|
||||||
|
|
||||||
let to_int_list json =
|
let to_int_list json =
|
||||||
let open Yojson.Basic.Util in
|
let open Yojson.Basic.Util in
|
||||||
|
|
Loading…
Reference in a new issue