···120120 in
121121 let bundle : Bundle.t = { primary; blocks = [ payload_block ] } in
122122 let ipaddr =
123123- if dest_host = "127.0.0.1" || dest_host = "localhost" then
124124- Eio.Net.Ipaddr.V4.loopback
125125- else
126126- (* Parse IPv4 address string like "192.168.1.1" *)
127127- let parts = String.split_on_char '.' dest_host in
128128- match List.map int_of_string parts with
129129- | [ a; b; c; d ] ->
130130- let raw =
131131- String.init 4 (fun i ->
132132- match i with
133133- | 0 -> Char.chr a
134134- | 1 -> Char.chr b
135135- | 2 -> Char.chr c
136136- | _ -> Char.chr d)
137137- in
138138- Eio.Net.Ipaddr.of_raw raw
139139- | _ -> failwith ("Invalid IP address: " ^ dest_host)
123123+ match Ipaddr.of_string dest_host with
124124+ | Ok (V4 ip) -> Eio.Net.Ipaddr.of_raw (Ipaddr.V4.to_octets ip)
125125+ | Ok (V6 ip) -> Eio.Net.Ipaddr.of_raw (Ipaddr.V6.to_octets ip)
126126+ | Error (`Msg e) -> failwith ("Invalid IP address: " ^ e)
140127 in
141128 let addr = `Tcp (ipaddr, dest_port) in
142129 Log.info (fun m -> m "Connecting to %s:%d..." dest_host dest_port);