]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 动态获取ip
authorqydysky <qydysky@foxmail.com>
Sun, 25 Aug 2024 02:42:23 +0000 (10:42 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 25 Aug 2024 02:42:23 +0000 (10:42 +0800)
CV/Var.go

index 38a655044acd7cf9e25f7b3f0c1550eb45b44c5a..497027c0ab4735fd105a26a2447877d9684ce1e5 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -434,7 +434,6 @@ func (t *Common) Init() *Common {
                        port = s[1]
                }
 
-               var ips []string
                {
                        // 启动时显示ip
                        showIpOnBoot, _ := t.K_v.LoadV("启动时显示ip").(bool)
@@ -446,7 +445,6 @@ func (t *Common) Init() *Common {
                                                fmt.Printf("当前地址 http://[%s]:%s\n", ip.String(), port)
                                        }
                                }
-                               ips = append(ips, ip.String())
                        }
                }
 
@@ -494,8 +492,8 @@ func (t *Common) Init() *Common {
                                if DefaultHttpCheck(t, w, r, http.MethodGet) {
                                        return
                                }
-                               for _, v := range ips {
-                                       if _, e := w.Write([]byte(v + "\n")); e != nil {
+                               for ip := range sys.GetIpByCidr() {
+                                       if _, e := w.Write([]byte(ip.String() + "\n")); e != nil {
                                                return
                                        }
                                }