Skip to content

Commit 9b23ede

Browse files
committed
download: modify check update api version
1 parent 41809c3 commit 9b23ede

11 files changed

Lines changed: 72 additions & 89 deletions

File tree

.github/workflows/buildapp.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ jobs:
9797
needs: [build_win, build_linux, build_darwin]
9898
steps:
9999
- name: Download artifacts
100-
uses: actions/download-artifact@v3
100+
uses: actions/download-artifact@v5
101101
with:
102102
name: mirouter-ui-win
103103
path: ./build
104104
- name: Download artifacts
105-
uses: actions/download-artifact@v3
105+
uses: actions/download-artifact@v5
106106
with:
107107
name: mirouter-ui-linux
108108
path: ./build
109109
- name: Download artifacts
110-
uses: actions/download-artifact@v3
110+
uses: actions/download-artifact@v5
111111
with:
112112
name: mirouter-ui-darwin
113113
path: ./build

.github/workflows/buildappwhr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ jobs:
9999
needs: [build_win, build_linux, build_darwin]
100100
steps:
101101
- name: Download artifacts
102-
uses: actions/download-artifact@v3
102+
uses: actions/download-artifact@v5
103103
with:
104104
name: mirouter-ui-win
105105
path: ./build
106106
- name: Download artifacts
107-
uses: actions/download-artifact@v3
107+
uses: actions/download-artifact@v5
108108
with:
109109
name: mirouter-ui-linux
110110
path: ./build
111111
- name: Download artifacts
112-
uses: actions/download-artifact@v3
112+
uses: actions/download-artifact@v5
113113
with:
114114
name: mirouter-ui-darwin
115115
path: ./build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ aa.sh
66
static/*
77
mirouter-ui.exe
88
database.db
9+
config.yaml

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ then
6161
# Building darwin_amd64
6262
echo "Building darwin_amd64"
6363
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION main.go
64-
upx --best -o $OUTPUT_DIR/mirouterui_darwin_amd64_$VERSION $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION
64+
upx --force-macos --best -o $OUTPUT_DIR/mirouterui_darwin_amd64_$VERSION $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION
6565

6666
# Building darwin_arm64
6767
echo "Building darwin_arm64"
6868
GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION main.go
69-
upx --best -o $OUTPUT_DIR/mirouterui_darwin_arm64_$VERSION $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION
69+
upx --force-macos --best -o $OUTPUT_DIR/mirouterui_darwin_arm64_$VERSION $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION
7070
fi

config.example.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 路由器设备配置
2+
dev:
3+
- password: "" # 路由器密码
4+
key: "a2ffa5c9be07488bbb04a3a47d3c5f6a" # 路由器密钥
5+
ip: "192.168.31.1" # 路由器IP地址
6+
islocal: false # 是否为本地模式
7+
8+
# 历史记录配置
9+
history:
10+
enable: true # 是否启用历史记录
11+
maxsaved: 3000 # 最大保存记录数
12+
sampletime: 300 # 采样时间(秒)
13+
14+
# 应用配置
15+
debug: true # 调试模式
16+
port: 6789 # 服务端口
17+
address: "0.0.0.0" # 监听地址
18+
tiny: false # 精简模式
19+
flushTokenTime: 1800 # Token刷新时间(秒)
20+
safemode: true # 安全模式
21+
api_key: "" # 认证令牌

config.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

main.go

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
// _ "net/http/pprof"
1717
"os"
18-
"os/exec"
1918
"os/signal"
2019
"path/filepath"
2120
"strconv"
@@ -29,35 +28,24 @@ import (
2928
)
3029

3130
var (
32-
password string
33-
key string
34-
token string
35-
tokens map[int]string
36-
debug bool
37-
port int
38-
routerName string
39-
routerNames map[int]string
40-
hardware string
41-
hardwares map[int]string
42-
isLocals map[int]bool
43-
tiny bool
44-
routerunit bool
45-
dev []config.Dev
46-
cpu_cmd *exec.Cmd
47-
w24g_cmd *exec.Cmd
48-
w5g_cmd *exec.Cmd
49-
configPath string
50-
workdirectory string
51-
Version string
52-
databasepath string
53-
flushTokenTime int
54-
maxsaved int
55-
historyEnable bool
56-
sampletime int
57-
netdata_routernum int
58-
safemode bool
59-
api_key string
60-
address string
31+
tokens map[int]string
32+
debug bool
33+
port int
34+
routerNames map[int]string
35+
hardwares map[int]string
36+
isLocals map[int]bool
37+
tiny bool
38+
dev []config.Dev
39+
workdirectory string
40+
Version string
41+
databasepath string
42+
flushTokenTime int
43+
maxsaved int
44+
historyEnable bool
45+
sampletime int
46+
safemode bool
47+
api_key string
48+
address string
6149
)
6250

6351
type Config struct {
@@ -84,7 +72,6 @@ func init() {
8472
historyEnable = cfg.History.Enable
8573
sampletime = cfg.History.Sampletime
8674
flushTokenTime = cfg.FlushTokenTime
87-
netdata_routernum = cfg.Netdata_routernum
8875
workdirectory = cfg.Workdirectory
8976
databasepath = cfg.Databasepath
9077
safemode = cfg.SafeMode
@@ -288,7 +275,7 @@ func main() {
288275

289276
// switch chart {
290277
// case "system.cpu":
291-
// if routerunits[netdata_routernum] {
278+
// if onrouters[netdata_routernum] {
292279
// cpuLoad = int(GetCpuPercent() * 100)
293280
// }
294281
// data := netdata.GenerateArray("system.cpu", cpuLoad, starttime, "system.cpu", "system.cpu")

modules/config/base.go

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import (
1515
)
1616

1717
type Dev struct {
18-
Password string `mapstructure:"password"`
19-
Key string `mapstructure:"key"`
20-
IP string `mapstructure:"ip"`
21-
RouterUnit bool `mapstructure:"routerunit"`
22-
IsLocal bool `mapstructure:"islocal"`
18+
Password string `mapstructure:"password"`
19+
Key string `mapstructure:"key"`
20+
IP string `mapstructure:"ip"`
21+
IsLocal bool `mapstructure:"islocal"`
2322
}
2423

2524
type History struct {
@@ -29,18 +28,17 @@ type History struct {
2928
}
3029

3130
type AppConfig struct {
32-
Dev []Dev `mapstructure:"dev"`
33-
History History `mapstructure:"history"`
34-
Debug bool `mapstructure:"debug"`
35-
Port int `mapstructure:"port"`
36-
Address string `mapstructure:"address"`
37-
Tiny bool `mapstructure:"tiny"`
38-
FlushTokenTime int `mapstructure:"flushTokenTime"`
39-
Netdata_routernum int `mapstructure:"netdata_routernum"`
40-
Workdirectory string `mapstructure:"-"`
41-
Databasepath string `mapstructure:"-"`
42-
ApiKey string `mapstructure:"api_key"`
43-
SafeMode bool `mapstructure:"safemode"`
31+
Dev []Dev `mapstructure:"dev"`
32+
History History `mapstructure:"history"`
33+
Debug bool `mapstructure:"debug"`
34+
Port int `mapstructure:"port"`
35+
Address string `mapstructure:"address"`
36+
Tiny bool `mapstructure:"tiny"`
37+
FlushTokenTime int `mapstructure:"flushTokenTime"`
38+
Workdirectory string `mapstructure:"-"`
39+
Databasepath string `mapstructure:"-"`
40+
ApiKey string `mapstructure:"api_key"`
41+
SafeMode bool `mapstructure:"safemode"`
4442
}
4543

4644
var (
@@ -71,11 +69,10 @@ func LoadConfig() (*AppConfig, error) {
7169
// Set default values
7270
v.SetDefault("dev", []Dev{
7371
{
74-
Password: "",
75-
Key: "a2ffa5c9be07488bbb04a3a47d3c5f6a",
76-
IP: "192.168.31.1",
77-
RouterUnit: false,
78-
IsLocal: false,
72+
Password: "",
73+
Key: "a2ffa5c9be07488bbb04a3a47d3c5f6a",
74+
IP: "192.168.31.1",
75+
IsLocal: false,
7976
},
8077
})
8178
v.SetDefault("history.enable", false)
@@ -85,7 +82,6 @@ func LoadConfig() (*AppConfig, error) {
8582
v.SetDefault("port", 6789)
8683
v.SetDefault("tiny", false)
8784
v.SetDefault("flushTokenTime", 1800)
88-
v.SetDefault("netdata_routernum", 0)
8985
v.SetDefault("api_key", "")
9086
v.SetDefault("safemode", true)
9187
v.SetDefault("address", "0.0.0.0")

modules/database/base.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ type DeviceInfo struct {
5555
}
5656

5757
type Dev struct {
58-
Password string `json:"password"`
59-
Key string `json:"key"`
60-
IP string `json:"ip"`
61-
RouterUnit bool `json:"routerunit"`
58+
Password string `json:"password"`
59+
Key string `json:"key"`
60+
IP string `json:"ip"`
6261
}
6362

6463
// CheckDatabase checks the SQLite database file at the given path.

modules/download/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func DownloadStatic(workdirectory string, force bool, checkupdate bool) error {
5050

5151
// Check for updates
5252
if checkupdate {
53-
resp, err := http.Get("https://mrui-api.hzchu.top/v2/api/checkupdate")
53+
resp, err := http.Get("https://mrui-api.hzchu.top/v3/api/checkupdate")
5454

5555
if err != nil {
5656
logrus.Info("Failed to get update information, skipping check")

0 commit comments

Comments
 (0)