Skip to content

Commit

Permalink
Add an http_port config setting
Browse files Browse the repository at this point in the history
This should help with brndnmtthws#1061.

Also added a warning about the default port being blocked by browsers.
  • Loading branch information
mmuman committed Sep 4, 2022
1 parent 1c7113b commit 374c929
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 11 additions & 0 deletions doc/config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
13 changes: 11 additions & 2 deletions src/display-http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 374c929

Please sign in to comment.