Skip to content

Commit 6568f76

Browse files
committed
添加一个gateway-go用于提供没有公网用户的备用选择
1 parent eee1bf3 commit 6568f76

5 files changed

Lines changed: 51 additions & 3 deletions

File tree

.github/workflows/build_OpenListLib_libs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- name: Setup web
4141
run: |
4242
go get github.com/jeessy2/ddns-go/v6
43+
go get github.com/OpenIoTHub/gateway-go/v2
4344
bash build.sh dev web
4445
env:
4546
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -113,6 +114,7 @@ jobs:
113114
- name: Setup web
114115
run: |
115116
go get github.com/jeessy2/ddns-go/v6
117+
go get github.com/OpenIoTHub/gateway-go/v2
116118
bash build.sh dev web
117119
env:
118120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build_OpenListLib_libs_release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- name: Setup web
2323
run: |
2424
go get github.com/jeessy2/ddns-go/v6
25+
go get github.com/OpenIoTHub/gateway-go/v2
2526
bash build.sh dev web
2627
env:
2728
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -59,7 +60,7 @@ jobs:
5960
build/linux/libmobile_arm64.so
6061
build/windows/mobile_amd64.dll
6162
gomobile-libs-android:
62-
needs: linux-android-windows-libs
63+
# needs: linux-android-windows-libs
6364
runs-on: macos-latest
6465
steps:
6566
- name: Checkout
@@ -73,6 +74,7 @@ jobs:
7374
- name: Setup web
7475
run: |
7576
go get github.com/jeessy2/ddns-go/v6
77+
go get github.com/OpenIoTHub/gateway-go/v2
7678
bash build.sh dev web
7779
env:
7880
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

libs/mobile/api.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ func RunAPIServer() {
8080
"message": "success",
8181
})
8282
})
83+
r.GET("/start-ddns-go", func(c *gin.Context) {
84+
runDdnsGo()
85+
c.JSON(http.StatusOK, gin.H{
86+
"code": 0,
87+
"message": "success",
88+
})
89+
})
90+
r.GET("/start-gateway-go", func(c *gin.Context) {
91+
runGatewayGO()
92+
c.JSON(http.StatusOK, gin.H{
93+
"code": 0,
94+
"message": "success",
95+
})
96+
})
8397
err := r.Run("0.0.0.0:15244")
8498
if err != nil {
8599
log.Println(err.Error())

libs/mobile/ddns-go.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ var staticEmbeddedFiles embed.FS
2222
//go:embed favicon.ico
2323
var faviconEmbeddedFile embed.FS
2424

25+
// 默认开启
2526
func init() {
26-
go run()
27+
go runDdnsGo()
2728
}
2829

29-
func run() {
30+
func runDdnsGo() {
31+
log.Println("Start ddns-go service")
3032
// 兼容之前的配置文件
3133
conf, _ := config.GetConfigCached()
3234
conf.CompatibleConfig()

libs/mobile/gateway-go.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package mobile
2+
3+
import (
4+
"github.com/OpenIoTHub/gateway-go/v2/client"
5+
"github.com/OpenIoTHub/gateway-go/v2/register"
6+
"log"
7+
"net"
8+
)
9+
10+
//只可以由用户开启
11+
//func init() {
12+
// runGatewayGO()
13+
//}
14+
15+
func runGatewayGO() {
16+
log.Println("Start gateway-go service")
17+
register.RegisterService("localhost",
18+
"gateway-go",
19+
"_http._tcp",
20+
"localhost",
21+
5244,
22+
[]string{},
23+
0,
24+
[]net.IP{net.ParseIP("127.0.0.1")},
25+
[]net.IP{},
26+
)
27+
client.Run()
28+
}

0 commit comments

Comments
 (0)