62 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
79e48310a1
dynamicdns: Use privileged decorator for actions
Tests:

- Functional tests work.
- Initial setup works.
- Setting the setup version to 1 and running the service upgrades to version 2.
  During this, export_config() and clean() work successfully.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:51:51 -04:00
Sunil Mohan Adapa
d77f812d11
dynamicdns: Fix adding null domain into configuration
When old configuration is not set and is exported with new code into newer
format, the result is a domain added with domain name 'null'. This causes issues
with UI not showing configuration and with null domain being added into
configurations of various daemons.

Tests:

- To reproduce the issue, switch to a revision with old dynamicdns code. Then
switch to a latest version without the fix. A 'null' domain is added to
configuration.

- To reproduce the issue, switch to a revision with old dynamicdns code. Then
switch to a latest version with the fix. A 'null' domain is not added to
configuration.

- With null domain in the configuration. Start FreedomBox with the fix. The null
domain should be removed and null domain should not be announced to other
daemons.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:13 -05:00
Sunil Mohan Adapa
7e0156adbe
dynamicdns: Rewrite configuration handling and update using URL
- Drop all the bash code.

- Run the update URL code with same logic as before. Don't need to use action
code for it.

- Completely new way to handle configuration: using key/value store. Import old
configuration once and delete it.

- Use a glib scheduler instead of creating a cron job.

- Store and show status from key/value store.

- Handle multiple domains when getting/setting configuration and status. The UI
still shows a single configuration form. To be improved later.

- Catch and report all errors during the update process.

- Drop all NAT detection code.

- Drop selfhost.bz. German only, no free account, no proper TLS on domain, no
easy to test. Existing accounts will continue to work with "other" as the
service type.

- For gnudip update code, add a timeout of 10 seconds, set a buffer size of two
powers and fix handling error messages from server.

Tests:

- GnuDIP:

  - Upon submission of the form, the IP is updated if app is enabled. IP is not
  updated if app is disabled.

  - Every 5 minutes, check is made again and IP is updated.

  - If IP lookup URL is available, update calls are not made if the DNS is
  already up-to-date.

  - If IP lookup URL is not available, update calls are made unconditionally
  every 5 minutes.

- For each of noip.com, freedns.afraid.org and other service:

  - Upon submission of the form, the IP is updated if app is enabled. IP is not
  updated if app is disabled.

  - Every 5 minutes, check is made again and IP is updated.

  - If IP lookup URL is available, update calls are not made if the DNS is
  already up-to-date.

  - If IP lookup URL is not available, update calls are made unconditionally
  every 5 minutes.

- Form validation:

  - Domain field is always mandatory.

  - When type is selected as gnudip, the fields server, username, and password
  are mandatory.

  - When type is selected other than gnudip, the field update URL is mandatory.
  The rest are optional.

  - When the update URL contains a field contains <User>, username is mandatory.
  For <Pass>, password is mandatory. For <Ip>, ip_lookup_url is mandatory.

  - When use HTTP basic auth is checked, the fields username and password are
  mandatory.

  - Password is optional only if a previous password exists. If configuration is
  deleted from kvstore, password is mandatory.

- Configuration import:

  Install dynamicdns without the patch. Add configuration with each of the
  service types. For GnuDIP service type, set two configurations with one with
  and without IP lookup URL. Update to code with the patch. Setup should run.

  - All fields in the configuration should be imported properly.

  - If the previous configuration is disabled, app should be disabled after
  import. Enabled otherwise.

  - Updating the IP address should work immediately after import.

- Enable/Disable: when enabled, IP URL should be enabled every 5 minutes.
When disabled, updates should not happen.

- Status:

  - When status is removed from the DB, it should show that no status is
  available yet.

  - When the form is updated or update happens via the timer, the status is
  shown. It should show success for a proper update. Proper external IP address
  should be shown.

  - Set the server to localhost and submit. Status should show 'Server refused
  connection' message. IP address should be '-'.

  - Set the server to an unknown domain. Status should show 'Could not find
  server' message. IP address should be '-'.

  - Set the server to a known domain. Status should show 'Connection timed out'
  message. IP address should be '-'.

  - Last update time should keep increasing as time passes.

- Backup/restore:

  - Functional tests.

