Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin submit] freedns.afraid.org v2 api #70

Open
atesin opened this issue Aug 1, 2022 · 4 comments
Open

[plugin submit] freedns.afraid.org v2 api #70

atesin opened this issue Aug 1, 2022 · 4 comments

Comments

@atesin
Copy link
Contributor

atesin commented Aug 1, 2022

hi.... as promised in #67 , i (tried to) wrote a new plugin for freedns afraid.org api v2 (random token)

random token is more secure (your accound data is not exposed) and shorter, and a single token can be associated with many domains... see https://freedns.afraid.org/dynamic/v2/ for details (needs login)

keep in mind is very basic because i don't have the tools (i wrote it just with plain vim) and i'm not so skilled in python, neither in git... i never sent a patch request so here it goes the plugin

freedns_v2.py

"""
"""
ddupdate plugin updating data on freedns.afraid.org api v2 random token.

See: ddupdate(8)
See: https://freedns.afraid.org
See: https://freedns.afraid.org/dynamic/v2/ (needs login)
"""

from ddupdate.ddplugin import ServicePlugin, ServiceError
from ddupdate.ddplugin import get_response


class FreednsV2Plugin(ServicePlugin):
    """
    Updates DNS data for host on freedns.afraid.org api v2.

    Freedns allows settings the IP address using an address plugin or
    just using the address as seen from the internet using the ip-disabled
    plugin. Ipv6 is supported. V2 api uses a random token which is simpler
    and more secure, your credentials are never exposed.

    Login to afraid.org and add some domain to v2 api. Take the token
    (last part of update url) and use it as 'hostname' in ddupdate.conf.
    """

    _name = 'sync.afraid.org'
    _oneliner = 'Updates on https://sync.afraid.org/'
    _url = 'https://{0}sync.afraid.org/u/{1}/'

    def register(self, log, hostname, ip, options):
        """
        Based on  https://freedns.afraid.org/dynamic/v2/, needs _url below
        to update.

        The {0} parameter is a randomized update token, generated specificly
        for each domain when enabled for api v2. The server detects source IP
        automatically, but optionally you can provide it
        """
        url = ''
        if ip and ip.v6:
            url = self._url.format('v6.', hostname) + '?address=' + str(ip.v6)
        else:
            url = self._url.format(''   , hostname)
            if ip and ip.v4:
                url += '?address=' + str(ip.v4)
        log.debug("Contacting freedns for update v2 on %s", url)
        get_response(log, url)

what it lacks:

  • netrc support (i never heard of it, probably i don't need it)
  • better documentation maybe
  • add alternate port 8080 (less maintained, use it just on proxy or redirects problems)
  • do something with wrong updates (send mail?, run script?, retry later?, use other method?...)
  • anything i haven't thought yet... anybody feel free to improve it

maybe token fits best as password than hostname... but how can i do if i don't want to use a .netrc file?... i don't know/understand how to write it properly, but the code is open to enhancements

@atesin atesin changed the title [new plugin submit] [new plugin submit] freedns.afraid.org v2 api (random token) Aug 1, 2022
@atesin atesin changed the title [new plugin submit] freedns.afraid.org v2 api (random token) [new plugin submit] freedns.afraid.org v2 api Aug 1, 2022
@atesin atesin changed the title [new plugin submit] freedns.afraid.org v2 api [plugin submit] freedns.afraid.org v2 api Aug 1, 2022
@leamas
Copy link
Owner

leamas commented Aug 1, 2022

OK. "Just using vim" is nothing spectacular, this is what I use ;)

Anyway, without the netrc support it cannot be accepted since it will not work with ddupdate-config. This is a basic requirement for any plugin.

@atesin
Copy link
Contributor Author

atesin commented Aug 2, 2022

vim is a powerful text editor... but for developing apps it lacks many tools, like function names autocompletion, documentation tooltips, search in files debugging, refactoring, rename vars in all files, etc.... if you develop python or any language just with a text editor without the need of external tools, that means you know all the quirks of the language and you are a pro developer

i think this project urges a detailed (and well advertised) formal document on how to write plugins... requirements, submission, etc .... that might boost the growth and popularity of this plugin, and relieve your work

@atesin
Copy link
Contributor Author

atesin commented Aug 13, 2022

mh... i sent a pull request a week ago, but i cand find it :/

i manually edit a new file inside /plugins/ directory in devel branch and then the system offered me to sublit a pull request with the new file

@atesin
Copy link
Contributor Author

atesin commented Oct 19, 2022

nevermind... i sent a PR as it should be... by forking repo, modifying and sending a PR (i am still learning github)... please review when you can

#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants