kiwix/kiwix-tools

[REGRESSION] kiwix-serve URL helper does not display iPv4 URL anymore

Closed this issue · 10 comments

With cutting-edge dev kiwix-serve the URL help to join the server via HTTP is not anymore really what it should.

I get:

$ kiwix-serve --port=8081 /home/kelson/Downloads/*zim
The Kiwix server is running and can be accessed in the local network at: http://[::1]:8081

My system has both IPv4 AND IPv6, so both should be displayed in the helper. It should look like (if -i=all or default):

$ kiwix-serve --port=8081 /home/kelson/Downloads/*zim
The Kiwix server is running and can be accessed in the local network at: http://127.0.0.1:8081 or http://[::1]:8081

@sgourdas Can you please fix quickly this small regression?

My system has both IPv4 AND IPv6, so both should be displayed in the helper. It should look like (if -i=all or default):

@kelson42 default (no -i parameter given), with the current implementation, just straight up uses only ipv4. There is no check of how the system is configured to determine what to use. Do we want to change that and check what the system supports and go based on that?

Edit: Let me get back to this.

just straight up uses only ipv4

I don't want to change the default behaviour, but it's not normal that I get a helper with an IPv6 URL if IPv4 is used!

Yeah I am investigating further. Disregard what I said above for now. Will get back ASAP.

@kelson42 just to confirm, because this needs refactoring on libkiwix's side as well, what we want to be displayed is all the available urls that the server is running on. Just like the example you gave, if attached to both ipv4 and ipv6 with --address=all the output should give:

The Kiwix server is running and can be accessed in the local network at: http://127.0.0.1:8081 or http://[::1]:8081

Or, other example, if --address=all is used but ipv6 is not configured only the ipv4 host should be displayed. And so on.

@sgourdas I just ask that the helper line printed by kiwix-serve is phrased according to the --address option.

What is clear to me is that if the user requests something which can not be delivered (like listening on an inexisting IPv6 address) then an error should probably be triggered.

I would be surprised that any of this should require a refactoring.

@sgourdas I just ask that the helper line printed by kiwix-serve is phrased according to the --address option.

What is clear to me is that if the user requests something which can not be delivered (like listening on an inexisting IPv6 address) then an error should probably be triggered.

I would be surprised that any of this should require a refactoring.

Do we want to blindly print hosts just based on the 'address' variable? If yes, that is easy. If we want to be sure what we print works and is correct we need to refactor 'getBestPublicIp()' from libkiwix.

@sgourdas I would recommend to open a dedicated issue with all the details if this needs serious rewriting.

@kelson42 I will send a PR within today attached to this issue and we can evaluate then maybe.

@kelson42 I made these PRs which are up for discussion.