Skip to content

Commit d1a09ec

Browse files
committed
Fix ssh command bugs
1 parent 2fe4a6c commit d1a09ec

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

SSHCommand/RunSSH.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,21 @@ func (s *SSHClass) RunSetNetwork(ip string, dnsArr string, netmask, gateway stri
221221
cmd += fmt.Sprintf(" && uci set %sndp=relay", if4)
222222
cmd += fmt.Sprintf(" && uci set %smaster=1", if4)
223223

224-
cmd += fmt.Sprintf(" && uci delete %sdns", if4)
224+
cmd += fmt.Sprintf(" && uci add_list %sdns=::1", if4) // 此行必须添加,否则可能因为不存在list而导致错误
225+
cmd += fmt.Sprintf(" && uci add_list %sdns=::2", if4) // 此行必须添加,否则可能因为不存在list而导致错误
226+
cmd += fmt.Sprintf(" && uci delete %sdns", if4) // 使用delete命令删除整个列表
225227
cmd += fmt.Sprintf(" && uci add_list %sdns=2606:4700:4700::1111", if4)
226228
cmd += fmt.Sprintf(" && uci add_list %sdns=2001:4860:4860::8888", if4)
227229

228230
log.Info("Set dhcp wan")
229231
if5 := "/etc/config/dhcp.wan." // dhcp wan
230232
cmd += fmt.Sprintf(" && uci set %signore=1", if5)
231233

234+
log.Info("Delete lan IPV6 Assign")
235+
if6 := "/etc/config/network.lan."
236+
cmd += fmt.Sprintf(" && uci set %sip6assign=60", if6) // 用于保证选项存在
237+
cmd += fmt.Sprintf(" && uci delete %sip6assign", if6)
238+
232239
cmd += fmt.Sprintf(" && service network restart")
233240
s.RunCommand(cmd)
234241
log.Info("SetNetwork finished")

ScutLog.log

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{"time":"2023-11-04T17:29:19.0832432+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"55","message":"ssh: handshake failed: EOF"}
2-
{"time":"2023-11-04T17:29:19.1396842+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"35","message":"Dial Fails: ssh: handshake failed: EOF"}
3-
{"time":"2023-11-04T17:29:19.1396842+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"67","message":"New Session Fails: ssh: handshake failed: EOF"}
1+
{"time":"2023-11-04T21:23:32.4961224+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"55","message":"dial tcp 192.168.1.101:22: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."}
2+
{"time":"2023-11-04T21:23:32.5106611+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"35","message":"Dial Fails: dial tcp 192.168.1.101:22: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."}
3+
{"time":"2023-11-04T21:23:32.5106611+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"67","message":"New Session Fails: dial tcp 192.168.1.101:22: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."}

0 commit comments

Comments
 (0)