Add an http_port config setting

This should help with #1061.

Also added a warning about the default port being blocked by browsers.
This commit is contained in:
François Revol 2022-09-04 22:29:59 +02:00
parent eaa7abc542
commit 475b859e3f
2 changed files with 22 additions and 2 deletions

View File

@ -401,6 +401,17 @@
<listitem>Port to use for hddtemp connections. Defaults to 7634.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>http_port</option>
</command>
</term>
<listitem>Port to listen to for HTTP connections. Default value is
10080, but is blocked by Firefox and Chrome, so you really want to
change it.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>

View File

@ -61,6 +61,8 @@ std::string webpage;
struct MHD_Daemon *httpd;
static conky::simple_config_setting<bool> http_refresh("http_refresh", false,
true);
static conky::simple_config_setting<unsigned short> http_port("http_port",
HTTPPORT, true);
MHD_Result sendanswer(void *cls, struct MHD_Connection *connection,
const char *url, const char *method, const char *version,
@ -85,8 +87,15 @@ class out_to_http_setting : public conky::simple_config_setting<bool> {
Base::lua_setter(l, init);
if (init && do_convert(l, -1).first) {
httpd = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, HTTPPORT, nullptr,
NULL, &sendanswer, nullptr, MHD_OPTION_END);
/* warn about old default port */
if (http_port.get(*state) == 10080) {
NORM_ERR(
"warning: port 10080 is blocked by browsers "
"like Firefox and Chromium, you may want to change http_port.");
}
httpd =
MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, http_port.get(*state),
nullptr, NULL, &sendanswer, nullptr, MHD_OPTION_END);
}
++s;