net-dns/ddns-go: merge to gentoo-zh
This commit is contained in:
parent
5000610f03
commit
15544a2bd7
@ -1,2 +0,0 @@
|
||||
DIST ddns-go-6.2.1-deps.tar.xz 14673540 BLAKE2B 0ed0fb2d56cbea84c4164d09134c3a16f0d5c010bff948b3fd0e27f5852975eec35af2763f98a25dd6f8e32718dd3d56ce7e6364483468b9bfd7236bdfa51fd3 SHA512 ced5ef7fde26f198f640f058775450aa012cf2a30e5f524d8c072a9a70934f6d0f6a53f931704c978e00d6f327f60eaf9a796dfce469ee6539cd7cfba45dbbcf
|
||||
DIST ddns-go-6.2.1.tar.gz 150600 BLAKE2B d14f6b0c8d1036d0a035a27106cecb7a6e511f1478bb3d20c5422a2876187c3e9ca5924d4b03a7867b679e4bae03a8600792aa9266f37cdbb5290a63fb4a343e SHA512 9b90defbc395e8e3187e043cb632ebeb68db48267a50b56e90998d1e6d4f838135ba10f40f15fcb1b70b58b99a304ecb4ec229d9850c82820409f547193d4d85
|
@ -1,40 +0,0 @@
|
||||
# Copyright 2023-2024 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
inherit go-module systemd
|
||||
|
||||
DESCRIPTION="Automatically obtain your public IP address and set to your domain name service."
|
||||
HOMEPAGE="https://github.com/jeessy2/ddns-go"
|
||||
SRC_URI="https://github.com/jeessy2/ddns-go/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
|
||||
https://github.com/Puqns67/gentoo-deps/releases/download/${P}/${P}-deps.tar.xz"
|
||||
|
||||
LICENSE="MIT BSD"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64 ~riscv"
|
||||
|
||||
RESTRICT="mirror"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}/${P}-remove-update-support.patch"
|
||||
"${FILESDIR}/${P}-remove-service-management-support.patch"
|
||||
)
|
||||
|
||||
src_compile() {
|
||||
ego build \
|
||||
-trimpath \
|
||||
-ldflags="-s -w -linkmode external \
|
||||
-X 'main.version=${PV}' \
|
||||
-X 'main.buildTime=$(date -u +"%Y-%m-%dT%H:%M:%SZ")'" \
|
||||
-o "${PN}" \
|
||||
.
|
||||
}
|
||||
|
||||
src_install() {
|
||||
dobin "${PN}"
|
||||
systemd_dounit "${FILESDIR}/${PN}.service"
|
||||
systemd_newunit "${FILESDIR}/${PN}_at.service" "${PN}@.service"
|
||||
systemd_dounit "${FILESDIR}/${PN}-web.service"
|
||||
keepdir "/etc/${PN}"
|
||||
}
|
@ -1,317 +0,0 @@
|
||||
From 8d827cc9d4c59a4af9df07d88a4d623c7b2018dc Mon Sep 17 00:00:00 2001
|
||||
From: Puqns67 <me@puqns67.icu>
|
||||
Date: Sun, 24 Dec 2023 22:21:38 +0800
|
||||
Subject: [PATCH 2/2] build: remove service management support for this build
|
||||
|
||||
---
|
||||
go.mod | 7 +-
|
||||
go.sum | 5 --
|
||||
main.go | 223 --------------------------------------------------------
|
||||
3 files changed, 1 insertion(+), 234 deletions(-)
|
||||
|
||||
diff --git a/go.mod b/go.mod
|
||||
index ae9aceb..7a83d8b 100644
|
||||
--- a/go.mod
|
||||
+++ b/go.mod
|
||||
@@ -3,13 +3,8 @@ module github.com/jeessy2/ddns-go/v6
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
- github.com/kardianos/service v1.2.2
|
||||
github.com/wagslane/go-password-validator v0.3.0
|
||||
golang.org/x/net v0.22.0
|
||||
- gopkg.in/yaml.v3 v3.0.1
|
||||
-)
|
||||
-
|
||||
-require (
|
||||
- golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0
|
||||
+ gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
diff --git a/go.sum b/go.sum
|
||||
index 6d113ed..23a1c9a 100644
|
||||
--- a/go.sum
|
||||
+++ b/go.sum
|
||||
@@ -1,12 +1,7 @@
|
||||
-github.com/kardianos/service v1.2.2 h1:ZvePhAHfvo0A7Mftk/tEzqEZ7Q4lgnR8sGz4xu1YX60=
|
||||
-github.com/kardianos/service v1.2.2/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
|
||||
github.com/wagslane/go-password-validator v0.3.0 h1:vfxOPzGHkz5S146HDpavl0cw1DSVP061Ry2PX0/ON6I=
|
||||
github.com/wagslane/go-password-validator v0.3.0/go.mod h1:TI1XJ6T5fRdRnHqHt14pvy1tNVnrwe7m3/f1f2fDphQ=
|
||||
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
-golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
-golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
-golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
diff --git a/main.go b/main.go
|
||||
index 7617e5c..32c7285 100644
|
||||
--- a/main.go
|
||||
+++ b/main.go
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
- "os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -18,7 +17,6 @@ import (
|
||||
"github.com/jeessy2/ddns-go/v6/dns"
|
||||
"github.com/jeessy2/ddns-go/v6/util"
|
||||
"github.com/jeessy2/ddns-go/v6/web"
|
||||
- "github.com/kardianos/service"
|
||||
)
|
||||
|
||||
// ddns-go 版本
|
||||
@@ -34,9 +32,6 @@ var every = flag.Int("f", 300, "Sync frequency(seconds)")
|
||||
// 缓存次数
|
||||
var ipCacheTimes = flag.Int("cacheTimes", 5, "Interval N times compared with service providers")
|
||||
|
||||
-// 服务管理
|
||||
-var serviceType = flag.String("s", "", "Service management (install|uninstall|restart)")
|
||||
-
|
||||
// 配置文件路径
|
||||
var configFilePath = flag.String("c", util.GetConfigFilePathDefault(), "config file path")
|
||||
|
||||
@@ -79,37 +74,7 @@ func main() {
|
||||
util.SetDNS(*customDNSServer)
|
||||
}
|
||||
os.Setenv(util.IPCacheTimesENV, strconv.Itoa(*ipCacheTimes))
|
||||
- switch *serviceType {
|
||||
- case "install":
|
||||
- installService()
|
||||
- case "uninstall":
|
||||
- uninstallService()
|
||||
- case "restart":
|
||||
- restartService()
|
||||
- default:
|
||||
- if util.IsRunInDocker() {
|
||||
- run()
|
||||
- } else {
|
||||
- s := getService()
|
||||
- status, _ := s.Status()
|
||||
- if status != service.StatusUnknown {
|
||||
- // 以服务方式运行
|
||||
- s.Run()
|
||||
- } else {
|
||||
- // 非服务方式运行
|
||||
- switch s.Platform() {
|
||||
- case "windows-service":
|
||||
- util.Log("可使用 .\\ddns-go.exe -s install 安装服务运行")
|
||||
- default:
|
||||
- util.Log("可使用 sudo ./ddns-go -s install 安装服务运行")
|
||||
- }
|
||||
- run()
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
|
||||
-func run() {
|
||||
// 兼容v5.0.0之前的配置文件
|
||||
conf, _ := config.GetConfigCached()
|
||||
conf.CompatibleConfig()
|
||||
@@ -164,130 +129,6 @@ func runWebServer() error {
|
||||
return http.Serve(l, nil)
|
||||
}
|
||||
|
||||
-type program struct{}
|
||||
-
|
||||
-func (p *program) Start(s service.Service) error {
|
||||
- // Start should not block. Do the actual work async.
|
||||
- go p.run()
|
||||
- return nil
|
||||
-}
|
||||
-func (p *program) run() {
|
||||
- run()
|
||||
-}
|
||||
-func (p *program) Stop(s service.Service) error {
|
||||
- // Stop should not block. Return with a few seconds.
|
||||
- return nil
|
||||
-}
|
||||
-
|
||||
-func getService() service.Service {
|
||||
- options := make(service.KeyValue)
|
||||
- var depends []string
|
||||
-
|
||||
- // 确保服务等待网络就绪后再启动
|
||||
- switch service.ChosenSystem().String() {
|
||||
- case "unix-systemv":
|
||||
- options["SysvScript"] = sysvScript
|
||||
- case "windows-service":
|
||||
- // 将 Windows 服务的启动类型设为自动(延迟启动)
|
||||
- options["DelayedAutoStart"] = true
|
||||
- default:
|
||||
- // 向 Systemd 添加网络依赖
|
||||
- depends = append(depends, "Requires=network.target",
|
||||
- "After=network-online.target")
|
||||
- }
|
||||
-
|
||||
- svcConfig := &service.Config{
|
||||
- Name: "ddns-go",
|
||||
- DisplayName: "ddns-go",
|
||||
- Description: "Simple and easy to use DDNS. Automatically update domain name resolution to public IP (Support Aliyun, Tencent Cloud, Dnspod, Cloudflare, Callback, Huawei Cloud, Baidu Cloud, Porkbun, GoDaddy...)",
|
||||
- Arguments: []string{"-l", *listen, "-f", strconv.Itoa(*every), "-cacheTimes", strconv.Itoa(*ipCacheTimes), "-c", *configFilePath},
|
||||
- Dependencies: depends,
|
||||
- Option: options,
|
||||
- }
|
||||
-
|
||||
- if *noWebService {
|
||||
- svcConfig.Arguments = append(svcConfig.Arguments, "-noweb")
|
||||
- }
|
||||
-
|
||||
- if *skipVerify {
|
||||
- svcConfig.Arguments = append(svcConfig.Arguments, "-skipVerify")
|
||||
- }
|
||||
-
|
||||
- if *customDNSServer != "" {
|
||||
- svcConfig.Arguments = append(svcConfig.Arguments, "-dns", *customDNSServer)
|
||||
- }
|
||||
-
|
||||
- prg := &program{}
|
||||
- s, err := service.New(prg, svcConfig)
|
||||
- if err != nil {
|
||||
- log.Fatalln(err)
|
||||
- }
|
||||
- return s
|
||||
-}
|
||||
-
|
||||
-// 卸载服务
|
||||
-func uninstallService() {
|
||||
- s := getService()
|
||||
- s.Stop()
|
||||
- if service.ChosenSystem().String() == "unix-systemv" {
|
||||
- if _, err := exec.Command("/etc/init.d/ddns-go", "stop").Output(); err != nil {
|
||||
- log.Println(err)
|
||||
- }
|
||||
- }
|
||||
- if err := s.Uninstall(); err == nil {
|
||||
- util.Log("ddns-go 服务卸载成功")
|
||||
- } else {
|
||||
- util.Log("ddns-go 服务卸载失败, 异常信息: %s", err)
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-// 安装服务
|
||||
-func installService() {
|
||||
- s := getService()
|
||||
-
|
||||
- status, err := s.Status()
|
||||
- if err != nil && status == service.StatusUnknown {
|
||||
- // 服务未知,创建服务
|
||||
- if err = s.Install(); err == nil {
|
||||
- s.Start()
|
||||
- util.Log("安装 ddns-go 服务成功! 请打开浏览器并进行配置")
|
||||
- if service.ChosenSystem().String() == "unix-systemv" {
|
||||
- if _, err := exec.Command("/etc/init.d/ddns-go", "enable").Output(); err != nil {
|
||||
- log.Println(err)
|
||||
- }
|
||||
- if _, err := exec.Command("/etc/init.d/ddns-go", "start").Output(); err != nil {
|
||||
- log.Println(err)
|
||||
- }
|
||||
- }
|
||||
- return
|
||||
- }
|
||||
- util.Log("安装 ddns-go 服务失败, 异常信息: %s", err)
|
||||
- }
|
||||
-
|
||||
- if status != service.StatusUnknown {
|
||||
- util.Log("ddns-go 服务已安装, 无需再次安装")
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-// 重启服务
|
||||
-func restartService() {
|
||||
- s := getService()
|
||||
- status, err := s.Status()
|
||||
- if err == nil {
|
||||
- if status == service.StatusRunning {
|
||||
- if err = s.Restart(); err == nil {
|
||||
- util.Log("重启 ddns-go 服务成功")
|
||||
- }
|
||||
- } else if status == service.StatusStopped {
|
||||
- if err = s.Start(); err == nil {
|
||||
- util.Log("启动 ddns-go 服务成功")
|
||||
- }
|
||||
- }
|
||||
- } else {
|
||||
- util.Log("ddns-go 服务未安装, 请先安装服务")
|
||||
- }
|
||||
-}
|
||||
-
|
||||
// 打开浏览器
|
||||
func autoOpenExplorer() {
|
||||
_, err := config.GetConfigCached()
|
||||
@@ -310,67 +151,3 @@ func autoOpenExplorer() {
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
-const sysvScript = `#!/bin/sh /etc/rc.common
|
||||
-DESCRIPTION="{{.Description}}"
|
||||
-cmd="{{.Path}}{{range .Arguments}} {{.|cmd}}{{end}}"
|
||||
-name="ddns-go"
|
||||
-pid_file="/var/run/$name.pid"
|
||||
-stdout_log="/var/log/$name.log"
|
||||
-stderr_log="/var/log/$name.err"
|
||||
-START=99
|
||||
-get_pid() {
|
||||
- cat "$pid_file"
|
||||
-}
|
||||
-is_running() {
|
||||
- [ -f "$pid_file" ] && cat /proc/$(get_pid)/stat > /dev/null 2>&1
|
||||
-}
|
||||
-start() {
|
||||
- if is_running; then
|
||||
- echo "Already started"
|
||||
- else
|
||||
- echo "Starting $name"
|
||||
- {{if .WorkingDirectory}}cd '{{.WorkingDirectory}}'{{end}}
|
||||
- $cmd >> "$stdout_log" 2>> "$stderr_log" &
|
||||
- echo $! > "$pid_file"
|
||||
- if ! is_running; then
|
||||
- echo "Unable to start, see $stdout_log and $stderr_log"
|
||||
- exit 1
|
||||
- fi
|
||||
- fi
|
||||
-}
|
||||
-stop() {
|
||||
- if is_running; then
|
||||
- echo -n "Stopping $name.."
|
||||
- kill $(get_pid)
|
||||
- for i in $(seq 1 10)
|
||||
- do
|
||||
- if ! is_running; then
|
||||
- break
|
||||
- fi
|
||||
- echo -n "."
|
||||
- sleep 1
|
||||
- done
|
||||
- echo
|
||||
- if is_running; then
|
||||
- echo "Not stopped; may still be shutting down or shutdown may have failed"
|
||||
- exit 1
|
||||
- else
|
||||
- echo "Stopped"
|
||||
- if [ -f "$pid_file" ]; then
|
||||
- rm "$pid_file"
|
||||
- fi
|
||||
- fi
|
||||
- else
|
||||
- echo "Not running"
|
||||
- fi
|
||||
-}
|
||||
-restart() {
|
||||
- stop
|
||||
- if is_running; then
|
||||
- echo "Unable to stop, will not attempt to start"
|
||||
- exit 1
|
||||
- fi
|
||||
- start
|
||||
-}
|
||||
-`
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,45 +0,0 @@
|
||||
From 23c717798d0bd247c7b8db6c822f134853c1ac43 Mon Sep 17 00:00:00 2001
|
||||
From: Puqns67 <me@puqns67.icu>
|
||||
Date: Sun, 3 Dec 2023 17:17:25 +0800
|
||||
Subject: [PATCH 1/2] build: remove update support for this build
|
||||
|
||||
---
|
||||
main.go | 8 --------
|
||||
1 file changed, 8 deletions(-)
|
||||
|
||||
diff --git a/main.go b/main.go
|
||||
index 3b36dc2..7617e5c 100644
|
||||
--- a/main.go
|
||||
+++ b/main.go
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/jeessy2/ddns-go/v6/config"
|
||||
"github.com/jeessy2/ddns-go/v6/dns"
|
||||
"github.com/jeessy2/ddns-go/v6/util"
|
||||
- "github.com/jeessy2/ddns-go/v6/util/update"
|
||||
"github.com/jeessy2/ddns-go/v6/web"
|
||||
"github.com/kardianos/service"
|
||||
)
|
||||
@@ -26,9 +25,6 @@ import (
|
||||
// ddns-go version
|
||||
var versionFlag = flag.Bool("v", false, "ddns-go version")
|
||||
|
||||
-// 更新 ddns-go
|
||||
-var updateFlag = flag.Bool("u", false, "Upgrade ddns-go to the latest version")
|
||||
-
|
||||
// 监听地址
|
||||
var listen = flag.String("l", ":9876", "Listen address")
|
||||
|
||||
@@ -68,10 +64,6 @@ func main() {
|
||||
fmt.Println(version)
|
||||
return
|
||||
}
|
||||
- if *updateFlag {
|
||||
- update.Self(version)
|
||||
- return
|
||||
- }
|
||||
if _, err := net.ResolveTCPAddr("tcp", *listen); err != nil {
|
||||
log.Fatalf("Parse listen address failed! Exception: %s", err)
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=DDNS-GO with default config, and web user interface
|
||||
Requires=network.target
|
||||
After=network-online.target
|
||||
Conflicts=ddns-go.service ddns-go@config.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/ddns-go -c /etc/ddns-go/config.yaml
|
||||
Restart=on-failure
|
||||
RestartSec=60
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=DDNS-GO with default config
|
||||
Requires=network.target
|
||||
After=network-online.target
|
||||
Conflicts=ddns-go@config.service ddns-go-web.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/ddns-go -noweb -c /etc/ddns-go/config.yaml
|
||||
Restart=on-failure
|
||||
RestartSec=60
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=DDNS-GO with config '%i'
|
||||
Requires=network.target
|
||||
After=network-online.target
|
||||
Conflicts=ddns-go.service ddns-go-web.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/ddns-go -noweb -c "/etc/ddns-go/%i.yaml"
|
||||
Restart=on-failure
|
||||
RestartSec=60
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
|
||||
<pkgmetadata>
|
||||
<maintainer type="person">
|
||||
<email>me@puqns67.icu</email>
|
||||
<name>Puqns67</name>
|
||||
</maintainer>
|
||||
<upstream>
|
||||
<bugs-to>https://github.com/jeessy2/ddns-go/issues</bugs-to>
|
||||
<remote-id type="github">jeessy2/ddns-go</remote-id>
|
||||
</upstream>
|
||||
<longdescription lang="en">
|
||||
Simple and easy to use DDNS. Automatically obtain your public IPv4
|
||||
or IPv6 address and resolve it to the corresponding domain name service.
|
||||
Support Aliyun, Tencent Cloud, Dnspod, Cloudflare, Callback,
|
||||
Huawei Cloud, Baidu Cloud, Porkbun, GoDaddy, Namecheap, NameSilo...
|
||||
</longdescription>
|
||||
<longdescription lang="zh">
|
||||
简单好用的 DDNS。自动获得你的公网 IPv4 或 IPv6 地址,并解析到对应的域名服务。
|
||||
支持阿里云 腾讯云 Dnspod Cloudflare 华为云 Callback 百度云
|
||||
Porkbun GoDaddy Google Domain Namecheap NameSilo...
|
||||
</longdescription>
|
||||
</pkgmetadata>
|
Loading…
x
Reference in New Issue
Block a user