opt: standard upf output

This commit is contained in:
2024-04-16 16:32:24 +08:00
parent 7a70d76eb2
commit 18e6b0ed8d
5 changed files with 56 additions and 26 deletions

View File

@@ -51,16 +51,24 @@ var (
CustomUriOmMmlInt = config.UriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
)
var TIME_DELAY_AFTER_WRITE time.Duration = 200
var TIME_DEAD_LINE time.Duration = 10
var (
TIME_DELAY_AFTER_WRITE time.Duration = 200
TIME_DEAD_LINE time.Duration = 10
WIN_ROW_SIZE byte = 100
WIN_COL_SIZE byte = 100
BUFFER_SIZE int = 65535
)
func init() {
func InitMML() {
if config.GetYamlConfig().MML.Sleep != 0 {
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)
}
WIN_ROW_SIZE = config.GetYamlConfig().MML.SizeRow
WIN_COL_SIZE = config.GetYamlConfig().MML.SizeCol
BUFFER_SIZE = config.GetYamlConfig().MML.BufferSize
}
func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
@@ -78,8 +86,7 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
return
}
var buf [100 * 1024]byte
//buf := make([]byte, 0)
buf := make([]byte, BUFFER_SIZE)
var n int
var mmlResult []string
port2 := 5002
@@ -90,6 +97,7 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
if neInfo != nil {
hostMML := fmt.Sprintf("%s:%d", neInfo.Ip, port2)
conn, err := net.Dial("tcp", hostMML)
//conn, err := net.Dial("tcp", hostMML)
if err != nil {
errMsg := fmt.Sprintf("Failed to dial %s: %v", hostMML, err)
log.Error(errMsg)
@@ -110,6 +118,9 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
// services.ResponseWithJson(w, http.StatusOK, response)
// return
// }
// 发送窗口大小设置命令
conn.Write([]byte{255, 251, 31}) // 发送WILL WINDOW SIZE
conn.Write([]byte{255, 250, 31, 0, WIN_ROW_SIZE, 0, WIN_COL_SIZE, 255, 240}) // 发送SB WINDOW SIZE
conn.SetDeadline(time.Now().Add(TIME_DEAD_LINE * time.Second))
loginStr := fmt.Sprintf("%s\n%s\n", config.GetYamlConfig().MML.User, config.GetYamlConfig().MML.Password)