kiwix / kiwix-tools

Command line Kiwix tools: kiwix-serve, kiwix-manage, ...
https://download.kiwix.org/release/kiwix-tools/
GNU General Public License v3.0
428 stars 83 forks source link

Unable to configure kiwix-serve to listen on multiple interfaces to listen on #547

Closed kelson42 closed 2 years ago

kelson42 commented 2 years ago
$ kiwix-serve --port=8282 --address=127.0.0.1 --address=192.168.1.213 *zim

Seems to listen only on 192.168.1.213 although it should listen on 127.0.0.1 as well.

But:

$ kiwix-serve --port=8282 *zim

... works fine, it listens properly on all IPs.

To me this looks like a regresssion, but not sure.

mgautierfr commented 2 years ago

I'm not sure it is possible (at least with libmicrohttpd). If you don't specify a address, we use INADDR_ANY and this means that we listen to any/all interface. This is done by libc/kernel, not us.

I'm not sure it is possible to pass several MHD_OPTION_SOCK_ADDR to libmicrohttpd. It would need that libmicrohttpd listens on several socket and I doubt it does this.

Why do you want to listen on several specific addresses ?

kelson42 commented 2 years ago

@mgautierfr The main problem is to have a command line which does do what it should do. @juuz0 Would you be able please to (1) check if this is possible to give many addresses (2) if not possible to print an error telling that only one IP address is possible.

mgautierfr commented 2 years ago

The main problem is to have a command line which does do what it should do.

This is not a valid requirement. If it is, I can simply answer you that it already does what it should do.

kelson42 commented 2 years ago

@mgautierfr NO. If you request to listen on two IPs, it should listen on two IPs, and not only on the first one (or the last one?) like today. So, either we implement it or generate a clear error if more than one --address is used.

juuz0 commented 2 years ago

Would you be able please to (1) check if this is possible to give many addresses

No "out of the box" way looks possible in libmicrohttpd. We can start multiple instances of kiwix::Server maybe?

(2) if not possible to print an error telling that only one IP address is possible.

Yes but blocked by #563. Help needed :(

mgautierfr commented 2 years ago

If you request to listen on two IPs, it should listen on two IPs, and not only on the first one (or the last one?) like today. So, either we implement it or generate a clear error if more than one --address is used.

So now we have a requirement 😉

So as it is not possible to listen on several IPs, we should check if several --address is used and print a error