fix:continue if error command

This commit is contained in:
2024-02-21 19:10:10 +08:00
parent b815d2c6fb
commit fdb3c2fbf6

View File

@@ -24,6 +24,7 @@ import (
// const ( // const (
// //经过测试linux下延时需要大于100ms // //经过测试linux下延时需要大于100ms
// TIME_DELAY_AFTER_WRITE = 200 // TIME_DELAY_AFTER_WRITE = 200
// TIME_DEAD_LINE = 10
// ) // )
type Response struct { type Response struct {
@@ -48,14 +49,17 @@ var (
CustomUriOmMmlInt = config.UriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}" CustomUriOmMmlInt = config.UriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
) )
// func init() { var TIME_DELAY_AFTER_WRITE time.Duration = 200
// if config.GetYamlConfig().MML.Sleep != 0 { var TIME_DEAD_LINE time.Duration = 10
// TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep)
// } func init() {
// if config.GetYamlConfig().MML.DeadLine != 0 { if config.GetYamlConfig().MML.Sleep != 0 {
// TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine) TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep)
// } }
// } if config.GetYamlConfig().MML.DeadLine != 0 {
TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine)
}
}
func PostMMLToNF(w http.ResponseWriter, r *http.Request) { func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
log.Debug("PostMMLToNF processing... ") log.Debug("PostMMLToNF processing... ")
@@ -66,14 +70,14 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
return return
} }
// 经过测试linux下延时需要大于100ms // 经过测试linux下延时需要大于100ms
var TIME_DELAY_AFTER_WRITE time.Duration = 200 // var TIME_DELAY_AFTER_WRITE time.Duration = 200
var TIME_DEAD_LINE time.Duration = 10 // var TIME_DEAD_LINE time.Duration = 10
if config.GetYamlConfig().MML.Sleep != 0 { // if config.GetYamlConfig().MML.Sleep != 0 {
TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep) // TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep)
} // }
if config.GetYamlConfig().MML.DeadLine != 0 { // if config.GetYamlConfig().MML.DeadLine != 0 {
TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine) // TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine)
} // }
pack := "mml" pack := "mml"
vars := mux.Vars(r) vars := mux.Vars(r)
@@ -330,7 +334,7 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
services.ResponseWithJson(w, http.StatusOK, response) services.ResponseWithJson(w, http.StatusOK, response)
return return
} }
log.Debug(string(buf[0:n])) log.Trace(string(buf[0:n]))
_, err = conn.Write([]byte(config.GetYamlConfig().MML.Password + "\r\n")) _, err = conn.Write([]byte(config.GetYamlConfig().MML.Password + "\r\n"))
if err != nil { if err != nil {
@@ -402,7 +406,6 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
//re2 := regexp.MustCompile(`\x00`) // 匹配空字符 //re2 := regexp.MustCompile(`\x00`) // 匹配空字符
re2 := regexp.MustCompile(`[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x1B]`) // 匹配空字符和包含␛的控制字符 re2 := regexp.MustCompile(`[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x1B]`) // 匹配空字符和包含␛的控制字符
//re := regexp.MustCompile(`[\x00-\x1F\x7F]`) //re := regexp.MustCompile(`[\x00-\x1F\x7F]`)
// upf telnet buffer只能读取一次需要去掉前面的多余字符
result := re1.ReplaceAllString(string(buf[0:n-len(neType)-2]), "") result := re1.ReplaceAllString(string(buf[0:n-len(neType)-2]), "")
result = re2.ReplaceAllString(result, "") result = re2.ReplaceAllString(result, "")
mmlResult = append(mmlResult, result) mmlResult = append(mmlResult, result)
@@ -540,7 +543,7 @@ func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
hostUri := fmt.Sprintf("http://%s:%s", neInfo.Ip, neInfo.Port) hostUri := fmt.Sprintf("http://%s:%s", neInfo.Ip, neInfo.Port)
omcMmlVar := &mmlp.MmlVar{ omcMmlVar := &mmlp.MmlVar{
Version: "16.1.1", Version: global.Version,
Output: mmlp.DefaultFormatType, Output: mmlp.DefaultFormatType,
MmlHome: config.GetYamlConfig().MML.MmlHome, MmlHome: config.GetYamlConfig().MML.MmlHome,
Limit: 50, Limit: 50,