Skip to content

Commit

Permalink
🐛 修复 IPv6 only 机器取 IP 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed May 23, 2021
1 parent 7d5ea7a commit 1c35caf
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 251 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<div align="center" style="background-color: white">
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
<br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.7.1&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.0-brightgreen?style=for-the-badge&logo=linux">
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.7.2&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.0-brightgreen?style=for-the-badge&logo=linux">
<br>
<p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
</div>

\>> 交流论坛:[打杂社区](https://daza.net/c/nezha) (Lemmy)

\>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器**
\>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器**<br>
群友互助/服务器交流,作者不答疑,找 naiba 请至论坛发帖

\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒监控%7C哪吒面板"&filter=0) (Google)

Expand All @@ -22,17 +23,18 @@

```shell
curl -sSL https://raw.githubusercontent.com/naiba/nezha/master/script/fetch.sh | bash
/opt/nezha/nezha.sh
sudo /opt/nezha/nezha.sh
```

国内镜像加速:

```shell
curl -sSL https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/fetch.sh | CN=true bash
CN=true /opt/nezha/nezha.sh
CN=true sudo /opt/nezha/nezha.sh
```

再次运行仅需:

```
/opt/nezha/nezha.sh
```
Expand Down Expand Up @@ -284,4 +286,4 @@ restart() {
- [哪吒探针 - Windows 客户端安装](https://nyko.me/2020/12/13/nezha-windows-client.html)
- [哪吒监控,一个便携服务器状态监控面板搭建教程,不想拥有一个自己的探针吗?](https://haoduck.com/644.html)
- [哪吒监控:小鸡们的最佳探针](https://www.zhujizixun.com/2843.html) _(已过时)_
- [>>更多教程](https://www.google.com/search?q="哪吒"%2B"面板%7C监控%7C探针"+"教程") (Google)
- [>>更多教程](https://www.google.com/search?q="哪吒"%2B"面板%7C监控%7C探针"+"教程") (Google)
7 changes: 6 additions & 1 deletion cmd/agent/monitor/myip.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ func resolveIP(addr string, ipv6 bool) (string, error) {
}
m.RecursionDesired = true

dnsServer := "2606:4700:4700::1111"
if !ipv6 {
dnsServer = "1.1.1.1"
}

c := new(dns.Client)
r, _, err := c.Exchange(m, net.JoinHostPort("1.1.1.1", "53"))
r, _, err := c.Exchange(m, net.JoinHostPort(dnsServer, "53"))
if err != nil {
return "", err
}
Expand Down
Loading

0 comments on commit 1c35caf

Please sign in to comment.