Compare commits

...

3 Commits

Author SHA1 Message Date
Timmy Welch
d69563b5dd Update externalip 2022-07-07 18:43:59 -07:00
Timmy Welch
a175f5d569 Rename module 2022-07-06 19:49:07 -07:00
4abd68e9f0 Cleanup
Update README.md
Remove leftover gopkg files
Remove CONTRIBUTING.md
2021-08-01 18:45:03 -07:00
13 changed files with 61 additions and 212 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
cloud-dyndns-client
vendor

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=.gitignore]
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.5
hooks:
- id: go-mod-tidy
- id: go-imports
args: [-w]
- repo: https://github.com/golangci/golangci-lint
rev: v1.46.2
hooks:
- id: golangci-lint

View File

@ -1,25 +0,0 @@
# How to Contribute
We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
## Contributor License Agreement
Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution,
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <https://cla.developers.google.com/> to see
your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.
A bot should provide instructions when you submit a PR.
## Code reviews
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

View File

@ -9,12 +9,11 @@ WORKDIR /app
COPY go.mod ./
COPY go.sum ./
COPY go-external-ip ./
RUN go mod download
COPY . ./
RUN go build ./cmd/cloud-dyndns-client
RUN go build ./cmd/godyn
##
## Deploy
@ -24,8 +23,8 @@ FROM gcr.io/distroless/base-debian10
WORKDIR /
COPY --from=build /app/cloud-dyndns-client /cloud-dyndns-client
COPY --from=build /app/godyn /godyn
USER nonroot:nonroot
ENTRYPOINT ["/cloud-dyndns-client"]
ENTRYPOINT ["/godyn"]

97
Gopkg.lock generated
View File

@ -1,97 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
digest = "1:5c3894b2aa4d6bead0ceeea6831b305d62879c871780e7b76296ded1b004bc57"
name = "cloud.google.com/go"
packages = ["compute/metadata"]
pruneopts = "UT"
revision = "dfffe386c33fb24c34ee501e5723df5b97b98514"
version = "v0.30.0"
[[projects]]
digest = "1:97df918963298c287643883209a2c3f642e6593379f97ab400c2a2e219ab647d"
name = "github.com/golang/protobuf"
packages = ["proto"]
pruneopts = "UT"
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
version = "v1.2.0"
[[projects]]
branch = "master"
digest = "1:db7528233e2f178f8770284f05c60708b31e73d9b8d287676ce52a3389681fe4"
name = "golang.org/x/net"
packages = [
"context",
"context/ctxhttp",
"html",
"html/atom",
]
pruneopts = "UT"
revision = "04a2e542c03f1d053ab3e4d6e5abcd4b66e2be8e"
[[projects]]
branch = "master"
digest = "1:faa25cb78cf9c8cec9345d4ed07322cdef6a8c968b3d0a6b6c3609067c7386eb"
name = "golang.org/x/oauth2"
packages = [
".",
"google",
"internal",
"jws",
"jwt",
]
pruneopts = "UT"
revision = "9dcd33a902f40452422c2367fefcb95b54f9f8f8"
[[projects]]
branch = "master"
digest = "1:39ebcc2b11457b703ae9ee2e8cca0f68df21969c6102cb3b705f76cca0ea0239"
name = "golang.org/x/sync"
packages = ["errgroup"]
pruneopts = "UT"
revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
[[projects]]
branch = "master"
digest = "1:53cc6f72e450ce1451e3644208d66df770212cdefbc9c63445bc3f55ec713b05"
name = "google.golang.org/api"
packages = [
"dns/v1",
"gensupport",
"googleapi",
"googleapi/internal/uritemplates",
]
pruneopts = "UT"
revision = "a2651947f503a1793446d4058bb073a6fdf99e53"
[[projects]]
digest = "1:193950893ea275f89ed92e5da11ed8fa1436872f755a9ea5d4afa83dc9d9c3a8"
name = "google.golang.org/appengine"
packages = [
".",
"internal",
"internal/app_identity",
"internal/base",
"internal/datastore",
"internal/log",
"internal/modules",
"internal/remote_api",
"internal/urlfetch",
"urlfetch",
]
pruneopts = "UT"
revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06"
version = "v1.2.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = [
"golang.org/x/net/html",
"golang.org/x/oauth2/google",
"golang.org/x/sync/errgroup",
"google.golang.org/api/dns/v1",
]
solver-name = "gps-cdcl"
solver-version = 1

View File

@ -1,46 +0,0 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"
[[constraint]]
branch = "master"
name = "golang.org/x/sync"
[[constraint]]
branch = "master"
name = "google.golang.org/api"
[prune]
go-tests = true
unused-packages = true

View File

