From 7605b38f304f043b1a0947278eca12daad32a608 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Tue, 21 Jul 2015 01:00:41 +0200 Subject: Multi::API: Support IPv6 This was more trivial than I had expected. I already took ipv6 into account when rewriting the API for AnyEvent (including the use of norm_ip()), so that part was fine. The only part I had to fix was the listening socket, and I had to ensure that the $c->{ip} was correct. The first was easy, and the latter was properly handled by AnyEvent automatically. Looks like AnyEvent automatically 'unpacks' IPv4-mapped IPv6 addresses, so I didn't have to deal with that myself. --- lib/Multi/API.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm index 2385e11d..cce366d1 100644 --- a/lib/Multi/API.pm +++ b/lib/Multi/API.pm @@ -55,7 +55,11 @@ sub run { shift; %O = (%O, @_); - push_watcher tcp_server undef, $O{port}, \&newconn; + push_watcher tcp_server '::', $O{port}, \&newconn; + # The following tcp_server will fail if the above already bound to IPv4. + eval { + push_watcher tcp_server 0, $O{port}, \&newconn; + }; writelog 'API starting up on port %d', $O{port}; } -- cgit v1.2.3