@@ -56,7 +56,7 @@ func (a *App) systemTray() {
56
56
57
57
func (a * App ) testPing () {
58
58
a .PingAll ()
59
- tick := time .Tick (time .Second * 60 )
59
+ tick := time .Tick (time .Second * 5 )
60
60
for range tick {
61
61
a .PingAll ()
62
62
}
@@ -86,18 +86,17 @@ func (a *App) startup(ctx context.Context) {
86
86
rdata , err2 := httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db.sha256sum" )
87
87
if err2 == nil {
88
88
sum256 := sha256 .Sum256 (file )
89
- fmt .Println (fmt .Sprintf ("%x" , sum256 ), string (rdata ))
90
89
if fmt .Sprintf ("%x" , sum256 ) != string (rdata ) {
91
90
rdata , err2 = httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db" )
92
91
if err2 == nil {
93
- _ = os .WriteFile (geoPath , rdata , 0644 )
92
+ _ = os .WriteFile (geoPath , rdata , 0o644 )
94
93
}
95
94
}
96
95
}
97
96
} else {
98
97
rdata , err2 := httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db" )
99
98
if err2 == nil {
100
- _ = os .WriteFile (geoPath , rdata , 0644 )
99
+ _ = os .WriteFile (geoPath , rdata , 0o644 )
101
100
}
102
101
}
103
102
geoPath = fmt .Sprintf ("%s%c%s%c%s" , home , os .PathSeparator , ".gpp" , os .PathSeparator , "geosite.db" )
@@ -106,24 +105,26 @@ func (a *App) startup(ctx context.Context) {
106
105
rdata , err2 := httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db.sha256sum" )
107
106
if err2 == nil {
108
107
sum256 := sha256 .Sum256 (file )
109
- fmt .Println (fmt .Sprintf ("%x" , sum256 ), string (rdata ))
110
108
if fmt .Sprintf ("%x" , sum256 ) != string (rdata ) {
111
109
rdata , err2 = httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db" )
112
110
if err2 == nil {
113
- _ = os .WriteFile (geoPath , rdata , 0644 )
111
+ _ = os .WriteFile (geoPath , rdata , 0o644 )
114
112
}
115
113
}
116
114
}
117
115
} else {
118
116
rdata , err2 := httpGet ("https://mirror.ghproxy.com/https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db" )
119
117
if err2 == nil {
120
- _ = os .WriteFile (geoPath , rdata , 0644 )
118
+ _ = os .WriteFile (geoPath , rdata , 0o644 )
121
119
}
122
120
}
123
121
}
124
122
func (a * App ) PingAll () {
125
123
group := sync.WaitGroup {}
126
124
for i := range a .conf .PeerList {
125
+ if a .conf .PeerList [i ].Protocol == "direct" {
126
+ continue
127
+ }
127
128
group .Add (1 )
128
129
peer := a .conf .PeerList [i ]
129
130
go func () {
@@ -160,16 +161,31 @@ func (a *App) Add(token string) string {
160
161
}
161
162
err , peer := config .ParsePeer (token )
162
163
if err != nil {
164
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
165
+ Type : runtime .ErrorDialog ,
166
+ Title : "导入错误" ,
167
+ Message : err .Error (),
168
+ })
163
169
return err .Error ()
164
170
}
165
171
for _ , p := range a .conf .PeerList {
166
172
if p .Name == peer .Name {
173
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
174
+ Type : runtime .ErrorDialog ,
175
+ Title : "导入错误" ,
176
+ Message : fmt .Sprintf ("节点 %s 已存在" , peer .Name ),
177
+ })
167
178
return fmt .Sprintf ("peer %s already exists" , peer .Name )
168
179
}
169
180
}
170
181
a .conf .PeerList = append (a .conf .PeerList , peer )
171
182
err = config .SaveConfig (a .conf )
172
183
if err != nil {
184
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
185
+ Type : runtime .ErrorDialog ,
186
+ Title : "导入错误" ,
187
+ Message : err .Error (),
188
+ })
173
189
return err .Error ()
174
190
}
175
191
return "ok"
@@ -211,10 +227,20 @@ func (a *App) Start() string {
211
227
var err error
212
228
a .box , err = client .Client (a .gamePeer , a .httpPeer , a .processList )
213
229
if err != nil {
230
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
231
+ Type : runtime .ErrorDialog ,
232
+ Title : "加速失败" ,
233
+ Message : err .Error (),
234
+ })
214
235
return err .Error ()
215
236
}
216
237
err = a .box .Start ()
217
238
if err != nil {
239
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
240
+ Type : runtime .ErrorDialog ,
241
+ Title : "加速失败" ,
242
+ Message : err .Error (),
243
+ })
218
244
return err .Error ()
219
245
}
220
246
return "ok"
@@ -227,6 +253,11 @@ func (a *App) Stop() string {
227
253
}
228
254
err := a .box .Close ()
229
255
if err != nil {
256
+ _ , _ = runtime .MessageDialog (a .ctx , runtime.MessageDialogOptions {
257
+ Type : runtime .ErrorDialog ,
258
+ Title : "停止失败" ,
259
+ Message : err .Error (),
260
+ })
230
261
return err .Error ()
231
262
}
232
263
a .box = nil
0 commit comments