]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 添加配置ip路径
authorqydysky <qydysky@foxmail.com>
Sat, 24 Aug 2024 01:18:01 +0000 (09:18 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 24 Aug 2024 01:18:01 +0000 (09:18 +0800)
.github/workflows/go.yml
.github/workflows/test.yml
CV/Var.go
README.md
bili_danmu.go
demo/config/config_K_v.json
go.mod
go.sum

index 70650b2cb728c26228159ae070ac17608c0b6b1a..d910ec0e2c481b206c20b5f3a5efbe292b74a425 100644 (file)
@@ -13,7 +13,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -53,7 +53,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -93,7 +93,7 @@ jobs:
     runs-on: windows-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -133,7 +133,7 @@ jobs:
     runs-on: macos-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
index ded2844e699cf421bfdfa24e69afd28170f31b9f..bd24079a1aa10d61af5aa0f9f22fee05e1c15473 100644 (file)
@@ -16,7 +16,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -56,7 +56,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -96,7 +96,7 @@ jobs:
     runs-on: windows-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
@@ -135,7 +135,7 @@ jobs:
     runs-on: macos-latest
     strategy:
       matrix:
-        go: [ '1.22' ]
+        go: [ '1.23' ]
     steps:
     - name: Set up Go${{ matrix.go }}
       uses: actions/setup-go@v5
index 5fc160d4482ee56722c0674152026c51e0d5d6bc..38a655044acd7cf9e25f7b3f0c1550eb45b44c5a 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -30,6 +30,7 @@ import (
        reqf "github.com/qydysky/part/reqf"
        psql "github.com/qydysky/part/sql"
        syncmap "github.com/qydysky/part/sync"
+       sys "github.com/qydysky/part/sys"
        web "github.com/qydysky/part/web"
        _ "modernc.org/sqlite"
 )
@@ -428,6 +429,27 @@ func (t *Common) Init() *Common {
                        panic(e)
                }
 
+               port := `80`
+               if s := strings.Split(serAdress, ":"); len(s) > 1 {
+                       port = s[1]
+               }
+
+               var ips []string
+               {
+                       // 启动时显示ip
+                       showIpOnBoot, _ := t.K_v.LoadV("启动时显示ip").(bool)
+                       for ip := range sys.GetIpByCidr() {
+                               if showIpOnBoot {
+                                       if ip.To4() != nil {
+                                               fmt.Printf("当前地址 http://%s:%s\n", ip.String(), port)
+                                       } else {
+                                               fmt.Printf("当前地址 http://[%s]:%s\n", ip.String(), port)
+                                       }
+                               }
+                               ips = append(ips, ip.String())
+                       }
+               }
+
                var (
                        readTimeout       = 3
                        readHeaderTimeout = 3
@@ -467,6 +489,19 @@ func (t *Common) Init() *Common {
                        }
                }
 
+               if val, ok := t.K_v.LoadV("ip路径").(string); ok && val != "" {
+                       t.SerF.Store(val, func(w http.ResponseWriter, r *http.Request) {
+                               if DefaultHttpCheck(t, w, r, http.MethodGet) {
+                                       return
+                               }
+                               for _, v := range ips {
+                                       if _, e := w.Write([]byte(v + "\n")); e != nil {
+                                               return
+                                       }
+                               }
+                       })
+               }
+
                if val, ok := t.K_v.LoadV("性能路径").(string); ok && val != "" {
                        var cache web.Cache
                        t.SerF.Store(val, func(w http.ResponseWriter, r *http.Request) {
index 2c4cef3ccce9a21a9127dd78e2fbc488f963df5d..f1df838a8f4fed7992bef0b56ac24cec71e1dcc2 100644 (file)
--- a/README.md
+++ b/README.md
 ### 说明
 本项目使用github action自动构建,构建过程详见[yml](https://github.com/qydysky/bili_danmu/blob/master/.github/workflows/go.yml)
 
+#### ip路径
+配置文件中添加配置项`ip路径`(>v0.14.16)。不为空时,将会在指定路径显示出当前主机ip,从而可以使用主机名来获取主机ipv6,以便于[ddns-go](https://github.com/jeessy2/ddns-go)等通过命令获取ipv6。默认空。
+
+例子:
+```
+{
+  "Web服务地址":"0.0.0.0:11000",
+  "ip路径":"/ip/"
+}
+```
+
+```
+curl -s http://{主机名}:11000/ip/
+192.168.31.230
+172.16.0.1
+172.17.144.244
+172.17.0.1
+172.17.0.10
+172.17.121.35
+2409:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:8ce5
+fd55:d4a5:a9e7:0:aab8:e0ff:fe03:8ce5
+fe80::aab8:e0ff:fe03:8ce5
+fe80::d8dc:35ff:fe21:d71b
+fe80::785f:8dff:fe34:9443
+fe80::440a:9fff:fe6d:5da6
+fe80::60ff:4cff:fee7:c226
+fe80::4c24:e3ff:fe65:b955
+fe80::8099:ecff:fefa:f36c
+fe80::68fe:63ff:fe74:6e35
+```
+
+```
+curl -s http://{主机名}:11000/ip/ | awk '/240:?/'
+
+2409:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:8ce5
+```
+
 #### 保持粉丝牌点亮
 配置文件中添加配置项`保持牌子亮着_指定时间`(>v0.14.11)。将会在指定时间启动保持。默认`00:00:00`
 
index efbbd95b14f57adfa6af4cba635c07cd1669d7a2..55b0ba05ddc4a13767a212c8f49edde9f1d5b28a 100644 (file)
@@ -74,13 +74,6 @@ func Start() {
                }
        }()
 
-       // 启动时显示ip
-       if v, ok := c.C.K_v.LoadV("启动时显示ip").(bool); ok && v {
-               for _, v := range sys.GetIntranetIp(``) {
-                       danmulog.L(`I: `, `当前ip:http://`+v)
-               }
-       }
-
        {
                //如果连接中断,则等待
                F.KeepConnect()
index e46f2d022d0b8efa7b1a27d1044548c62087255f..7d56ca6bf84191687be820dcd3cf83f3e5c7ee09 100644 (file)
     "debug路径":"",
     "性能路径-help":"当Web服务地址不为空时, 访问此路径可以获取性能信息,为空时关闭",
     "性能路径":"/state/",
+    "ip路径":"",
     "生成pgo-help":"将在退出后生成pgo文件在指定路径,default.pgo将有助于下次构建的优化,但会导致gc频繁,构建缓慢,为空时不生成",
     "生成pgo":"",
     "登陆二维码-白":"OO",
diff --git a/go.mod b/go.mod
index e38d58231a404db1527b1ef8a0eced5e16d7df76..f0cc28e29a285327144075c02c790824b87babdb 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.23
 require (
        github.com/gotk3/gotk3 v0.6.4
        github.com/mdp/qrterminal/v3 v3.2.0
-       github.com/qydysky/part v0.28.20240821214546
+       github.com/qydysky/part v0.28.20240823183215
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
        github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
        golang.org/x/text v0.17.0
diff --git a/go.sum b/go.sum
index ec666ce852b1f8ef8434c80bfa0d3c8626c1b77b..82f2b1906aedba83631202c88ad259264e1718db 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -46,8 +46,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/qydysky/biliApi v0.0.0-20240725184407-15076dddb6fb h1:dtSpNF9hLQa09TUfR+xbYFkHcx2breAFsXeU7e599gE=
 github.com/qydysky/biliApi v0.0.0-20240725184407-15076dddb6fb/go.mod h1:om024vfxALQ5vxsbaGoMm8IS0esLYBnEOpJI8FsGoDg=
-github.com/qydysky/part v0.28.20240821214546 h1:MtOxggPvVKa9t24QhxxDuIxuuSjJUCaAwVCJRsN+gWs=
-github.com/qydysky/part v0.28.20240821214546/go.mod h1:lv0lIlm2keVMdwnOzXdRCUL8Ky8HoAAYw8coaBW6rb8=
+github.com/qydysky/part v0.28.20240823183215 h1:irnWS/3QsVDrx8xSoFtmxkkyVPzFhnyvBFTf6mwCMpk=
+github.com/qydysky/part v0.28.20240823183215/go.mod h1:lv0lIlm2keVMdwnOzXdRCUL8Ky8HoAAYw8coaBW6rb8=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=