Skip to content

Commit

Permalink
Fix ssh command bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
KrxkGit committed Nov 4, 2023
1 parent 2fe4a6c commit d1a09ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion SSHCommand/RunSSH.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,21 @@ func (s *SSHClass) RunSetNetwork(ip string, dnsArr string, netmask, gateway stri
cmd += fmt.Sprintf(" && uci set %sndp=relay", if4)
cmd += fmt.Sprintf(" && uci set %smaster=1", if4)

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

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

log.Info("Delete lan IPV6 Assign")
if6 := "/etc/config/network.lan."
cmd += fmt.Sprintf(" && uci set %sip6assign=60", if6) // 用于保证选项存在
cmd += fmt.Sprintf(" && uci delete %sip6assign", if6)

cmd += fmt.Sprintf(" && service network restart")
s.RunCommand(cmd)
log.Info("SetNetwork finished")
Expand Down
6 changes: 3 additions & 3 deletions ScutLog.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"time":"2023-11-04T17:29:19.0832432+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"55","message":"ssh: handshake failed: EOF"}
{"time":"2023-11-04T17:29:19.1396842+08:00","level":"ERROR","prefix":"-","file":"RunSSH.go","line":"35","message":"Dial Fails: ssh: handshake failed: EOF"}
{"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"}
{"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."}
{"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."}
{"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 comments on commit d1a09ec

Please sign in to comment.