opt: standard upf output
This commit is contained in:
@@ -73,6 +73,9 @@ mml:
|
|||||||
port2: 5002
|
port2: 5002
|
||||||
sleep: 200
|
sleep: 200
|
||||||
deadLine: 10
|
deadLine: 10
|
||||||
|
sizeRow: 100
|
||||||
|
sizeCol: 128
|
||||||
|
bufferSize: 65535
|
||||||
user: admin
|
user: admin
|
||||||
password: admin
|
password: admin
|
||||||
mmlHome: ./mmlhome
|
mmlHome: ./mmlhome
|
||||||
|
|||||||
@@ -51,16 +51,24 @@ var (
|
|||||||
CustomUriOmMmlInt = config.UriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
|
CustomUriOmMmlInt = config.UriPrefix + "/omManagement/{apiVersion}/mml/{neType}/{neId}"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TIME_DELAY_AFTER_WRITE time.Duration = 200
|
var (
|
||||||
var TIME_DEAD_LINE time.Duration = 10
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
|
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) {
|
func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -78,8 +86,7 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf [100 * 1024]byte
|
buf := make([]byte, BUFFER_SIZE)
|
||||||
//buf := make([]byte, 0)
|
|
||||||
var n int
|
var n int
|
||||||
var mmlResult []string
|
var mmlResult []string
|
||||||
port2 := 5002
|
port2 := 5002
|
||||||
@@ -90,6 +97,7 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
if neInfo != nil {
|
if neInfo != nil {
|
||||||
hostMML := fmt.Sprintf("%s:%d", neInfo.Ip, port2)
|
hostMML := fmt.Sprintf("%s:%d", neInfo.Ip, port2)
|
||||||
conn, err := net.Dial("tcp", hostMML)
|
conn, err := net.Dial("tcp", hostMML)
|
||||||
|
//conn, err := net.Dial("tcp", hostMML)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := fmt.Sprintf("Failed to dial %s: %v", hostMML, err)
|
errMsg := fmt.Sprintf("Failed to dial %s: %v", hostMML, err)
|
||||||
log.Error(errMsg)
|
log.Error(errMsg)
|
||||||
@@ -110,6 +118,9 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
// services.ResponseWithJson(w, http.StatusOK, response)
|
// services.ResponseWithJson(w, http.StatusOK, response)
|
||||||
// return
|
// 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))
|
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)
|
loginStr := fmt.Sprintf("%s\n%s\n", config.GetYamlConfig().MML.User, config.GetYamlConfig().MML.Password)
|
||||||
|
|||||||
@@ -11,17 +11,6 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DbConfig struct {
|
|
||||||
Type string `yaml:"type"`
|
|
||||||
User string `yaml:"user"`
|
|
||||||
Password string `yaml:"password"`
|
|
||||||
Host string `yaml:"host"`
|
|
||||||
Port string `yaml:"port"`
|
|
||||||
Name string `yaml:"name"`
|
|
||||||
ConnParam string `yaml:"connParam,omitempty"`
|
|
||||||
Backup string `yaml:"backup"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yaml struct of config
|
// Yaml struct of config
|
||||||
type YamlConfig struct {
|
type YamlConfig struct {
|
||||||
Logger struct {
|
Logger struct {
|
||||||
@@ -110,16 +99,7 @@ type YamlConfig struct {
|
|||||||
} `yaml:"smsc"`
|
} `yaml:"smsc"`
|
||||||
} `yaml:"alarm"`
|
} `yaml:"alarm"`
|
||||||
|
|
||||||
MML struct {
|
MML MMLParam `yaml:"mml"`
|
||||||
Port int `yaml:"port"`
|
|
||||||
Port2 int `yaml:"port2"`
|
|
||||||
Sleep int64 `yaml:"sleep"`
|
|
||||||
DeadLine int64 `yaml:"deadLine"`
|
|
||||||
User string `yaml:"user"`
|
|
||||||
Password string `ymal:"password"`
|
|
||||||
MmlHome string `yaml:"mmlHome"`
|
|
||||||
Upload string `yaml:"upload"`
|
|
||||||
} `yaml:"mml"`
|
|
||||||
|
|
||||||
NE struct {
|
NE struct {
|
||||||
Addr string `yaml:"addr"`
|
Addr string `yaml:"addr"`
|
||||||
@@ -171,6 +151,31 @@ type RestParam struct {
|
|||||||
KeyFile string `yaml:"keyFile"`
|
KeyFile string `yaml:"keyFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DbConfig struct {
|
||||||
|
Type string `yaml:"type"`
|
||||||
|
User string `yaml:"user"`
|
||||||
|
Password string `yaml:"password"`
|
||||||
|
Host string `yaml:"host"`
|
||||||
|
Port string `yaml:"port"`
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
ConnParam string `yaml:"connParam,omitempty"`
|
||||||
|
Backup string `yaml:"backup"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MMLParam struct {
|
||||||
|
Port int `yaml:"port"`
|
||||||
|
Port2 int `yaml:"port2"`
|
||||||
|
Sleep int64 `yaml:"sleep"`
|
||||||
|
DeadLine int64 `yaml:"deadLine"`
|
||||||
|
SizeRow byte `yaml:"sizeRow"`
|
||||||
|
SizeCol byte `yaml:"sizeCol"`
|
||||||
|
BufferSize int `yaml:"bufferSize"`
|
||||||
|
User string `yaml:"user"`
|
||||||
|
Password string `ymal:"password"`
|
||||||
|
MmlHome string `yaml:"mmlHome"`
|
||||||
|
Upload string `yaml:"upload"`
|
||||||
|
}
|
||||||
|
|
||||||
type TestDatas struct {
|
type TestDatas struct {
|
||||||
UDM struct {
|
UDM struct {
|
||||||
CapUsed uint32 `yaml:"capUsed"`
|
CapUsed uint32 `yaml:"capUsed"`
|
||||||
@@ -211,6 +216,11 @@ func NewYamlConfig() YamlConfig {
|
|||||||
Type: "mysql",
|
Type: "mysql",
|
||||||
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True",
|
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True",
|
||||||
},
|
},
|
||||||
|
MML: MMLParam{
|
||||||
|
SizeRow: 100,
|
||||||
|
SizeCol: 128,
|
||||||
|
BufferSize: 65535,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ mml:
|
|||||||
port2: 5002
|
port2: 5002
|
||||||
sleep: 200
|
sleep: 200
|
||||||
deadLine: 10
|
deadLine: 10
|
||||||
|
sizeRow: 100
|
||||||
|
sizeCol: 128
|
||||||
|
bufferSize: 65535
|
||||||
user: admin
|
user: admin
|
||||||
password: admin
|
password: admin
|
||||||
mmlHome: ./mmlhome
|
mmlHome: ./mmlhome
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"be.ems/features/event"
|
"be.ems/features/event"
|
||||||
"be.ems/features/fm"
|
"be.ems/features/fm"
|
||||||
"be.ems/features/lm"
|
"be.ems/features/lm"
|
||||||
|
"be.ems/features/mml"
|
||||||
"be.ems/features/pm"
|
"be.ems/features/pm"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
@@ -227,6 +228,8 @@ func main() {
|
|||||||
os.Exit(4)
|
os.Exit(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mml.InitMML()
|
||||||
|
|
||||||
// 将 mux.Router 注册到 gin.Engine
|
// 将 mux.Router 注册到 gin.Engine
|
||||||
|
|
||||||
// 默认路由组
|
// 默认路由组
|
||||||
|
|||||||
Reference in New Issue
Block a user