Skip to content

Commit

Permalink
v1.3.4 d: 一堆小修小补
Browse files Browse the repository at this point in the history
  • Loading branch information
yzy613 committed Jun 22, 2021
1 parent a16286c commit 5a209fb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- 自动将域名解析到动态 IP(支持 IPv6)

### 用法
- `./ddns-watchdog-client -init string` 有选择地初始化配置文件,可以组合使用 (例 01)
- `./ddns-watchdog-client -i string` 有选择地初始化配置文件,可以组合使用 (例`./ddns-watchdog-client -i 01`)
```
0 -> client.json
1 -> dnspod.json
Expand All @@ -39,15 +39,15 @@
- `./ddns-watchdog-client` 直接运行
- `./ddns-watchdog-client -conf_path string` 指定配置文件路径 (最好是绝对路径)(路径有空格请放在双引号中间)
- `./ddns-watchdog-client -c string` 指定配置文件路径 (最好是绝对路径)(路径有空格请放在双引号中间)
- `./ddns-watchdog-client -install` 安装服务
- `./ddns-watchdog-client -I` 安装服务 (对于 Linux)
- `./ddns-watchdog-client -uninstall` 卸载服务
- `./ddns-watchdog-client -U` 卸载服务 (对于 Linux)
- `./ddns-watchdog-client -f` 强制检查 DNS 解析记录
- `./ddns-watchdog-client -version` 查看当前版本并检查更新
- `./ddns-watchdog-client -v` 查看当前版本并检查更新
### 第一次使用?
- 前往 [releases](https://github.com/yzy613/ddns-watchdog/releases) 选择下载符合自己系统的压缩包,解压得到二进制文件
Expand All @@ -56,15 +56,15 @@
- 在 Linux 上不要忘记程序需要执行权限 `chmod 755 ddns-watchdog-client`
- 使用 `./ddns-watchdog-client -init string` 初始化配置文件(在 Windows 上使用 [ddns-watchdog-client-startup-script.bat](https://github.com/yzy613/ddns-watchdog/blob/master/ddns-watchdog-client-startup-script.bat) 一气呵成)
- 使用 `./ddns-watchdog-client -i string` 初始化配置文件(在 Windows 上使用 [ddns-watchdog-client-startup-script.bat](https://github.com/yzy613/ddns-watchdog/blob/master/ddns-watchdog-client-startup-script.bat) 一气呵成)
- 默认获取的是 IPv4,若需 IPv6,请在 `./conf/client.json` 修改 `api_url` 为 `https://yzyweb.cn/ddns-watchdog6`(此方法会优先使用临时 IPv6 地址)
- 若需使用网卡的 IP 地址,请在 `./conf/client.json` 修改 `enable_network_card` 为 `true` 并运行一次程序自动获取网卡信息,从 `./conf/network_card.json` 里面选择一个网卡填入 `./conf/client.json` 的 `network_card`
- 按照 [支持的服务商](https://github.com/yzy613/ddns-watchdog#%E6%94%AF%E6%8C%81%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%95%86) 进行配置
- 若需配置不同域名的 ddns-watchdog,可以结合 `-conf_path string` 启动参数配置多种配置文件(可搭配 `-init` 启动参数初始化配置文件)
- 若需配置不同域名的 ddns-watchdog,可以结合 `-c string` 启动参数配置多种配置文件(可搭配 `-i` 启动参数初始化配置文件)
- 如果域名解析更新成功,那么程序工作正常,可以在 `./conf/client.json` 启用 `check_cycle` 进行定期检查(单位:分钟)(默认为 0,意为不启用定期检查)
Expand All @@ -74,7 +74,7 @@
### 可选操作
- 在 Linux 上
1. 使用 `./ddns-watchdog-client -install` 安装服务,就可以使用 `systemctl` 管理 ddns-watchdog-client 服务了
1. 使用 `./ddns-watchdog-client -I` 安装服务,就可以使用 `systemctl` 管理 ddns-watchdog-client 服务了
- 在 Windows 上
1. [ddns-watchdog-client-startup-script.bat](https://github.com/yzy613/ddns-watchdog/blob/master/ddns-watchdog-client-startup-script.bat) 直接运行程序并回显程序返回的信息(需与 ddns-watchdog-client.exe 同一文件夹)
Expand Down Expand Up @@ -143,17 +143,17 @@
- 返回 Json 格式的客户端 IP(支持 IPv6)
### 服务端 用法
- `./ddns-watchdog-server -install` 安装服务 (已经包含 `-init` 启动参数)
- `./ddns-watchdog-server -I` 安装服务 (已经包含 `-i` 启动参数)
- `./ddns-watchdog-server -conf_path string` 指定配置文件路径 (最好是绝对路径)(路径有空格请放在双引号中间)
- `./ddns-watchdog-server -c string` 指定配置文件路径 (最好是绝对路径)(路径有空格请放在双引号中间)
- `./ddns-watchdog-server -init` 初始化配置文件
- `./ddns-watchdog-server -i` 初始化配置文件
- `systemctl start ddns-watchdog-server` 启动服务
- `./ddns-watchdog-server -uninstall` 卸载服务
- `./ddns-watchdog-server -U` 卸载服务
- `./ddns-watchdog-server -version` 查看当前版本并检查更新
- `./ddns-watchdog-server -v` 查看当前版本并检查更新
## 安装
### Arch Linux
Expand Down
11 changes: 7 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ import (
"strings"
)

var (
const (
RunningName = "ddns-watchdog-client"
RunningPath = common.GetRunningPath()
InstallPath = "/etc/systemd/system/" + RunningName + ".service"
ConfPath = RunningPath + "conf/"
ConfFileName = "client.json"
DNSPodConfFileName = "dnspod.json"
AliDNSConfFileName = "alidns.json"
CloudflareConfFileName = "cloudflare.json"
NetworkCardFileName = "network_card.json"
)

var (
RunningPath = common.GetRunningPath()
InstallPath = "/etc/systemd/system/" + RunningName + ".service"
ConfPath = RunningPath + "conf/"
)

func Install() (err error) {
if common.IsWindows() {
log.Println("Windows 暂不支持安装到系统")
Expand Down
2 changes: 1 addition & 1 deletion main-code/client/ddns-watchdog-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var (
installOption = flag.Bool("I", false, "安装服务")
uninstallOption = flag.Bool("u", false, "卸载服务")
uninstallOption = flag.Bool("U", false, "卸载服务")
enforcement = flag.Bool("f", false, "强制检查 DNS 解析记录")
version = flag.Bool("v", false, "查看当前版本并检查更新")
initOption = flag.String("i", "", "有选择地初始化配置文件,可以组合使用 (例 01)\n"+
Expand Down
14 changes: 7 additions & 7 deletions main-code/server/ddns-watchdog-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
)

var (
installOption = flag.Bool("install", false, "安装服务")
uninstallOption = flag.Bool("uninstall", false, "卸载服务")
version = flag.Bool("version", false, "查看当前版本并检查更新")
confPath = flag.String("conf_path", "", "手动设置配置文件路径(绝对路径)(有空格用双引号)")
initOption = flag.Bool("init", false, "初始化配置文件")
installOption = flag.Bool("I", false, "安装服务")
uninstallOption = flag.Bool("U", false, "卸载服务")
version = flag.Bool("v", false, "查看当前版本并检查更新")
confPath = flag.String("c", "", "手动设置配置文件路径(绝对路径)(有空格用双引号)")
initOption = flag.Bool("i", false, "初始化配置文件")
)

func main() {
Expand Down Expand Up @@ -61,7 +61,7 @@ func main() {

// 加载配置
conf := server.ServerConf{}
err := common.LoadAndUnmarshal(server.ConfPath+"/server.json", &conf)
err := common.LoadAndUnmarshal(server.ConfPath+server.ConfFileName, &conf)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func RunInit() (err error) {
conf.Port = ":10032"
conf.IsRoot = false
conf.RootServerAddr = "https://yzyweb.cn/ddns-watchdog"
err = common.MarshalAndSave(conf, server.ConfPath+"/server.json")
err = common.MarshalAndSave(conf, server.ConfPath+server.ConfFileName)
if err != nil {
return
}
Expand Down
8 changes: 6 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import (
"strings"
)

const (
RunningName = "ddns-watchdog-server"
ConfFileName = "server.json"
)

var (
RunningName = "ddns-watchdog-server"
RunningPath = common.GetRunningPath()
InstallPath = "/etc/systemd/system/" + RunningName + ".service"
ConfPath = RunningPath + "conf/"
Expand Down Expand Up @@ -91,7 +95,7 @@ func Install() (err error) {
"After=network.target\n\n" +
"[Service]\n" +
"Type=simple\n" +
"ExecStart=" + RunningPath + RunningName + " -conf_path " + ConfPath +
"ExecStart=" + RunningPath + RunningName + " -c " + ConfPath +
"\nRestart=on-failure\n" +
"RestartSec=2\n\n" +
"[Install]\n" +
Expand Down

0 comments on commit 5a209fb

Please sign in to comment.