Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
7676f3f5
Commit
7676f3f5
authored
3 years ago
by
David Levanon
Browse files
Options
Download
Email Patches
Plain Diff
move own ips to tcp stream factory
parent
aa17e11e
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tap/passive_tapper.go
+1
-10
tap/passive_tapper.go
tap/tcp_stream_factory.go
+14
-1
tap/tcp_stream_factory.go
with
15 additions
and
11 deletions
+15
-11
tap/passive_tapper.go
+
1
-
10
View file @
7676f3f5
...
...
@@ -91,7 +91,6 @@ type TapOpts struct {
}
//lint:ignore U1000 will be used in the future
var
ownIps
[]
string
// global
var
hostMode
bool
// global
var
extensions
[]
*
api
.
Extension
// global
var
filteringOptions
*
api
.
TrafficFilteringOptions
// global
...
...
@@ -202,17 +201,9 @@ func startPassiveTapper(outputItems chan *api.OutputChannelItem) {
tapErrors
=
NewErrorsMap
(
outputLevel
)
if
localhostIPs
,
err
:=
getLocalhostIPs
();
err
!=
nil
{
// TODO: think this over
rlog
.
Info
(
"Failed to get self IP addresses"
)
rlog
.
Errorf
(
"Getting-Self-Address"
,
"Error getting self ip address: %s (%v,%+v)"
,
err
,
err
,
err
)
ownIps
=
make
([]
string
,
0
)
}
else
{
ownIps
=
localhostIPs
}
var
handle
*
pcap
.
Handle
var
err
error
if
*
fname
!=
""
{
if
handle
,
err
=
pcap
.
OpenOffline
(
*
fname
);
err
!=
nil
{
log
.
Fatalf
(
"PCAP OpenOffline error: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
tap/tcp_stream_factory.go
+
14
-
1
View file @
7676f3f5
...
...
@@ -23,6 +23,7 @@ type tcpStreamFactory struct {
outboundLinkWriter
*
OutboundLinkWriter
Emitter
api
.
Emitter
streamsMap
*
tcpStreamMap
ownIps
[]
string
}
type
tcpStreamWrapper
struct
{
...
...
@@ -31,9 +32,21 @@ type tcpStreamWrapper struct {
}
func
NewTcpStreamFactory
(
emitter
api
.
Emitter
,
streamsMap
*
tcpStreamMap
)
*
tcpStreamFactory
{
var
ownIps
[]
string
if
localhostIPs
,
err
:=
getLocalhostIPs
();
err
!=
nil
{
// TODO: think this over
rlog
.
Info
(
"Failed to get self IP addresses"
)
rlog
.
Errorf
(
"Getting-Self-Address"
,
"Error getting self ip address: %s (%v,%+v)"
,
err
,
err
,
err
)
ownIps
=
make
([]
string
,
0
)
}
else
{
ownIps
=
localhostIPs
}
return
&
tcpStreamFactory
{
Emitter
:
emitter
,
streamsMap
:
streamsMap
,
ownIps
:
ownIps
,
}
}
...
...
@@ -150,7 +163,7 @@ func (factory *tcpStreamFactory) getStreamProps(srcIP string, srcPort string, ds
//lint:ignore U1000 will be used in the future
func
(
factory
*
tcpStreamFactory
)
shouldNotifyOnOutboundLink
(
dstIP
string
,
dstPort
int
)
bool
{
if
inArrayInt
(
remoteOnlyOutboundPorts
,
dstPort
)
{
isDirectedHere
:=
inArrayString
(
ownIps
,
dstIP
)
isDirectedHere
:=
inArrayString
(
factory
.
ownIps
,
dstIP
)
return
!
isDirectedHere
&&
!
isPrivateIP
(
dstIP
)
}
return
true
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help