Skip to content

Commit

Permalink
remove dependency en cohttp version
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtori committed Oct 1, 2024
1 parent 958e02c commit 938e0a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(dirs :standard)
(env
(_
(flags (:standard -w +a-4-41-44-45-48-70 -warn-error -a))))
(flags (:standard -w +a-4-41-42-44-45-48-70 -warn-error -a))))
21 changes: 11 additions & 10 deletions src/server/cohttp/ezAPIServerCohttp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ let set_debug () = Cohttp_lwt_unix.Debug.activate_debug ()

let register_ip req io time =
let open Conduit_lwt_unix in match io with
| Domain_socket _ | Vchan _ | Tunnel _ -> ()
| TCP tcp ->
match[@warning "-42"] Lwt_unix.getpeername tcp.fd with
| Lwt_unix.ADDR_INET (ip,_port) ->
let ip = Ipaddr.to_string (Ipaddr_unix.of_inet_addr ip) in
let ip =
match Header.get (Request.headers req) "x-forwarded-for" with
| None -> ip
| Some ip -> ip in
Ip.register time ip
| Lwt_unix.ADDR_UNIX _path -> ()
begin match Lwt_unix.getpeername tcp.fd with
| Lwt_unix.ADDR_INET (ip,_port) ->
let ip = Ipaddr.to_string (Ipaddr_unix.of_inet_addr ip) in
let ip =
match Header.get (Request.headers req) "x-forwarded-for" with
| None -> ip
| Some ip -> ip in
Ip.register time ip
| Lwt_unix.ADDR_UNIX _path -> ()
end
| _ -> ()

let headers_from_cohttp req =
let headers = ref StringMap.empty in
Expand Down

0 comments on commit 938e0a4

Please sign in to comment.