git: 86b0e308eb20 - main - dns/godns: New port: Dynamic DNS (DDNS) client with notification support

From: Daniel Engberg <diizzy_at_FreeBSD.org>
Date: Sun, 22 Oct 2023 15:00:09 UTC
The branch main has been updated by diizzy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=86b0e308eb20ed0c8692386b1f1ee7011d2686ed

commit 86b0e308eb20ed0c8692386b1f1ee7011d2686ed
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2023-10-22 14:52:42 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2023-10-22 14:52:52 +0000

    dns/godns: New port: Dynamic DNS (DDNS) client with notification support
    
    Yet another client but with support for sending notifications over
    multiple services such as Email, Telegram, Slack, Discord, Pushover
    and additional ways such as webhooks.
    
    Website: https://github.com/TimothyYe/godns
---
 dns/Makefile                             |  1 +
 dns/godns/Makefile                       | 67 +++++++++++++++++++++++++++++++
 dns/godns/distinfo                       | 69 ++++++++++++++++++++++++++++++++
 dns/godns/files/godns-config.json.sample | 16 ++++++++
 dns/godns/files/godns.in                 | 55 +++++++++++++++++++++++++
 dns/godns/files/patch-cmd_godns_godns.go | 16 ++++++++
 dns/godns/files/pkg-message.in           | 19 +++++++++
 dns/godns/pkg-descr                      |  3 ++
 dns/godns/pkg-plist                      |  2 +
 9 files changed, 248 insertions(+)

diff --git a/dns/Makefile b/dns/Makefile
index 7234dbb3bc58..f66925dd5353 100644
--- a/dns/Makefile
+++ b/dns/Makefile
@@ -76,6 +76,7 @@
     SUBDIR += gdnsd3
     SUBDIR += gen6dns
     SUBDIR += getdns
+    SUBDIR += godns
     SUBDIR += hesiod
     SUBDIR += hetzner_ddns
     SUBDIR += hostdb
