Influencer/UNplugged — pull request #10 by overbyrn (2012-11-29 20:29:04+00:00)
Title: rework https enablement, port & pid checking logic

Revised how rc.sabnzbd and sabnzbd.php determines when https is enabled and what port to use in that situation.

This pull request tries to resolve the following issue;

rc.sabnzbd assumes if https is enabled, then there will be a value in https_port. This is not always the case as it is possible for sabnzbd to have this field blank where it will use HTTPS over the value in regular port ini entry. The current logic is not sufficient to account for all eventualties.

sabnzbd.php has been amended to include additional logic for how to determine if sabnzbd is running based on whether https is enabled and what port is in use.

An additional form field has been contextually added to show when HTTPS is enabled and https_port contains a value.

There are still some gaps in the logic:

1) php form field "HTTPS Port" will only be displayed in the webgui when https is enabled and https_port contains a value different than that in port. For form field exists solely to be informative to the user. There exists a scenario where https is enabled but https_port field is empty, thus using HTTPS over value stored in regular port. Using current logic, "HTTPS Port" form field will not display under these circumstances, meaning that webgui will show "HTTP Port" and whilst the value in this field is accurate, SAB is actually using HTTPS over this port. This could lead to user confusion. Perhaps it is best to hide the HTTPS port value at all times. Or add an extra contextual change so that "HTTP Port" form field becomes "HTTPS Port" when https is enabled but https_port has no value.

2) Changing HTTPS config from inside SABnzbd webgui can lead to issues in the plugin. The user always has the option to make changes within SABnzbd and hit the built-in restart button. This can cause the rc.script and php file to get out of sync such as the script may try to stop an existing instance of SAB but against the wrong port and/or php file wrongly detects SAB as running/not running.

However, I think the included changes go some way to ensuring both HTTP and HTTPS ports are managed correctly.