Parse single IP addresses
This commit is contained in:
parent
4371d0f445
commit
ae9d67eb8a
1 changed files with 8 additions and 0 deletions
|
@ -16,7 +16,13 @@ module Zone = struct
|
||||||
let rec of_json = function
|
let rec of_json = function
|
||||||
| `String str ->
|
| `String str ->
|
||||||
str |> V6.Prefix.of_string |> Result.map ipv6
|
str |> V6.Prefix.of_string |> Result.map ipv6
|
||||||
|
&?> (str |> V6.of_string
|
||||||
|
|> Result.map V6.Prefix.of_addr
|
||||||
|
|> Result.map ipv6)
|
||||||
&?> (str |> V4.Prefix.of_string |> Result.map ipv4)
|
&?> (str |> V4.Prefix.of_string |> Result.map ipv4)
|
||||||
|
&?> (str |> V4.of_string
|
||||||
|
|> Result.map V4.Prefix.of_addr
|
||||||
|
|> Result.map ipv4)
|
||||||
&> (str |> name)
|
&> (str |> name)
|
||||||
| `Assoc [ ("not", json) ] -> Not (of_json json)
|
| `Assoc [ ("not", json) ] -> Not (of_json json)
|
||||||
| `List list -> List (List.map of_json list)
|
| `List list -> List (List.map of_json list)
|
||||||
|
@ -34,7 +40,9 @@ module Addrs = struct
|
||||||
let open Yojson.Basic.Util in
|
let open Yojson.Basic.Util in
|
||||||
let str = json |> to_string in
|
let str = json |> to_string in
|
||||||
str |> V6.Prefix.of_string |> Result.map ipv6
|
str |> V6.Prefix.of_string |> Result.map ipv6
|
||||||
|
&?> (str |> V6.of_string |> Result.map V6.Prefix.of_addr |> Result.map ipv6)
|
||||||
&?> (str |> V4.Prefix.of_string |> Result.map ipv4)
|
&?> (str |> V4.Prefix.of_string |> Result.map ipv4)
|
||||||
|
&?> (str |> V4.of_string |> Result.map V4.Prefix.of_addr |> Result.map ipv4)
|
||||||
&> (str |> name)
|
&> (str |> name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue