[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4] Servers can listen on multiple addresses simultaneously (was:
From: |
Kim Minh Kaplan |
Subject: |
[PATCH 4] Servers can listen on multiple addresses simultaneously (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix) |
Date: |
Wed, 25 Mar 2009 14:09:04 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Servers can listen on multiple addresses simultaneously.
The settings -recon_address and -hkp_address are extended to accept
multiple IP addresses separated by spaces.
Kim Minh.
diff -r 0b3ca8c14f6f -r b1c6270313e0 common.ml
--- a/common.ml Wed Mar 25 13:37:28 2009 +0000
+++ b/common.ml Wed Mar 25 13:43:26 2009 +0000
@@ -197,6 +197,12 @@
(************************************************************)
(** Network Related definitions *)
+let whitespace = Str.regexp "[ \t\n]+"
+let make_addr_list address_string port =
+ let addrlist = Str.split whitespace address_string in
+ let f s = Unix.ADDR_INET (Unix.inet_addr_of_string s, port) in
+ List.map ~f addrlist
+
let recon_port = !Settings.recon_port
let recon_address = !Settings.recon_address
let http_port = !Settings.hkp_port
@@ -213,6 +219,11 @@
let get_client_recon_addr () =
- Unix.ADDR_INET (Unix.inet_addr_of_string recon_address,0)
+ make_addr_list recon_address 0
let get_client_recon_addr =
Utils.unit_memoize get_client_recon_addr
+
+let match_client_recon_addr addr =
+ let family = Unix.domain_of_sockaddr addr in
+ List.find ~f:(fun caddr -> family = Unix.domain_of_sockaddr caddr)
+ (get_client_recon_addr ())
diff -r 0b3ca8c14f6f -r b1c6270313e0 dbserver.ml
--- a/dbserver.ml Wed Mar 25 13:37:28 2009 +0000
+++ b/dbserver.ml Wed Mar 25 13:43:26 2009 +0000
@@ -56,9 +56,11 @@
if not withtxn then
failwith "Running sks_db without transactions is no longer supported."
+ let websocks =
+ List.map ~f:Eventloop.create_sock
+ ((if !Settings.use_port_80 then make_addr_list http_address 80 else [])
+ @ make_addr_list http_address http_port)
- let addr = inet_addr_of_string http_address
- let websock = Eventloop.create_sock (ADDR_INET (addr,http_port))
let () =
if Sys.file_exists db_command_name
then Unix.unlink db_command_name
@@ -652,23 +654,16 @@
)
(
- (websock, Eventloop.make_th ~name:"webserver"
- ~timeout:!Settings.wserver_timeout
- ~cb:(Wserver.accept_connection webhandler ~recover_timeout:1))
- ::
(comsock, Eventloop.make_th ~name:"command handler"
~timeout:!Settings.command_timeout
~cb:(eventify_handler command_handler))
::
- (if !Settings.use_port_80 then
- let sock = Eventloop.create_sock (ADDR_INET (addr,80)) in
- (sock,Eventloop.make_th ~name:"webserver80"
- ~timeout:!Settings.wserver_timeout
- ~cb:(Wserver.accept_connection webhandler ~recover_timeout:1)
- )::[]
- else
- []
- )
+ (List.map
+ ~f:(fun sock ->
+ (sock, Eventloop.make_th ~name:"webserver"
+ ~timeout:!Settings.wserver_timeout
+ ~cb:(Wserver.accept_connection webhandler ~recover_timeout:1)))
+ websocks)
)
diff -r 0b3ca8c14f6f -r b1c6270313e0 reconCS.ml
--- a/reconCS.ml Wed Mar 25 13:37:28 2009 +0000
+++ b/reconCS.ml Wed Mar 25 13:43:26 2009 +0000
@@ -137,7 +137,7 @@
~protocol:0
in
let run () =
- Unix.bind s ~addr:(get_client_recon_addr ());
+ Unix.bind s ~addr:(match_client_recon_addr partner);
Unix.connect s ~addr:partner;
let cin = Channel.sys_in_from_fd s
and cout = Channel.sys_out_from_fd s in
diff -r 0b3ca8c14f6f -r b1c6270313e0 reconComm.ml
--- a/reconComm.ml Wed Mar 25 13:37:28 2009 +0000
+++ b/reconComm.ml Wed Mar 25 13:43:26 2009 +0000
@@ -73,7 +73,7 @@
~kind:Unix.SOCK_STREAM
~protocol:0 in
protect ~f:(fun () ->
- Unix.bind s ~addr:(get_client_recon_addr ());
+ Unix.bind s ~addr:(match_client_recon_addr addr);
Unix.connect s ~addr;
let cin = Channel.sys_in_from_fd s
and cout = Channel.sys_out_from_fd s in
diff -r 0b3ca8c14f6f -r b1c6270313e0 reconserver.ml
--- a/reconserver.ml Wed Mar 25 13:37:28 2009 +0000
+++ b/reconserver.ml Wed Mar 25 13:43:26 2009 +0000
@@ -49,8 +49,8 @@
(******************************************************************)
- let recon_addr = Unix.ADDR_INET (Unix.inet_addr_of_string
recon_address,recon_port)
- let reconsock = Eventloop.create_sock recon_addr
+ let reconsocks =
+ List.map Eventloop.create_sock (make_addr_list recon_address recon_port)
let () =
if Sys.file_exists recon_command_name
@@ -354,17 +354,18 @@
)
)
- [ (comsock, Eventloop.make_th
+ ( (comsock, Eventloop.make_th
~name:"command handler"
~cb:(eventify_handler command_handler)
~timeout:!Settings.command_timeout
- );
- (reconsock, Eventloop.make_th
- ~name:"reconciliation handler"
- ~cb:recon_handler
- ~timeout:!Settings.reconciliation_config_timeout
- );
- ]
+ )
+ ::
+ (List.map ~f:(fun sock ->
+ (sock, Eventloop.make_th
+ ~name:"reconciliation handler"
+ ~cb:recon_handler
+ ~timeout:!Settings.reconciliation_config_timeout))
+ reconsocks))
(******************************************************************)
diff -r 0b3ca8c14f6f -r b1c6270313e0 sks.pod
--- a/sks.pod Wed Mar 25 13:37:28 2009 +0000
+++ b/sks.pod Wed Mar 25 13:43:26 2009 +0000
@@ -152,7 +152,7 @@
=item -recon_address
-Set recon binding address.
+Set recon binding address. Can be a list of whitespace separated IP addresses.
=item -hkp_port
@@ -160,7 +160,7 @@
=item -hkp_address
-Set hkp binding address.
+Set hkp binding address. Can be a list of whitespace separated IP addresses.
=item -use_port_80
- [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix, Kim Minh Kaplan, 2009/03/25
- Re: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix, Yaron Minsky, 2009/03/25
- [PATCH 1] Fix non tail recursion in sksdump (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/25
- [PATCH 2] Recon server check that the HTTP request succeeded before using the response (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/25
- [PATCH 3] Use Unix.domain_of_sockaddr instead of hardcoded PF_INET or PF_UNIX (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/25
- [PATCH 4] Servers can listen on multiple addresses simultaneously (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/25
- [PATCH 5] Use all available addresses of partners (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/25
- [PATCH 4] Servers can listen on multiple addresses simultaneously (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix),
Kim Minh Kaplan <=
- [PATCH 6] Fix DNS staleness (was: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix), Kim Minh Kaplan, 2009/03/28
- Re: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix, Phil Pennock, 2009/03/25
- Re: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix, Phil Pennock, 2009/03/25
- Re: [Sks-devel] [PATCH] Bundle IPv6, DNS fixes, sks dump fix, Kim Minh Kaplan, 2009/03/29
- [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Phil Pennock, 2009/03/29
- Re: [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Kim Minh Kaplan, 2009/03/30
- Re: [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Phil Pennock, 2009/03/30
- Re: [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Yaron Minsky, 2009/03/30
- Re: [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Phil Pennock, 2009/03/31
- Re: [Sks-devel] [CONTRIB] sks.pod text for enabling IPv6, Yaron Minsky, 2009/03/31