Skip to content

Commit da077b5

Browse files
authored
Merge pull request #138 from michael-mri/master
Make sure BPF filter applies to all interfaces
2 parents 336013e + d0a4ec8 commit da077b5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/pyshark/capture/live_capture.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from pyshark.capture.capture import Capture
22
from pyshark.tshark.tshark import get_tshark_interfaces
3+
import sys
34

5+
# Define basestring as str if we're in python3.
6+
if sys.version_info >= (3, 0):
7+
basestring = str
48

59
class LiveCapture(Capture):
610
"""
@@ -45,10 +49,10 @@ def get_parameters(self, packet_count=None):
4549
Returns the special tshark parameters to be used according to the configuration of this class.
4650
"""
4751
params = super(LiveCapture, self).get_parameters(packet_count=packet_count)
48-
for interface in self.interfaces:
49-
params += ['-i', interface]
5052
if self.bpf_filter:
5153
params += ['-f', self.bpf_filter]
54+
for interface in self.interfaces:
55+
params += ['-i', interface]
5256
return params
5357

5458
# Backwards compatibility

src/pyshark/capture/live_ring_capture.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,5 @@ def get_parameters(self, packet_count=None):
4040
Returns the special tshark parameters to be used according to the configuration of this class.
4141
"""
4242
params = super(LiveRingCapture, self).get_parameters(packet_count=packet_count)
43-
for interface in self.interfaces:
44-
params += ['-i', interface]
45-
if self.bpf_filter:
46-
params += ['-f', self.bpf_filter]
4743
params += ['-b', 'filesize:' + str(self.ring_file_size), '-b', 'files:' + str(self.num_ring_files), '-w', self.ring_file_name, '-P']
4844
return params

0 commit comments

Comments
 (0)