diff --git a/src/modules/ne_data/controller/udm_auth.go b/src/modules/ne_data/controller/udm_auth.go index 3c5582c8..22b12b3e 100644 --- a/src/modules/ne_data/controller/udm_auth.go +++ b/src/modules/ne_data/controller/udm_auth.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "be.ems/src/framework/cmd" "be.ems/src/framework/constants" "be.ems/src/framework/i18n" "be.ems/src/framework/reqctx" @@ -692,8 +693,8 @@ func (s *UDMAuthController) ExportDec(c *gin.Context) { // 发送MML // 导出解密的ki和opc 需要执行 dec authdat:imsi=all // 生成文件 /user/local/etc/udm/authdata.txt - cmd := "dec authdat:imsi=all" - data, err := telnet.ConvertToStr(telnetClient, cmd) + cmdStr := "dec authdat:imsi=all" + data, err := telnet.ConvertToStr(telnetClient, cmdStr) if err != nil { c.JSON(200, resp.ErrMsg(err.Error())) return @@ -701,32 +702,17 @@ func (s *UDMAuthController) ExportDec(c *gin.Context) { // 命令ok时 if strings.Contains(data, "ok") { - // 网元主机的SSH客户端 - sshClient, err := s.neInfoService.NeRunSSHClient("UDM", neId) - if err != nil { - c.JSON(200, resp.ErrMsg(err.Error())) - return - } - defer sshClient.Close() - // 网元主机的SSH客户端进行文件传输 - sftpClient, err := sshClient.NewClientSFTP() - if err != nil { - c.JSON(200, resp.ErrMsg(err.Error())) - return - } - defer sftpClient.Close() - // 复制到本地 nePath := "/usr/local/etc/udm/authdata.txt" localFilePath := filepath.Join("/tmp/omc/pull", filepath.Base(nePath)) if runtime.GOOS == "windows" { localFilePath = fmt.Sprintf("C:%s", localFilePath) } - if err = sftpClient.CopyFileRemoteToLocal(nePath, localFilePath); err != nil { + if err = file.CopyFile(nePath, localFilePath); err != nil { c.JSON(200, resp.ErrMsg(err.Error())) return } - sshClient.RunCMD(fmt.Sprintf("sudo rm -rf %s", nePath)) + cmd.Exec(fmt.Sprintf("sudo rm -rf %s", nePath)) defer os.Remove(localFilePath) c.FileAttachment(localFilePath, filepath.Base(nePath)) return diff --git a/src/modules/trace/service/tcpdump.go b/src/modules/trace/service/tcpdump.go index 0a73e96e..ec4d5f20 100644 --- a/src/modules/trace/service/tcpdump.go +++ b/src/modules/trace/service/tcpdump.go @@ -224,11 +224,11 @@ func (s *TCPdump) UPFTrace(neType, neId, cmdStr string) (string, error) { return "", fmt.Errorf("app.common.noNEInfo") } // 网元主机的SSH客户端 - sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId) - if err != nil { - return "", err - } - defer sshClient.Close() + // sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId) + // if err != nil { + // return "", err + // } + // defer sshClient.Close() // 网元主机的Telnet客户端 telnetClient, err := s.neInfoService.NeRunTelnetClient("UPF", neInfo.NeId, 2) if err != nil {