From 95f4abc34300575394255393357cfe7f31abfd78 Mon Sep 17 00:00:00 2001 From: johnjaylward Date: Fri, 2 Aug 2019 17:02:33 -0400 Subject: [PATCH 1/8] Update Readme with build instructions make the "requirements" section more specific and also adds simple build instructions. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14a9f0d..efc6b07 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,19 @@ A simple script in Go language to automatically update Digital ocean DNS records To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. -## requirements -Requires Git and Go for building. +## Requirements +Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building. Requires that the record already exists in DigitalOcean's DNS so that it can be updated. (manually find your IP and add it to DO's DNS it will later be updated) Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens. +## Building +You first need to install the "homedir" module if you aren't using it in another project. To install the module, run `go get github.com/mitchellh/go-homedir` + +Once the module is fetched, you should be able to compile the program using `go build` + ## Usage ```bash git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git From 0f46c9b8207d8f17d625a3afa0aaa290d049ee92 Mon Sep 17 00:00:00 2001 From: johnjaylward Date: Mon, 5 Aug 2019 10:07:13 -0400 Subject: [PATCH 2/8] fix small typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index efc6b07..6b8edb1 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,9 @@ go build digitalocean-dynamic-ip.go ``` Optionally, you can create the configuration file with any name wherever you want, and pass it as a command line argument: -````bash +```bash #run -./digitalocean-dynamic-ip /path/tp/my/config.json +./digitalocean-dynamic-ip /path/to/my/config.json ``` You can either set this to run periodically with a cronjob or use your own method. From 8309b1bb645f8a272fbb170ef517ea1f630646bf Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Thu, 26 Sep 2019 11:23:15 -0400 Subject: [PATCH 3/8] Add support for configuring IP check URLs --- digitalocean-dynamic-ip.go | 21 ++++++++++++++++----- digitalocean-dynamic-ip.sample.json | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/digitalocean-dynamic-ip.go b/digitalocean-dynamic-ip.go index b9ed4f0..a567b3d 100644 --- a/digitalocean-dynamic-ip.go +++ b/digitalocean-dynamic-ip.go @@ -31,6 +31,8 @@ type ClientConfig struct { DOPageSize int `json:"doPageSize"` UseIPv4 *bool `json:"useIPv4"` UseIPv6 *bool `json:"useIPv6"` + IPv4CheckURL string `json:"ipv4CheckUrl"` + IPv6CheckURL string `json:"ipv6CheckUrl"` AllowIPv4InIPv6 bool `json:"allowIPv4InIPv6"` Domains []Domain `json:"domains"` } @@ -118,9 +120,17 @@ func usage() { //CheckLocalIPs : get current IP of server. checks both IPv4 and Ipv6 to support dual stack environments func CheckLocalIPs() (ipv4, ipv6 net.IP) { var ipv4String, ipv6String string + ipv4CheckUrl := "https://ipv4bot.whatismyipaddress.com" + ipv6CheckUrl := "https://ipv6bot.whatismyipaddress.com" + if len(config.IPv4CheckURL) > 0 { + ipv4CheckUrl = config.IPv4CheckURL + } + if len(config.IPv6CheckURL) > 0 { + ipv6CheckUrl = config.IPv6CheckURL + } if config.UseIPv4 == nil || *(config.UseIPv4) { - ipv4String, _ = getURLBody("https://ipv4bot.whatismyipaddress.com") + ipv4String, _ = getURLBody(ipv4CheckUrl) if ipv4String == "" { log.Println("No IPv4 address found. Consider disabling IPv4 checks in the config `\"useIPv4\": false`") } else { @@ -128,6 +138,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) { if ipv4 != nil { // make sure we got back an actual ipv4 address ipv4 = ipv4.To4() + log.Printf("Discovered IPv4 address `%s`", ipv4.String()) } if ipv4 == nil { log.Printf("Unable to parse `%s` as an IPv4 address", ipv4String) @@ -136,13 +147,15 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) { } if config.UseIPv6 == nil || *(config.UseIPv6) { - ipv6String, _ = getURLBody("https://ipv6bot.whatismyipaddress.com") + ipv6String, _ = getURLBody(ipv6CheckUrl) if ipv6String == "" { log.Println("No IPv6 address found. Consider disabling IPv6 checks in the config `\"useIPv6\": false`") } else { ipv6 = net.ParseIP(ipv6String) if ipv6 == nil { log.Printf("Unable to parse `%s` as an IPv6 address", ipv6String) + } else { + log.Printf("Discovered IPv6 address `%s`", ipv6.String()) } } } @@ -151,9 +164,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) { func getURLBody(url string) (string, error) { request, err := http.Get(url) - if err != nil { - return "", err - } + checkError(err) defer request.Body.Close() body, err := ioutil.ReadAll(request.Body) checkError(err) diff --git a/digitalocean-dynamic-ip.sample.json b/digitalocean-dynamic-ip.sample.json index e812158..43d7622 100644 --- a/digitalocean-dynamic-ip.sample.json +++ b/digitalocean-dynamic-ip.sample.json @@ -3,6 +3,8 @@ "doPageSize": 20, "useIPv4": true, "useIPv6": true, + "ipv4CheckUrl": "https://ipv4bot.whatismyipaddress.com", + "ipv6CheckUrl": "https://ipv6bot.whatismyipaddress.com", "allowIPv4InIPv6": false, "domains": [ { @@ -11,6 +13,10 @@ { "name": "subdomainOrRecord", "type": "A" + }, + { + "name": "subdomainOrRecord", + "type": "AAAA" } ] }, From 3b401c5a1f6bb719826cb3a0292d10b2f8baaa58 Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Thu, 26 Sep 2019 11:23:36 -0400 Subject: [PATCH 4/8] [minor] Cleanup some log messages & README --- README.md | 4 ++-- digitalocean-dynamic-ip.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6b8edb1..33bf565 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ Once the module is fetched, you should be able to compile the program using `go ```bash git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git ``` -create a file ".digitalocean-dynamic-ip.json"(dot prefix to hide the file) and place it user home directory and add the following json +create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and place it user home directory and add the following json ```json { "apikey": "samplekeydasjkdhaskjdhrwofihsamplekey", - "doPageSize" : 20, + "doPageSize": 20, "useIPv4": true, "useIPv6": false, "allowIPv4InIPv6": false, diff --git a/digitalocean-dynamic-ip.go b/digitalocean-dynamic-ip.go index a567b3d..a1ab236 100644 --- a/digitalocean-dynamic-ip.go +++ b/digitalocean-dynamic-ip.go @@ -217,10 +217,10 @@ func UpdateRecords(domain Domain, ipv4, ipv6 net.IP) { doRecords := GetDomainRecords(domain.Domain) // look for the item to update if len(doRecords) < 1 { - log.Printf("%s: No DNS records found in Digital Ocean", domain.Domain) + log.Printf("%s: No DNS records found in DigitalOcean", domain.Domain) return } - log.Printf("%s: %d DNS records found in Digital Ocean", domain.Domain, len(doRecords)) + log.Printf("%s: %d DNS records found in DigitalOcean", domain.Domain, len(doRecords)) for _, toUpdateRecord := range domain.Records { if toUpdateRecord.Type != "A" && toUpdateRecord.Type != "AAAA" { log.Printf("%s: Unsupported type (Only A and AAAA records supported) for updates %+v", domain.Domain, toUpdateRecord) @@ -338,7 +338,7 @@ func main() { config = GetConfig() currentIPv4, currentIPv6 := CheckLocalIPs() if currentIPv4 == nil && currentIPv6 == nil { - log.Fatal("current IP addresses are not a valid, or both are disabled in the config. Check you configuration and internet connection") + log.Fatal("Current IP addresses are not valid, or both are disabled in the config. Check your configuration and internet connection.") } for _, domain := range config.Domains { log.Printf("%s: START", domain.Domain) From 7e236a7cf0eb2af48203bd400b17b5bc8f109675 Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Thu, 26 Sep 2019 11:24:05 -0400 Subject: [PATCH 5/8] Add GoLand project file to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f34a787..7a004cc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ config.json digitalocean-dynamic-ip digitalocean-dynamic-dns-ip digitalocean-dynamic-ip.json + +# GoLand IDE +.idea/ \ No newline at end of file From bf919c063b0efdd90c8030adee0307c7d2ec3978 Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Thu, 26 Sep 2019 13:45:03 -0400 Subject: [PATCH 6/8] update README --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 33bf565..7cbf701 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # DIGITAL OCEAN DYNAMIC IP API CLIENT A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc. -To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. +To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. (These URLs can be customized; see Usage, below.) ## Requirements Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building. @@ -18,9 +18,11 @@ Once the module is fetched, you should be able to compile the program using `go ## Usage ```bash +# clone the repo in ~/go/src/github.com/anaganisk: git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git ``` -create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and place it user home directory and add the following json + +Create a file `.digitalocean-dynamic-ip.json` (dot prefix to hide the file) and place it in your home directory. Add the following JSON (or refer to the sample configuration file, `digitalocean-dynamic-ip.sample.json`): ```json { @@ -29,6 +31,7 @@ create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and "useIPv4": true, "useIPv6": false, "allowIPv4InIPv6": false, + "ipv4CheckUrl": "https://ipv4bot.whatismyipaddress.com", "domains": [ { "domain": "example.com", @@ -52,6 +55,7 @@ create a file ".digitalocean-dynamic-ip.json" (dot prefix to hide the file) and ] } ``` + The TTL can optionally be updated if passed in the configuration. Digital Ocean has a minimum TTL of 30 seconds. The `type` and the `name` must match existing records in the Digital Ocean DNS configuration. Only `types` of `A` and `AAAA` allowed at the moment. If you want to reduce the number of calls made to the digital ocean API and have more than 20 DNS records in your domain, you can adjust the `doPageSize` parameter. By default, Digital Ocean returns 20 records per page. Digital Ocean has a max page size of 200 items. @@ -60,22 +64,25 @@ By default, the configuration checks both IPv4 and IPv6 addresses assuming your The `allowIPv4InIPv6` configuration option will allow adding an IPv4 address to be used in a AAAA record for IPv6 lookups. +The `ipv4CheckUrl` and `ipv6CheckUrl` configuration settings are optional. If set, they must be URLs which respond to a GET request, with a plaintext response containing only your IP address. If unset, they default to `https://ipv_bot.whatismyipaddress.com`. + ```bash -#run -go build digitalocean-dynamic-ip.go +# after running `go build digitalocean-dynamic-ip.go`, run: ./digitalocean-dynamic-ip ``` Optionally, you can create the configuration file with any name wherever you want, and pass it as a command line argument: + ```bash -#run +#run: ./digitalocean-dynamic-ip /path/to/my/config.json ``` You can either set this to run periodically with a cronjob or use your own method. + ```bash -# run crontab -e -# sample cron job task +# run `crontab -e` to edit your crontab +# sample cron job task # m h dom mon dow command */5 * * * * /home/user/digitalocean-dynamic-dns-ip/digitalocean-dynamic-ip From 47b51d0cf03f870ee0f21517602f931d376d39f0 Mon Sep 17 00:00:00 2001 From: Sai Kiran Anagani Date: Tue, 29 Oct 2019 17:07:49 +0530 Subject: [PATCH 7/8] added circle ci --- .circleci/config.yml | 34 ++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- README.md | 15 ++++++++++++--- ci-build-script.sh | 27 +++++++++++++++++++++++++++ go.mod | 5 +++++ go.sum | 2 ++ 6 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 .circleci/config.yml create mode 100755 ci-build-script.sh create mode 100644 go.mod create mode 100644 go.sum diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..948c674 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,34 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/golang:1.8 + working_directory: /go/src/github.com/anaganisk/digitalocean-dynamic-dns-ip + steps: + - checkout + - attach_workspace: + at: ./releases + - run: + name: Build + command: | + echo 'export GO111MODULE=on' >> $BASH_ENV + source $BASH_ENV + ./ci-build-script.sh + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./releases/ + +workflows: + version: 2 + main: + jobs: + - build: + filters: + tags: + only: /^\d+\.\d+\.\d+$/ + - publish-github-release: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + only: /^\d+\.\d+\.\d+$/ diff --git a/.gitignore b/.gitignore index 7a004cc..42ce9ef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ digitalocean-dynamic-dns-ip digitalocean-dynamic-ip.json # GoLand IDE -.idea/ \ No newline at end of file +.idea/ +releases \ No newline at end of file diff --git a/README.md b/README.md index 7cbf701..8f3628b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # DIGITAL OCEAN DYNAMIC IP API CLIENT + A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc. To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. (These URLs can be customized; see Usage, below.) ## Requirements -Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building. + +Requires Git, Go 1.8+. Requires that the record already exists in DigitalOcean's DNS so that it can be updated. (manually find your IP and add it to DO's DNS it will later be updated) @@ -12,11 +14,18 @@ Requires that the record already exists in DigitalOcean's DNS so that it can be Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens. ## Building -You first need to install the "homedir" module if you aren't using it in another project. To install the module, run `go get github.com/mitchellh/go-homedir` -Once the module is fetched, you should be able to compile the program using `go build` +You first need to install the "homedir" module if you aren't using it in another project. To install the module. + +```bash +# Skip to next step, if you have GO111MODULE=on in your environment it is fetched automatically +go get github.com/mitchellh/go-homedir +# build the project +go build +``` ## Usage + ```bash # clone the repo in ~/go/src/github.com/anaganisk: git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git diff --git a/ci-build-script.sh b/ci-build-script.sh new file mode 100755 index 0000000..43948f4 --- /dev/null +++ b/ci-build-script.sh @@ -0,0 +1,27 @@ +#!/bin/bash +package=$1 +if [[ -z "$package" ]]; then + echo "usage: $0 " + exit 1 +fi +package_split=(${package//\// }) +package_name=${package_split[-1]} + +platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm" "linux/arm64") +mkdir releases +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$GOOS'-'$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi +done \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e9fb58a --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/anaganisk/digitalocean-dynamic-dns-ip + +require github.com/mitchellh/go-homedir v1.1.0 + +go 1.13 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ae38d14 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= From 8623ef5c80f89d99258404a91ac0323199ae5e99 Mon Sep 17 00:00:00 2001 From: Sai Kiran Anagani Date: Tue, 29 Oct 2019 17:15:53 +0530 Subject: [PATCH 8/8] added new installation instructions --- .circleci/config.yml | 25 ++++++++++++++++++------- README.md | 23 ++++++++++------------- ci-build-script.sh | 8 +++----- digitalocean-dynamic-ip.go | 12 ++++++------ go.mod | 2 +- 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 948c674..90bda8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,18 +2,29 @@ version: 2 jobs: build: docker: - - image: circleci/golang:1.8 - working_directory: /go/src/github.com/anaganisk/digitalocean-dynamic-dns-ip + - image: circleci/golang:1.11 + working_directory: ~/app steps: - checkout - - attach_workspace: - at: ./releases - run: name: Build command: | - echo 'export GO111MODULE=on' >> $BASH_ENV - source $BASH_ENV - ./ci-build-script.sh + ./ci-build-script.sh . + - persist_to_workspace: + root: . + paths: + - ./releases + + publish-github-release: + docker: + - image: cibuilds/github:0.10 + working_directory: ~/app + steps: + - attach_workspace: + at: ~/app + - run: + name: "Publish Release on GitHub" + command: | ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./releases/ workflows: diff --git a/README.md b/README.md index 8f3628b..847f463 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DIGITAL OCEAN DYNAMIC IP API CLIENT +# DIGITAL OCEAN DYNAMIC IP API CLIENT [![CircleCI](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master.svg?style=svg)](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master) A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc. @@ -6,18 +6,20 @@ To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyi ## Requirements -Requires Git, Go 1.8+. +- The record must already exist in DigitalOcean's DNS so that it can be updated. + (manually find your IP and add it to DO's DNS it will later be updated) +- A Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens. -Requires that the record already exists in DigitalOcean's DNS so that it can be updated. -(manually find your IP and add it to DO's DNS it will later be updated) +## Installation -Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens. +Download the prebuilt binaries from [releases](https://github.com/anaganisk/digitalocean-dynamic-dns-ip/releases), -## Building - -You first need to install the "homedir" module if you aren't using it in another project. To install the module. +or Build from source ```bash +# Requires Git, Go 1.8+(GO 1.11 if you want to use GO111MODULE=on). +# clone the repo in ~/go/src/github.com/anaganisk: +git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git # Skip to next step, if you have GO111MODULE=on in your environment it is fetched automatically go get github.com/mitchellh/go-homedir # build the project @@ -26,11 +28,6 @@ go build ## Usage -```bash -# clone the repo in ~/go/src/github.com/anaganisk: -git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git -``` - Create a file `.digitalocean-dynamic-ip.json` (dot prefix to hide the file) and place it in your home directory. Add the following JSON (or refer to the sample configuration file, `digitalocean-dynamic-ip.sample.json`): ```json diff --git a/ci-build-script.sh b/ci-build-script.sh index 43948f4..760b593 100755 --- a/ci-build-script.sh +++ b/ci-build-script.sh @@ -6,7 +6,6 @@ if [[ -z "$package" ]]; then fi package_split=(${package//\// }) package_name=${package_split[-1]} - platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm" "linux/arm64") mkdir releases for platform in "${platforms[@]}" @@ -14,12 +13,11 @@ do platform_split=(${platform//\// }) GOOS=${platform_split[0]} GOARCH=${platform_split[1]} - output_name=$package_name'-'$GOOS'-'$GOARCH + output_name='digitalocean-dynamic-dns-ip-'$GOOS'-'$GOARCH if [ $GOOS = "windows" ]; then output_name+='.exe' - fi - - env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package + fi + env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package_name if [ $? -ne 0 ]; then echo 'An error has occurred! Aborting the script execution...' exit 1 diff --git a/digitalocean-dynamic-ip.go b/digitalocean-dynamic-ip.go index a1ab236..c11a7bf 100644 --- a/digitalocean-dynamic-ip.go +++ b/digitalocean-dynamic-ip.go @@ -120,17 +120,17 @@ func usage() { //CheckLocalIPs : get current IP of server. checks both IPv4 and Ipv6 to support dual stack environments func CheckLocalIPs() (ipv4, ipv6 net.IP) { var ipv4String, ipv6String string - ipv4CheckUrl := "https://ipv4bot.whatismyipaddress.com" - ipv6CheckUrl := "https://ipv6bot.whatismyipaddress.com" + ipv4CheckURL := "https://ipv4bot.whatismyipaddress.com" + ipv6CheckURL := "https://ipv6bot.whatismyipaddress.com" if len(config.IPv4CheckURL) > 0 { - ipv4CheckUrl = config.IPv4CheckURL + ipv4CheckURL = config.IPv4CheckURL } if len(config.IPv6CheckURL) > 0 { - ipv6CheckUrl = config.IPv6CheckURL + ipv6CheckURL = config.IPv6CheckURL } if config.UseIPv4 == nil || *(config.UseIPv4) { - ipv4String, _ = getURLBody(ipv4CheckUrl) + ipv4String, _ = getURLBody(ipv4CheckURL) if ipv4String == "" { log.Println("No IPv4 address found. Consider disabling IPv4 checks in the config `\"useIPv4\": false`") } else { @@ -147,7 +147,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) { } if config.UseIPv6 == nil || *(config.UseIPv6) { - ipv6String, _ = getURLBody(ipv6CheckUrl) + ipv6String, _ = getURLBody(ipv6CheckURL) if ipv6String == "" { log.Println("No IPv6 address found. Consider disabling IPv6 checks in the config `\"useIPv6\": false`") } else { diff --git a/go.mod b/go.mod index e9fb58a..dd16a23 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/anaganisk/digitalocean-dynamic-dns-ip require github.com/mitchellh/go-homedir v1.1.0 -go 1.13 +go 1.8