Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
OpnSense
Commits
ca9dfd03
Commit
ca9dfd03
authored
Apr 14, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(network insight) add protocols and services to api
parent
2ca714d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
NetworkinsightController.php
...ers/OPNsense/Diagnostics/Api/NetworkinsightController.php
+37
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetworkinsightController.php
View file @
ca9dfd03
...
...
@@ -168,4 +168,41 @@ class NetworkinsightController extends ApiControllerBase
}
return
$allInterfaces
;
}
/**
* return known protocols
*/
public
function
getProtocolsAction
()
{
$result
=
array
();
foreach
(
explode
(
"
\n
"
,
file_get_contents
(
'/etc/protocols'
))
as
$line
)
{
if
(
strlen
(
$line
)
>
1
&&
$line
[
0
]
!=
'#'
)
{
$parts
=
preg_split
(
'/\s+/'
,
$line
);
if
(
count
(
$parts
)
>=
4
)
{
$result
[
$parts
[
1
]]
=
$parts
[
0
];
}
}
}
return
$result
;
}
/**
* return known services
*/
public
function
getServicesAction
()
{
$result
=
array
();
foreach
(
explode
(
"
\n
"
,
file_get_contents
(
'/etc/services'
))
as
$line
)
{
if
(
strlen
(
$line
)
>
1
&&
$line
[
0
]
!=
'#'
)
{
// there a few ports which have different names for different protocols, but to not overcomplicate
// things here, we ignore those exceptions.
$parts
=
preg_split
(
'/\s+/'
,
$line
);
if
(
count
(
$parts
)
>=
2
)
{
$portnum
=
explode
(
'/'
,
trim
(
$parts
[
1
]))[
0
];
$result
[
$portnum
]
=
$parts
[
0
];
}
}
}
return
$result
;
}
}
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