@ -2,24 +2,26 @@
This project contains a simple [Dynamic DNS](https://en.wikipedia.org/wiki/Dynamic_DNS) client that can be used with cloud services. It simply gets your current IP address and sets it to DNS records in backing DNS services. It will do it's best to make sure that the DNS record is always there and set to the desired value, even if something or someone updates or deletes it. It is intended to be used where public internet IPs are assigned dynamically, such as home networks.
Currently cloud-dyndns-client only supports Google Cloud Platform. It is planned to add other DNS APIs as backends.
Currently godyn only supports Google Cloud Platform.
Forked from https://github.com/ianlewis/cloud-dyndns-client
## Prerequisites
cloud-dyndns-client requires **Go 1.8**.
godyn requires **Go 1.8**.
## Install
> You can install Go by following [these instructions](https://golang.org/doc/install).
`cloud-dyndns-client` is written in Go, so if you have Go installed you can install it with
`go get`:
`godyn` is written in Go, so if you have Go installed you can install it with
`go install`:
```
go get github.com/ianlewis/cloud-dyndns-client/cmd/cloud-dyndns-client
go install git.narnian.us/lordwelch/godyn@latest
```
This will download the code, compile it, and leave an `cloud-dyndns-client` binary
This will download the code, compile it, and leave an `godyn` binary
in `$GOPATH/bin`.
## Usage
@ -91,11 +93,3 @@ kubectl create secret generic cloud-dyndns-client-service-account --from-file=se
```
kubectl apply -f kubernetes/deploy.yaml
```
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md).
## Disclaimers
This is not an official Google product

View File

@ -30,9 +30,9 @@ import (
"golang.org/x/sync/errgroup"
"github.com/lordwelch/godyn/pkg/backend"
"github.com/lordwelch/godyn/pkg/backend/gcp"
"github.com/lordwelch/godyn/pkg/sync"
"git.narnian.us/lordwelch/godyn/pkg/backend"
"git.narnian.us/lordwelch/godyn/pkg/backend/gcp"
"git.narnian.us/lordwelch/godyn/pkg/sync"
)
// VERSION is the current version of the application.
@ -213,12 +213,15 @@ func main() {
log.Printf("Updating IPv4 to %v", ip)
for _, r := range records {
if r.Record.Type() == "A" {
syncer.UpdateRecord(
err := syncer.UpdateRecord(
r.Record.Name(),
r.Record.Type(),
r.Record.Ttl(),
[]string{ip},
)
if err != nil {
log.Println(err)
}
}
}
case ip := <-ip6c:
@ -232,7 +235,7 @@ func main() {
[]string{ip},
)
if err != nil {
fmt.Fprintln(os.Stderr, err)
log.Println(err)
}
}
}
@ -249,7 +252,7 @@ func main() {
// shutdown the http server.
mux := http.NewServeMux()
mux.HandleFunc("/_status/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
_, _ = w.Write([]byte("OK"))
})
srv := &http.Server{

22
go.mod
View File

@ -1,10 +1,26 @@
module github.com/lordwelch/godyn
module git.narnian.us/lordwelch/godyn
go 1.16
go 1.18
require (
git.narnian.us/lordwelch/externalip v1.0.0
git.narnian.us/lordwelch/externalip v1.0.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/api v0.52.0
)
require (
cloud.google.com/go v0.88.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420 // indirect
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f // indirect
google.golang.org/grpc v1.39.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)

10
go.sum
View File

@ -40,8 +40,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
git.narnian.us/lordwelch/externalip v1.0.0 h1:rx7o1qB6nWM2Ny+1jmsD4p//0frrFfUgKXkIDdQXwYg=
git.narnian.us/lordwelch/externalip v1.0.0/go.mod h1:rTPbrx5c/uidl/79AkH1FFUQKPtS3UUgpS7nr7Gmk0E=
git.narnian.us/lordwelch/externalip v1.0.1 h1:ITxMZ2WZPJ9ifcaOSkm5VgVLoHMIMfvCM/bpAeG86dM=
git.narnian.us/lordwelch/externalip v1.0.1/go.mod h1:OPhLol6UUxCk0//K+lHtcUi0AitUvww2uQEEPH0x0uQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
@ -121,7 +121,6 @@ github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIG
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190908185732-236ed259b199/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
@ -171,11 +170,9 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/arch v0.0.0-20190919213554-7fe50f7625bd/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -284,7 +281,6 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190919044723-0c1ff786ef13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -348,7 +344,6 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190919223014-db1d4edb4685/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@ -526,6 +521,5 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View File

@ -23,7 +23,7 @@ import (
"golang.org/x/time/rate"
dns "google.golang.org/api/dns/v1"
"github.com/lordwelch/godyn/pkg/backend"
"git.narnian.us/lordwelch/godyn/pkg/backend"
)
type cloudDNSRecord struct {

View File

@ -30,12 +30,6 @@ const (
IP6 IPType = 6
)
var webCheck = []string{
"http://checkip.dyndns.org/",
"http://ipdetect.dnspark.com/",
"http://dns.loopia.se/checkip/checkip.php",
}
// IPAddressPoller is a poller used to check the value
// of the current public internet IP address.
type IPAddressPoller struct {

View File

@ -23,7 +23,7 @@ import (
"sync"
"time"
"github.com/lordwelch/godyn/pkg/backend"
"git.narnian.us/lordwelch/godyn/pkg/backend"
)
type Record struct {