Commit 957dfbb0 authored by Eric's avatar Eric Committed by Eric_Lee

[update]更新asset的API数据获取

parent 4b65f008
......@@ -88,7 +88,7 @@ type Asset struct {
Platform string `json:"platform"`
Comment string `json:"comment"`
Protocol string `json:"protocol"`
Protocols []protocolItem `json:"protocols,omitempty"`
Protocols []string `json:"protocols,omitempty"`
OrgID string `json:"org_id"`
OrgName string `json:"org_name"`
}
......@@ -99,8 +99,13 @@ func (a *Asset) ProtocolPort(protocol string) int {
return a.Port
}
for _, item := range a.Protocols {
if strings.ToLower(item.Name) == strings.ToLower(protocol) {
return item.Port
if strings.Contains(strings.ToLower(item), strings.ToLower(protocol)) {
proAndPort := strings.Split(item, "/")
if len(proAndPort) == 2 {
if port, err := strconv.Atoi(proAndPort[1]); err == nil {
return port
}
}
}
}
switch strings.ToLower(protocol) {
......@@ -120,18 +125,13 @@ func (a *Asset) IsSupportProtocol(protocol string) bool {
return a.Protocol == protocol
}
for _, item := range a.Protocols {
if strings.ToLower(item.Name) == strings.ToLower(protocol) {
if strings.Contains(strings.ToLower(item), strings.ToLower(protocol)) {
return true
}
}
return false
}
type protocolItem struct {
Name string `json:"name"`
Port int `json:"port"`
}
type Gateway struct {
ID string `json:"id"`
Name string `json:"Name"`
......@@ -333,7 +333,7 @@ func (sf *SystemUserFilterRule) Pattern() *regexp.Regexp {
func (sf *SystemUserFilterRule) Match(cmd string) (RuleAction, string) {
pattern := sf.Pattern()
if pattern == nil{
if pattern == nil {
return ActionUnknown, ""
}
found := pattern.FindString(cmd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment