Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
957dfbb0
Commit
957dfbb0
authored
Jun 21, 2019
by
Eric
Committed by
Eric_Lee
Jun 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update]更新asset的API数据获取
parent
4b65f008
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
assets.go
pkg/model/assets.go
+24
-24
No files found.
pkg/model/assets.go
View file @
957dfbb0
...
...
@@ -76,21 +76,21 @@ func assetSortByHostName(asset1, asset2 *Asset) bool {
type
NodeList
[]
Node
type
Asset
struct
{
ID
string
`json:"id"`
Hostname
string
`json:"hostname"`
IP
string
`json:"ip"`
Port
int
`json:"port"`
SystemUsers
[]
SystemUser
`json:"system_users_granted"`
IsActive
bool
`json:"is_active"`
SystemUsersJoin
string
`json:"system_users_join"`
Os
string
`json:"os"`
Domain
string
`json:"domain"`
Platform
string
`json:"platform"`
Comment
string
`json:"comment"`
Protocol
string
`json:"protocol"`
Protocols
[]
protocolItem
`json:"protocols,omitempty"`
OrgID
string
`json:"org_id"`
OrgName
string
`json:"org_name"`
ID
string
`json:"id"`
Hostname
string
`json:"hostname"`
IP
string
`json:"ip"`
Port
int
`json:"port"`
SystemUsers
[]
SystemUser
`json:"system_users_granted"`
IsActive
bool
`json:"is_active"`
SystemUsersJoin
string
`json:"system_users_join"`
Os
string
`json:"os"`
Domain
string
`json:"domain"`
Platform
string
`json:"platform"`
Comment
string
`json:"comment"`
Protocol
string
`json:"protocol"`
Protocols
[]
string
`json:"protocols,omitempty"`
OrgID
string
`json:"org_id"`
OrgName
string
`json:"org_name"`
}
func
(
a
*
Asset
)
ProtocolPort
(
protocol
string
)
int
{
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment