On Tue, Jan 14, 2014 at 9:37 PM, Stefan Adams <[email protected]> wrote:
> > > > On Tue, Jan 14, 2014 at 9:02 PM, sri <[email protected]> wrote: > >> Is it possible for one Mojolicious process to listen on port 80 for both >>> the IPv6 address as well as the IPv4 address? >>> >> >> Should we have IPv6 experts on this list, this might be worth >> investigating (and possibly patch), but i suppose portability and backwards >> compatibility (especially regarding security) could be problematic. >> > > Perhaps the issue is related to this. When listening to two different > interfaces, only the first works. When using * both work. But * does not > pick up on IPv6 addresses. > > $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://127.0.0.1:8080 > <http://127.0.0.1:8080>,http://192.168.0.108:8080 > <http://192.168.0.108:8080>* perl -Mojo -E > 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); > $_->render(text=>$_->tx->remote_address."\n")})->start' daemon > [Tue Jan 14 21:30:46 2014] [info] Listening at "http://127.0.0.1:8080". > Server available at http://127.0.0.1:8080. > [Tue Jan 14 21:30:46 2014] [info] Listening at "http://192.168.0.108:8080 > ". > Server available at http://192.168.0.108:8080. > $ netstat -tulpen | grep :8080 tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1000 5615073 14990/perl > $ curl http://127.0.0.1:8080 > 127.0.0.1 > $ curl http://192.168.0.108:8080 > curl: (7) couldn't connect to host > > $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://**192.168.0.108:8080 > <http://192.168.0.108:8080>**,http://**127.0.0.1:8080 > <http://127.0.0.1:8080>* perl -Mojo -E > 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); > $_->render(text=>$_->tx->remote_address."\n")})->start' daemon > [Tue Jan 14 21:34:26 2014] [info] Listening at "http://192.168.0.108:8080 > ". > Server available at http://192.168.0.108:8080. > [Tue Jan 14 21:34:26 2014] [info] Listening at "http://127.0.0.1:8080". > Server available at http://127.0.0.1:8080. > $ netstat -tulpen | grep :8080 tcp 0 0 192.168.0.108:8080 0.0.0.0:* LISTEN 1000 5614881 14979/perl > $ curl http://127.0.0.1:8080 > curl: (7) couldn't connect to host > $ curl http://192.168.0.108:8080 > 192.168.0.108 > > $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://*:8080* perl -Mojo -E > 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); > $_->render(text=>$_->tx->remote_address."\n")})->start' daemon > $ curl http://127.0.0.1:8080 > 127.0.0.1 > $ curl http://192.168.0.108:8080 > 192.168.0.108 > $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://127.0.0.1:8080 <http://127.0.0.1:8080>,http://127.0.0.1:8081 <http://127.0.0.1:8081>* perl -Mojo -E 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); $_->render(text=>$_->tx->remote_address."\n")})->start' daemon$VAR1 = { [Tue Jan 14 22:06:49 2014] [info] Listening at "http://127.0.0.1:*8080*". Server available at http://127.0.0.1:*8080*. [Tue Jan 14 22:06:49 2014] [info] Listening at "http://127.0.0.1:*8081*". Server available at http://127.0.0.1:*8081*. $ netstat -tulpen | grep :808 tcp 0 0 127.0.0.1:*8080* 0.0.0.0:* LISTEN 1000 5623199 15058/perl tcp 0 0 127.0.0.1:*8081* 0.0.0.0:* LISTEN 1000 5623201 15058/perl $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://127.0.0.1:8080 <http://127.0.0.1:8080>,http://192.168.0.108:8081 <http://192.168.0.108:8081>* perl -Mojo -E 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); $_->render(text=>$_->tx->remote_address."\n")})->start' daemon [Tue Jan 14 22:24:12 2014] [info] Listening at "http://127.0.0.1:*8080*". Server available at http://127.0.0.1:*8080*. [Tue Jan 14 22:24:12 2014] [info] Listening at "http://192.168.0.108:*8081* ". Server available at http://192.168.0.108:*8081*. $ netstat -tulpen | grep :808 tcp 0 0 127.0.0.1:*8080* 0.0.0.0:* LISTEN 1000 5629196 15160/perl tcp 0 0 192.168.0.108:*8081* 0.0.0.0:* LISTEN 1000 5629198 15160/perl So the only scenario in which I see issue is when using the same port, regardless of host name. I don't know what this means, but between lines 63 and 64 of Mojo::IOLoop::Server, I did `undef $fd;' Upon doing so, I now get this: $ env MOJO_LOG_LEVEL=debug *MOJO_LISTEN=http://127.0.0.1:8080 <http://127.0.0.1:8080>,http://192.168.0.108:8080 <http://192.168.0.108:8080>* perl -Mojo -E 'a("/"=>sub{$_->app->log->debug("Remote Address: ".$_->tx->remote_address); $_->render(text=>$_->tx->remote_address."\n")})->start' daemon [Tue Jan 14 22:34:24 2014] [info] Listening at "http://127.0.0.1:*8080*". Server available at http://127.0.0.1:*8080*. [Tue Jan 14 22:34:24 2014] [info] Listening at "http://192.168.0.108:*8080* ". Server available at http://192.168.0.108:*8080*. $ netstat -tulpen | grep :808 tcp 0 0 192.168.0.108:*8080* 0.0.0.0:* LISTEN 1000 5632339 15201/perl tcp 0 0 127.0.0.1:*8080* 0.0.0.0:* LISTEN 1000 5632337 15201/perl And Mojolicious now behaves as expected in which it's listening on two different hosts on the same port. [Tue Jan 14 22:35:50 2014] [debug] Your secret passphrase needs to be changed!!! [Tue Jan 14 22:35:50 2014] [debug] GET "/". [Tue Jan 14 22:35:50 2014] [debug] Routing to a callback. *[Tue Jan 14 22:35:50 2014] [debug] Remote Address: 192.168.0.108* [Tue Jan 14 22:35:50 2014] [debug] 200 OK (0.000680s, 1470.588/s). [Tue Jan 14 22:36:12 2014] [debug] GET "/". [Tue Jan 14 22:36:12 2014] [debug] Routing to a callback. *[Tue Jan 14 22:36:12 2014] [debug] Remote Address: 2001:470:7c:1e5::108* [Tue Jan 14 22:36:12 2014] [debug] 200 OK (0.000302s, 3311.258/s). Obviously, setting $fd to undef where I did is NOT the right thing to do. I'm not sure what is. I hope this helps!! -- *----------------------------------------------------------------* *Keystone IT made the following notation* *----------------------------------------------------------------* *Email Confidentiality Notice: The information contained in this transmission is confidential, proprietary or privileged and may be subject to protection under the law, including the Health Insurance Portability and Accountability Act (HIPAA). * *This message is for the sole use of the intended individual or entity to whom it is addressed. If you are not the intended recipient, you are notified that any use, distribution or copying of the message is strictly prohibited and may subject you to criminal or civil penalties. If you received this transmission in error, please contact the sender immediately at (314) 621-9500 and delete the material from all computers.* -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/groups/opt_out.
