Giter VIP home page Giter VIP logo

dreamhost_dns_go's Introduction

Dreamhost DNS

This is a Go program for updating the IP addresses associated with your Dreamhost domain and subdomain names if you do not have a static IP address. (In other words, this makes Dreamhost a Dyanmic DNS provider)

Run this script on whatever computer is functioning as the server. (ie the one behind the ever-changing IP address)

You will need a Dreamhost API key. (See step 2 on this page)

Create a settings.json file that looks like this:

{
  "api_key": "myapikey",
  "domains": ["sub.domain1.com", "sub.domain2.com", "sub2.domain1.com"]
}

Obviously replace "myapikey" with whatever you generated by following the instructions linked above. The domains are all the domains that will be pointed to this one IP Address.

The settings.json file should be put into the xdg directory for your system. The output of the program will tell you where that is. On Linux/Unix, for example, this is $HOME/.config/dreamhostdns/settings.json

From the releases section of the repository you can grab the latest binary to run. Binaries are generated for Windows on x86-64 and Mac and Linux on x86-64 and ARM.

Run dreamhost_dns_go and it will generate minimal output as well as putting logs in the xdg DataFile location. On Linux that's $HOME/.local/share/dreamhostdns/dnsupdates.log. (Very useful if you are running as a cron job or on a systemd timer)

If you wish to have the log output also on the commandline, then run dreamhost_dns_go -v

Why Go?

Originally I wrote this program in Python, but every time I upgraded to a new version of Python, my virtual environment broke. That was really annoying for a script that I always want to automatically run via a cron job and not have to think about whether it was working correctly. Since Go is a compiled language it doesn't require virtual environments in order to run without polluting the system files.

dreamhost_dns_go's People

Contributors

djotaku avatar

Watchers

 avatar  avatar

dreamhost_dns_go's Issues

rething error handling

based on this advice from /r/golang

I believe the biggest way to improve this would be to rethink your error handling. Error handling in Go is very explicit, and is a first class feature of the language. Some areas to research might be:

  • you use both log.Fatal and explicit fmt.Println followed by os.exit. consider sticking with one.

  • consider only using log.Fatal or equivalent in main. As is, any error calling the webGet function will exit the program. This includes 429’s for API rate limiting, or any other transient issue.

  • consider handling those transient issues, such as a back off for 429 errors. This would be where goroutines would come in useful. They do bring some complexity though, as you would need to consider how to handle reporting errors and status. Goroutines can’t “return” data, and usually send errors and results via a channel, either combined or in separate channels. I recommend Concurrency in Go by Katherine Cox-Buday. Awesome book!

  • the normal pattern for go funcs that can possibly error is to return (type, error) where type is the appropriate type. Some funcs, like your contains can’t really error, but most/all others can. The normal way of handling this is to either handle the error as soon as possible, say by waiting and retrying the operation, or bubbling the error up with some more context. The latest version of Go has new error handling capabilities also, although I don’t think they are necessarily needed here.

no longer print out API key

that was (I think) originally something I put in for debugging back in Sept 2022. A bit of a security issue if someone leaves their terminal exposed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.