objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix dns handle resolution

futurGH 60219f1d 350b9a68

+8 -16
+8 -16
pegasus/lib/id_resolver.ml
··· 1 1 open Cohttp_lwt 2 2 3 - let did_regex = 4 - Re.Pcre.re {|^did:([a-z]+):([a-zA-Z0-9._:%\-]*[a-zA-Z0-9._\-])$|} 5 - |> Re.compile 6 - 7 3 module Handle = struct 8 4 let dns_client = Dns_client_unix.create () 9 5 ··· 26 22 try%lwt 27 23 match 28 24 Dns_client_unix.getaddrinfo dns_client Dns.Rr_map.Txt 29 - (Domain_name.of_string_exn handle) 25 + (Domain_name.of_string_exn ("_atproto." ^ handle)) 30 26 with 31 27 | Ok (_, t) -> ( 32 28 let txt = Dns.Rr_map.Txt_set.choose t in 33 - match Re.exec_opt did_regex txt with 34 - | Some groups -> ( 35 - let method_name = Re.Group.get groups 1 in 36 - let id = Re.Group.get groups 2 in 37 - match method_name with 38 - | "web" | "plc" -> 39 - Lwt.return_ok ("did:" ^ method_name ^ ":" ^ id) 40 - | _ -> 41 - Lwt.return_error ("unsupported method" ^ method_name) ) 42 - | None -> 43 - Lwt.return_error "invalid txt record" ) 29 + match String.split_on_char '=' txt with 30 + | ["did"; did] 31 + when String.starts_with ~prefix:"did:plc:" did 32 + || String.starts_with ~prefix:"did:web:" did -> 33 + Lwt.return_ok did 34 + | _ -> 35 + Lwt.return_error "invalid did in dns record" ) 44 36 | Error (`Msg e) -> 45 37 Lwt.return_error e 46 38 with exn -> Lwt.return_error (Printexc.to_string exn)