diff --git a/dns/godns/Makefile b/dns/godns/Makefile
new file mode 100644
index 000000000000..897a496c7579
--- /dev/null
+++ b/dns/godns/Makefile
@@ -0,0 +1,67 @@
+PORTNAME=	godns
+DISTVERSIONPREFIX=	v
+DISTVERSION=	3.0.4
+CATEGORIES=	dns
+
+MAINTAINER=	diizzy@FreeBSD.org
+COMMENT=	Dynamic DNS client (DDNS) with optional external reporting features
+WWW=		https://github.com/TimothyYe/godns
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		go:modules
+USE_RC_SUBR=	${PORTNAME}
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	TimothyYe
+
+GH_TUPLE=	\
+		alexcesaro:quotedprintable:2caba252f4dc:alexcesaro_quotedprintable/vendor/gopkg.in/alexcesaro/quotedprintable.v3 \
+		bitly:go-simplejson:v0.5.0:bitly_go_simplejson/vendor/github.com/bitly/go-simplejson \
+		bmizerany:assert:b7ed37b82869:bmizerany_assert/vendor/github.com/bmizerany/assert \
+		bwmarrin:discordgo:v0.27.1:bwmarrin_discordgo/vendor/github.com/bwmarrin/discordgo \
+		fatih:color:v1.15.0:fatih_color/vendor/github.com/fatih/color \
+		go-check:check:10cb98267c6c:go_check_check/vendor/gopkg.in/check.v1 \
+		go-gomail:gomail:81ebce5c23df:go_gomail_gomail/vendor/gopkg.in/gomail.v2 \
+		go-ini:ini:v1.67.0:go_ini_ini/vendor/gopkg.in/ini.v1 \
+		go-resty:resty:v2.7.0:go_resty_resty_v2/vendor/github.com/go-resty/resty/v2 \
+		go-yaml:yaml:v3.0.1:go_yaml_yaml/vendor/gopkg.in/yaml.v3 \
+		golang:appengine:v1.6.7:golang_appengine/vendor/google.golang.org/appengine \
+		golang:crypto:v0.8.0:golang_crypto/vendor/golang.org/x/crypto \
+		golang:mod:v0.10.0:golang_mod/vendor/golang.org/x/mod \
+		golang:net:v0.9.0:golang_net/vendor/golang.org/x/net \
+		golang:oauth2:v0.7.0:golang_oauth2/vendor/golang.org/x/oauth2 \
+		golang:protobuf:v1.5.3:golang_protobuf/vendor/github.com/golang/protobuf \
+		golang:sys:v0.7.0:golang_sys/vendor/golang.org/x/sys \
+		golang:text:v0.9.0:golang_text/vendor/golang.org/x/text \
+		golang:tools:v0.8.0:golang_tools/vendor/golang.org/x/tools \
+		google:uuid:v1.3.0:google_uuid/vendor/github.com/google/uuid \
+		gorilla:websocket:v1.5.0:gorilla_websocket/vendor/github.com/gorilla/websocket \
+		json-iterator:go:v1.1.12:json_iterator_go/vendor/github.com/json-iterator/go \
+		kr:pretty:v0.3.1:kr_pretty/vendor/github.com/kr/pretty \
+		linode:linodego:v1.16.1:linode_linodego/vendor/github.com/linode/linodego \
+		mattn:go-colorable:v0.1.13:mattn_go_colorable/vendor/github.com/mattn/go-colorable \
+		mattn:go-isatty:v0.0.18:mattn_go_isatty/vendor/github.com/mattn/go-isatty \
+		miekg:dns:v1.1.53:miekg_dns/vendor/github.com/miekg/dns \
+		modern-go:concurrent:bacd9c7ef1dd:modern_go_concurrent/vendor/github.com/modern-go/concurrent \
+		modern-go:reflect2:v1.0.2:modern_go_reflect2/vendor/github.com/modern-go/reflect2 \
+		ovh:go-ovh:v1.4.1:ovh_go_ovh/vendor/github.com/ovh/go-ovh \
+		protocolbuffers:protobuf-go:v1.30.0:protocolbuffers_protobuf_go/vendor/google.golang.org/protobuf \
+		sirupsen:logrus:v1.9.0:sirupsen_logrus/vendor/github.com/sirupsen/logrus \
+		stretchr:testify:v1.8.2:stretchr_testify/vendor/github.com/stretchr/testify
+
+GO_TARGET=	./cmd/${PORTNAME}
+
+SUB_FILES=	pkg-message
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
+		${PATCH_WRKSRC}/cmd/godns/godns.go
+	@${REINPLACE_CMD} -e 's|%%DISTVERSION%%|${DISTVERSION}|g' \
+		${PATCH_WRKSRC}/cmd/godns/godns.go
+
+post-install:
+	${INSTALL_DATA} ${FILESDIR}/godns-config.json.sample ${STAGEDIR}${PREFIX}/etc
+
+.include <bsd.port.mk>
diff --git a/dns/godns/distinfo b/dns/godns/distinfo
new file mode 100644
index 000000000000..53c73f8f704a
--- /dev/null
+++ b/dns/godns/distinfo
@@ -0,0 +1,69 @@
+TIMESTAMP = 1697979253
+SHA256 (TimothyYe-godns-v3.0.4_GH0.tar.gz) = 1874ac383aaa5d218158ae8862a228307773432479dfd2e22c62d941f372a1ff
+SIZE (TimothyYe-godns-v3.0.4_GH0.tar.gz) = 326763
+SHA256 (alexcesaro-quotedprintable-2caba252f4dc_GH0.tar.gz) = 1a314d172f499342a97996e30ae1731b2e923e17031734d7350927458f544efb
+SIZE (alexcesaro-quotedprintable-2caba252f4dc_GH0.tar.gz) = 10425
+SHA256 (bitly-go-simplejson-v0.5.0_GH0.tar.gz) = 44196c95263e74277372319e5a6cb7f53b29ef7ddab8c7fed6ce6fc80144d465
+SIZE (bitly-go-simplejson-v0.5.0_GH0.tar.gz) = 5994
+SHA256 (bmizerany-assert-b7ed37b82869_GH0.tar.gz) = f7dc11f10c5e52a94c836e15e7aff05ad4afba7436f66e5f4506806627c4635e
+SIZE (bmizerany-assert-b7ed37b82869_GH0.tar.gz) = 1469
+SHA256 (bwmarrin-discordgo-v0.27.1_GH0.tar.gz) = b2d58bfee839f9d34a1379d66e11213e50a0eccc00fdabd78b823c3559e58ff4
+SIZE (bwmarrin-discordgo-v0.27.1_GH0.tar.gz) = 154721
+SHA256 (fatih-color-v1.15.0_GH0.tar.gz) = e7a92edb32453c11aec9fac4d9f2b8fc42fac72249a7ca567c926a112534030e
+SIZE (fatih-color-v1.15.0_GH0.tar.gz) = 11273
+SHA256 (go-check-check-10cb98267c6c_GH0.tar.gz) = 0a42d9d5a49ebc30174e5840238e446f5fb16899bfaa6a6f63d12ab9953df293
+SIZE (go-check-check-10cb98267c6c_GH0.tar.gz) = 32375
+SHA256 (go-gomail-gomail-81ebce5c23df_GH0.tar.gz) = 13ee4111b51dd292a87f6216131eb614603dc54a5a34d6fb44deb0c352a217ba
+SIZE (go-gomail-gomail-81ebce5c23df_GH0.tar.gz) = 16568
+SHA256 (go-ini-ini-v1.67.0_GH0.tar.gz) = 06ba51234140118d1b6064f1817aa89cc971c6e7ce04cb9d286e6660d89296c8
+SIZE (go-ini-ini-v1.67.0_GH0.tar.gz) = 53531
+SHA256 (go-resty-resty-v2.7.0_GH0.tar.gz) = 9afa2ab22afb81b4ff7275f5a2cb055b1bf3b19ff9506036f35c85ec0465beee
+SIZE (go-resty-resty-v2.7.0_GH0.tar.gz) = 2644943
+SHA256 (go-yaml-yaml-v3.0.1_GH0.tar.gz) = cf05411540d3e6ef8f1fd88434b34f94cedaceb540329031d80e23b74540c4e5
+SIZE (go-yaml-yaml-v3.0.1_GH0.tar.gz) = 91173
+SHA256 (golang-appengine-v1.6.7_GH0.tar.gz) = c623d81235f7c9699e299b328191d813337dd57dcc800d7afdb5130e8c321a8f
+SIZE (golang-appengine-v1.6.7_GH0.tar.gz) = 333007
+SHA256 (golang-crypto-v0.8.0_GH0.tar.gz) = b8fb5d22ed977e7912d8a2c80ff40a4632fba492d43cc638c8b8bb7e961bea33
+SIZE (golang-crypto-v0.8.0_GH0.tar.gz) = 1634889
+SHA256 (golang-mod-v0.10.0_GH0.tar.gz) = 3d944a6ee2d258713636400930d0d5913a71a861d8efd00b51b97e8d19b487ba
+SIZE (golang-mod-v0.10.0_GH0.tar.gz) = 120380
+SHA256 (golang-net-v0.9.0_GH0.tar.gz) = f7f85ae52cf7dae86a30c71db6601f84bb1dd25e68e81b04deaeeb0dc3bbad1f
+SIZE (golang-net-v0.9.0_GH0.tar.gz) = 1244440
+SHA256 (golang-oauth2-v0.7.0_GH0.tar.gz) = 18407271b525c12d53d1264f13e04ed83b250b0fe78da96b4eabd687a79de260
+SIZE (golang-oauth2-v0.7.0_GH0.tar.gz) = 87761
+SHA256 (golang-protobuf-v1.5.3_GH0.tar.gz) = 48457a6a9e8c78a7556ff5ff4a4c77d7df9bf70e882491ee0f3f1ff06db2bfaa
+SIZE (golang-protobuf-v1.5.3_GH0.tar.gz) = 171822
+SHA256 (golang-sys-v0.7.0_GH0.tar.gz) = be9b6e1cb2fdb5822ea7fde4c3b226cfe47927c4305db9fa9fc1fae4fdf213b0
+SIZE (golang-sys-v0.7.0_GH0.tar.gz) = 1434670
+SHA256 (golang-text-v0.9.0_GH0.tar.gz) = 410b532978a3dcd01caa39baa39e0c6044e066545ab231b523cafbccf4425791
+SIZE (golang-text-v0.9.0_GH0.tar.gz) = 8361612
+SHA256 (golang-tools-v0.8.0_GH0.tar.gz) = 83277ab2b9590c472d5127d49757fbb44d45e1518c1f59eac7d0d8898b1970e6
+SIZE (golang-tools-v0.8.0_GH0.tar.gz) = 3399590
+SHA256 (google-uuid-v1.3.0_GH0.tar.gz) = 7f7f37c47980e0afcc178a9ffc390bec29ed2371919b4c07658eb01791a7f921
+SIZE (google-uuid-v1.3.0_GH0.tar.gz) = 16210
+SHA256 (gorilla-websocket-v1.5.0_GH0.tar.gz) = 5d86f9e1c76ff7ceca0747f78b79864fbaec9d440f4fdb03197466e5102a86b0
+SIZE (gorilla-websocket-v1.5.0_GH0.tar.gz) = 54155
+SHA256 (json-iterator-go-v1.1.12_GH0.tar.gz) = ff70e539fd919da757a2f3a530a053e7577cb4d7e2824fc1058d3abbefbb523e
+SIZE (json-iterator-go-v1.1.12_GH0.tar.gz) = 84307
+SHA256 (kr-pretty-v0.3.1_GH0.tar.gz) = e6fa7db2708320e66a1645bf6b234e524e73f4163ca0519b8608616e48f5d206
+SIZE (kr-pretty-v0.3.1_GH0.tar.gz) = 10227
+SHA256 (linode-linodego-v1.16.1_GH0.tar.gz) = 505244a8c76c2ba806bb5843ef97eaee1a0215769e4beed8d92649ae88a7b902
+SIZE (linode-linodego-v1.16.1_GH0.tar.gz) = 428705
+SHA256 (mattn-go-colorable-v0.1.13_GH0.tar.gz) = c3b62c76d365906bba9aa9d9ec048fd33a2a5742299d6482a08e7466d4c52d77
+SIZE (mattn-go-colorable-v0.1.13_GH0.tar.gz) = 9762
+SHA256 (mattn-go-isatty-v0.0.18_GH0.tar.gz) = 5b59235986f7a917559181ff814f83f610928b444f290bed733c3f2f900b803d
+SIZE (mattn-go-isatty-v0.0.18_GH0.tar.gz) = 4675
+SHA256 (miekg-dns-v1.1.53_GH0.tar.gz) = 4f75b864cdbfed2c86aa6ba69a5064b84ac1317aaacd5a43c144104dff830f0a
+SIZE (miekg-dns-v1.1.53_GH0.tar.gz) = 209036
+SHA256 (modern-go-concurrent-bacd9c7ef1dd_GH0.tar.gz) = d673e902118a6ece63198dc7e0961e904d0410f142726df0936ec1a52035a60f
+SIZE (modern-go-concurrent-bacd9c7ef1dd_GH0.tar.gz) = 7526
+SHA256 (modern-go-reflect2-v1.0.2_GH0.tar.gz) = eab313f24c09d512f004d489aeed0d0a485f789abd07e7df411375035174341b
+SIZE (modern-go-reflect2-v1.0.2_GH0.tar.gz) = 14030
+SHA256 (ovh-go-ovh-v1.4.1_GH0.tar.gz) = 6a8beedbd7486572a268974a3a95a9d8f28df1673af6a7fae814de4319acd786
+SIZE (ovh-go-ovh-v1.4.1_GH0.tar.gz) = 20810
+SHA256 (protocolbuffers-protobuf-go-v1.30.0_GH0.tar.gz) = 3279a16ec3bdd7c53fe1599134de298ed90d9f3b6ec1c1eb5f3b76ba5aaa9f0c
+SIZE (protocolbuffers-protobuf-go-v1.30.0_GH0.tar.gz) = 1298988
+SHA256 (sirupsen-logrus-v1.9.0_GH0.tar.gz) = 12446ed9eb96573c2aae4df2db81900a65bfd21d2ce92efde7201614e42134f7
+SIZE (sirupsen-logrus-v1.9.0_GH0.tar.gz) = 49098
+SHA256 (stretchr-testify-v1.8.2_GH0.tar.gz) = b1f8aab2022b39d9263dc38ce4a974f64c0219f580a6fe9c56693beaf2702516
+SIZE (stretchr-testify-v1.8.2_GH0.tar.gz) = 98353
diff --git a/dns/godns/files/godns-config.json.sample b/dns/godns/files/godns-config.json.sample
new file mode 100644
index 000000000000..2547a5456998
--- /dev/null
+++ b/dns/godns/files/godns-config.json.sample
@@ -0,0 +1,16 @@
+{
+  "provider": "MyDDNSProvider",
+  "email": "MyUserName",
+  "password": "MyPassWord",
+  "domains": [{
+     "domain_name": "foobar.domain",
+     "sub_domains": ["subdomain"]
+    }
+  ],
+  "ip_type": "IPv4",
+  "ip_urls": [""],
+  "ip_interface": "igb0",
+  "interval": 300,
+  "debug_info": false,
+  "run_once": false
+}
diff --git a/dns/godns/files/godns.in b/dns/godns/files/godns.in
new file mode 100644
index 000000000000..1785c653ce5a
--- /dev/null
+++ b/dns/godns/files/godns.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# PROVIDE: godns
+# REQUIRE: DAEMON LOGIN
+# KEYWORD: shutdown
+
+#
+# Add the following line to /etc/rc.conf to enable godns:
+# godns_enable (bool):		Set to "NO" by default.
+#				Set it to "YES" to enable godns.
+# godns_flags (str):		Custom additional arguments to be passed
+#				to godns (default empty).
+# godns_conf_dir (str):		Directory where ${name} configuration
+#				data is stored.
+
+. /etc/rc.subr
+
+name="godns"
+rcvar=godns_enable
+
+load_rc_config ${name}
+
+: ${godns_enable:="NO"}
+: ${godns_user:="nobody"}
+: ${godns_group:="nogroup"}
+: ${godns_conf_dir="%%PREFIX%%/etc"}
+
+start_precmd=godns_precmd
+stop_postcmd=godns_stop_postcmd
+
+procname="%%PREFIX%%/bin/${name}"
+pidfile="/var/run/${name}/${name}.pid"
+logfile="/var/log/${name}/${name}.log"
+
+required_files="${godns_conf_dir}/${name}-config.json"
+
+command="/usr/sbin/daemon"
+command_args="-f -t ${name} -o ${logfile} -p ${pidfile} ${procname} -c ${required_files} ${godns_args}"
+
+godns_precmd()
+{
+	local rundir=${pidfile%/*}
+	if [ ! -d $rundir ] ; then
+		install -d -m 0755 -o ${godns_user} -g ${godns_group} $rundir
+	fi
+	local logdir=${logfile%/*}
+	install -d -m 0750 -o ${godns_user} -g ${godns_group} $logdir
+}
+
+godns_stop_postcmd()
+{
+	rm -f "$rundir"
+}
+
+run_rc_command "$1"
diff --git a/dns/godns/files/patch-cmd_godns_godns.go b/dns/godns/files/patch-cmd_godns_godns.go
new file mode 100644
index 000000000000..fe61039e125b
--- /dev/null
+++ b/dns/godns/files/patch-cmd_godns_godns.go
@@ -0,0 +1,16 @@
+--- cmd/godns/godns.go.orig	2023-01-19 15:20:32 UTC
++++ cmd/godns/godns.go
+@@ -16,11 +16,11 @@ import (
+ 
+ var (
+ 	configuration settings.Settings
+-	optConf       = flag.String("c", "./config.json", "Specify a config file")
++	optConf       = flag.String("c", "%%PREFIX%%/etc/godns-config.json", "Specify a config file")
+ 	optHelp       = flag.Bool("h", false, "Show help")
+ 
+ 	// Version is current version of GoDNS.
+-	Version = "0.1"
++	Version = "%%DISTVERSION%%"
+ )
+ 
+ func init() {
diff --git a/dns/godns/files/pkg-message.in b/dns/godns/files/pkg-message.in
new file mode 100644
index 000000000000..af66ace952b9
--- /dev/null
+++ b/dns/godns/files/pkg-message.in
@@ -0,0 +1,19 @@
+[
+{ type: install
+  message: <<EOM
+  Edit /etc/rc.conf(.local) to start GoDNS automatically at system
+  startup. Command line arguments can be set via godns_args.
+
+  A sample configuration file is installed at the follow location:
+  %%PREFIX%%/etc/godns-config.json.sample
+
+  If you're testing out your setup be aware that GoDNS will refuse
+  to run if you've disabled external ip address lookup and your
+  local interface uses a private ip address.
+
+  Logfile is located at /var/log/godns/godns.log
+
+  For more documentation visit https://github.com/TimothyYe/godns
+EOM
+}
+]
diff --git a/dns/godns/pkg-descr b/dns/godns/pkg-descr
new file mode 100644
index 000000000000..d9435aa9278b
--- /dev/null
+++ b/dns/godns/pkg-descr
@@ -0,0 +1,3 @@
+GoDNS is Dynamic DNS (DDNS) a client that supports various domain providers
+and allows generating notifications upon change through e-mail (SMTP) or using
+services such as Discord, Pushover, Slack and Telegram.
diff --git a/dns/godns/pkg-plist b/dns/godns/pkg-plist
new file mode 100644
index 000000000000..d8ccb629a79f
--- /dev/null
+++ b/dns/godns/pkg-plist
@@ -0,0 +1,2 @@
+bin/godns
+@sample etc/godns-config.json.sample