- Javascript:

  - When GnuDIP is selected as the type, the fields server, username, password,
  domain, show password, and IP lookup URL should be shown while other fields
  should be hidden. Same on page load with GnuDIP as pre-selected type.

  - When GnuDIP is not selected as the type, the fields update URL, accept all
  SSL certificates, use basic HTTP auth, domain name, username, password, show
  password, IP lookup URL and use IPv6 fields should be shown and rest of the
  fields should be hidden. Same on page load with non-GnuDIP as pre-selected
  type.

  - When show password is checked, password should be shown and when it is
  unchecked, password is masked.

  - When other service types are selected, the update URL values changes to the
  respective service's URL.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-02-10 20:31:39 -05:00
Sunil Mohan Adapa
f107e83534
dynamicdns: Drop NAT detection as it is no longer used
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-02-10 20:31:30 -05:00
James Valleroy
84a7323b42
dynamicdns: Replace ez-ipupdate
Add Python implementation of GnuDIP client.

Tests:

- In testing container, configure Dynamic DNS with a (previously
  offlined) freedombox.rocks account. FreedomBox interface shows that
  the address has been updated. GnuDIP server also shows the correct
  IP address.

- Running "gnudip update" and "dynamicdns update" actions produce the
  expected results.
2022-02-09 12:05:21 -08:00
Matthias Dellweg
4b4f8187ef
Enable dynamicdns module to handle IPv6
Signed-off-by: Matthias Dellweg <2500@gmx.de>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-15 19:17:50 -05:00
Sunil Mohan Adapa
eada506b23
actions/*: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:39:36 +02:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Daniel Steglich
8608bf6f07
dynamicdns: Fix permissions for all /etc files
The file which contains the credentials should not be readable for
"others".
2016-09-18 16:51:31 +05:30
Daniel Steglich
367b29c50f
dynamicdns: Fix file creation with update URL
The wget command to push the current IP via update URL will download the
update URL document without deleting the HTML document afterwards. This
will cause the script to flood "/root/" folder.
2016-09-07 22:14:57 +05:30
Sunil Mohan Adapa
942b23c3c3
dynamicdns: Change 'lookup' to 'look up'
The original patch Nikhil Rayaprolu had this correct.  I have
incorrectly changed it.  Fixing it.
2016-07-28 22:58:00 +05:30
Nikhil Rayaprolu
777dbbe2a7
dynamicdns: Improve label for IP Check URL 2016-07-28 22:51:29 +05:30
Daniel Steglich
ddc049734d
dynamicdns: Status message improvement
Closes #496.  If no update is done because no update needs to be done,
the success status needs to be written.  Because maybe the DNS record is
up to date when the action script is executed for the first time.  In
this case no success message was written and it looks like DynDNS is not
executed.
2016-06-15 22:47:23 +05:30
Sunil Mohan Adapa
83ec57414c
dynamicdns: Fix starting daemon for no NAT
Incase the machine is not behind NAT, fix the logic that decides to
start the daemon.
2016-02-01 11:03:54 +05:30
Sunil Mohan Adapa
51dd1bb000
dynamicdns: Fix an invalid syntax
'local' keyword can't be used outside a method.
2016-02-01 11:02:43 +05:30
Sunil Mohan Adapa
ea1e9b6e2a
dynamicdns: Fix writing configuration for no NAT
- When writing the configuration file for no NAT case, append then last
  part of the file instead of overwriting.

- Also 'echo' statements are missing leading to attempt to execute the
  config options instead of writing them to a file.
2016-02-01 11:00:46 +05:30
Sunil Mohan Adapa
aa5efd4984
dynamicdns: Fix computing update times
Currenly uptime is being taken as measure to decide whether update must
run.  Uptime is the number of seconds since machine has booted.  If a
machine has run for 30 hours, and rebooted, then update will not be done
until the machine has run for 30 hours + desinated time.  Using seconds
since epoch fixes this.
2016-02-01 10:57:33 +05:30
Sunil Mohan Adapa
2a030f91fe
dynamicdns: Fix reading configuration file
- The current code to parse the configuration file does not work proper
  if there is an '=' in the password.  Fix it.

- Also if predesignated keyword like 'server' occurs in the password,
  configuration can't be read properly.  Fix it.
2016-02-01 10:53:26 +05:30
Daniel Steglich
a90039889d
dynamicdns: Fix passing password via stdin
* Add an option to pass the password via cmdline (optional, not used by
  plinth) if called manually.

* Fix: If -p option was not the last given option, everything after -p
  was lost.  Closes #310.
2016-02-01 10:46:48 +05:30
Daniel Steglich
994e674885 Github issue 320: fixed display error
* switched "ignore SSL cert errors" and "use basic auth"
2015-12-06 22:25:53 +05:30
Sean Alexandre
21b9a5b02a Passwords now sent over stdin instead of command line.
Fixes Issue #166:
Don't pass passwords on command line
https://github.com/freedombox/Plinth/issues/166

This issue was for 4 modules: Transmission, Pagekite, DynamicDNS, and Ikiwiki.
2015-08-23 15:20:08 +05:30
Daniel Steglich
4977258f78 use global wget options in addition to specific wget options 2015-03-26 18:45:17 +01:00
Daniel Steglich
2c36160237 removed debug output 2015-03-26 13:33:50 +01:00
Daniel Steglich
66e9b00567 built in string substitution of bash shell does not work with dash. avoid this incompatibility. 2015-03-25 21:47:50 +01:00
Daniel Steglich
c4fa908dd7 local vars are only possible inside of functions 2015-03-25 21:13:08 +01:00
Daniel Steglich
b4b3bb83f4 updated help message 2015-03-25 21:11:03 +01:00
Daniel Steglich
b4eba95759 fixed missing bracket in awk command 2015-03-25 21:04:01 +01:00
Daniel Steglich
22033aaea5 fixed some syntax errors after last changes 2015-03-25 19:43:22 +01:00
Daniel Steglich
3d8228ce38 made the bash script code shellcheck compatible, replaced obsolete statements 2015-03-25 19:28:43 +01:00
Daniel Steglich
09c541ea5c fixed missing whitespace 2015-03-25 17:30:05 +01:00
Daniel Steglich
c59fcf0d29 fixed status return string of updateurl 2015-03-09 23:30:45 +01:00
Daniel Steglich
41352912a3 copyright notice added 2015-03-09 22:58:51 +01:00
Daniel Steglich
98506f0fdd improved check of current IP, registered at DNS server 2015-03-06 21:46:57 +01:00
Daniel Steglich
7d30480117 improved ipurl check 2015-03-06 21:41:57 +01:00
Daniel Steglich
6acc4cc44f only do a update if DNS entry is outdated 2015-03-06 21:34:57 +01:00
Daniel Steglich
e42b8e5015 covered empty server arguments and made parameter comparsion more easy 2015-03-05 14:03:11 +01:00
Daniel Steglich
eab3ac2cfc added comments 2015-03-04 22:22:30 +01:00
Daniel Steglich
1075665a90 fixed indention 2015-03-04 10:28:28 +00:00
Daniel Steglich
ad1d94f6a6 changed success/failure storage after update is done via update URL 2015-03-04 10:17:48 +00:00
Daniel Steglich
68bd749164 sorround update URL with double qoutes 2015-03-04 10:01:48 +00:00
Daniel Steglich
5c5134f233 store successful update events to be displayed on status page 2015-03-04 09:18:53 +00:00
Daniel Steglich
8bcea1fdae do not show single quotes arround the update URL 2015-03-03 22:46:32 +01:00
Daniel Steglich
145028d518 added function to replace vars from update URL 2015-03-03 22:35:28 +01:00
Daniel Steglich
81ad2019b1 use global defined string variables 2015-03-03 21:18:31 +01:00
Daniel Steglich
875c24e213 added comment lines 2015-03-03 21:14:55 +01:00
Daniel Steglich
b782f36b28 consistent use of dollar bracket to assign variables from system call 2015-03-03 21:10:04 +01:00
Daniel Steglich
f611614c14 consistent use of curly brackets 2015-03-03 21:07:07 +01:00
Daniel Steglich
a2e8a0ec8a prepared update URL functionality (implemented new parameters) 2015-03-02 23:39:28 +01:00
Daniel Steglich
ffcfccb20f beautyfied and refactored code 2015-03-02 20:56:46 +01:00
Daniel Steglich
5b71ce815c cat on a empty string will block the script 2015-02-24 08:05:54 +00:00