Skip to content

Commit 7787074

Browse files
committed
Adapt to Ocsigen_request API change
Adapt to changes in ocsigenserver: ocsigen/ocsigenserver#273
1 parent 088cb9c commit 7787074

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

src/lib/eliom_common.server.ml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ let network_of_ip k mask4 mask6 =
298298
| Ipaddr.V4 ip -> Ipaddr.(V4 V4.Prefix.(network (make mask4 ip)))
299299
| Ipaddr.V6 ip -> Ipaddr.(V6 V6.Prefix.(network (make mask6 ip)))
300300

301+
let network_of_request r ~mask4 ~mask6 =
302+
match Ocsigen_request.client_conn r with
303+
| `Inet (ip, _) -> network_of_ip ip mask4 mask6
304+
| _ -> Ipaddr.(V6 V6.localhost)
305+
301306
module Net_addr_Hashtbl : sig
302307
type key = Ipaddr.t
303308
type 'a t
@@ -792,6 +797,8 @@ let add_dlist_ dlist v =
792797
| Some a -> a
793798
| None -> assert false
794799

800+
let default_ip_table_key = Ipaddr.(V6 V6.localhost)
801+
795802
let empty_tables max forsession =
796803
let t1 = [] in
797804
let t2 = ref (empty_naservice_table ()) in
@@ -812,15 +819,22 @@ let empty_tables max forsession =
812819
let ip, max, sitedata =
813820
match sp with
814821
| None -> (
815-
( Ipaddr.(V6 V6.localhost)
822+
( default_ip_table_key
816823
, max
817824
, match global_register_allowed () with
818825
| None ->
819826
failwith "global tables created outside initialisation"
820827
| Some get -> get () ))
821828
| Some sp ->
822-
( Ocsigen_request.remote_ip_parsed
823-
sp.sp_request.Ocsigen_extensions.request_info
829+
let ip =
830+
match
831+
Ocsigen_request.client_conn
832+
sp.sp_request.Ocsigen_extensions.request_info
833+
with
834+
| `Inet (ip, _) -> ip
835+
| _ -> default_ip_table_key
836+
in
837+
( ip
824838
, fst sp.sp_sitedata.max_anonymous_services_per_subnet
825839
, sp.sp_sitedata )
826840
in

src/lib/eliom_common.server.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ val remove_naservice_table :
674674

675675
val get_mask4 : sitedata -> int
676676
val get_mask6 : sitedata -> int
677-
val network_of_ip : Ipaddr.t -> int -> int -> Ipaddr.t
677+
val network_of_request : Ocsigen_request.t -> mask4:int -> mask6:int -> Ipaddr.t
678678
val ipv4mask : int ref
679679
val ipv6mask : int ref
680680
val create_dlist_ip_table : int -> dlist_ip_table

src/lib/eliom_request_info.server.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ let get_full_url () =
4949
let sp = Eliom_common.get_sp () in
5050
get_full_url_sp sp
5151

52-
let get_remote_ip () =
52+
let get_client_conn_to_string () =
5353
let sp = Eliom_common.get_sp () in
54-
Ocsigen_request.remote_ip sp.Eliom_common.sp_request.request_info
54+
Ocsigen_request.client_conn_to_string sp.Eliom_common.sp_request.request_info
5555

5656
let get_get_params () =
5757
let sp = Eliom_common.get_sp () in

src/lib/eliom_request_info.server.mli

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ val get_user_agent : unit -> string
3636
val get_full_url : unit -> string
3737
(** returns the full URL as a string *)
3838

39-
val get_remote_ip : unit -> string
40-
(** returns the internet address of the client as a string *)
39+
val get_client_conn_to_string : unit -> string
40+
(** returns the address of the client in textual format. This is an IP address
41+
if the client is connected through the internet. *)
4142

4243
val get_original_full_path_string : unit -> string
4344
(** returns the full path of the URL as first sent by the browser

src/lib/server/eliommod_sessiongroups.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ let make_full_group_name ~cookie_level ri site_dir_string ipv4mask ipv6mask
3030
( site_dir_string
3131
, cookie_level
3232
, Right
33-
(Eliom_common.network_of_ip
34-
(Ocsigen_request.remote_ip_parsed ri)
35-
ipv4mask ipv6mask) )
33+
(Eliom_common.network_of_request ri ~mask4:ipv4mask ~mask6:ipv6mask) )
3634
| Some g -> site_dir_string, cookie_level, Left g
3735

3836
let make_persistent_full_group_name =

0 commit comments

Comments
 (0)