Skip to content

Commit

Permalink
Added eventloop parameter to capture classes
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiNewt committed Aug 11, 2018
1 parent 4b49197 commit 6311e3e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/pyshark/capture/file_capture.py
Expand Up @@ -15,7 +15,7 @@ class FileCapture(Capture):
def __init__(self, input_file=None, keep_packets=True, display_filter=None, only_summaries=False,
decryption_key=None, encryption_type='wpa-pwk', decode_as=None,
disable_protocol=None, tshark_path=None, override_prefs=None,
use_json=False, output_file=None, include_raw=False):
use_json=False, output_file=None, include_raw=False, eventloop=None):
"""
Creates a packet capture object by reading from file.
Expand All @@ -41,7 +41,7 @@ def __init__(self, input_file=None, keep_packets=True, display_filter=None, only
decryption_key=decryption_key, encryption_type=encryption_type,
decode_as=decode_as, disable_protocol=disable_protocol, tshark_path=tshark_path,
override_prefs=override_prefs, use_json=use_json, output_file=output_file,
include_raw=include_raw)
include_raw=include_raw, eventloop=eventloop)
self.input_filename = input_file
if not isinstance(input_file, basestring):
self.input_filename = input_file.name
Expand Down
4 changes: 2 additions & 2 deletions src/pyshark/capture/inmem_capture.py
Expand Up @@ -24,7 +24,7 @@ class InMemCapture(Capture):
def __init__(self, bpf_filter=None, display_filter=None, only_summaries=False,
decryption_key=None, encryption_type='wpa-pwk', decode_as=None,
disable_protocol=None, tshark_path=None, override_prefs=None, use_json=False,
linktype=LinkTypes.ETHERNET, include_raw=False):
linktype=LinkTypes.ETHERNET, include_raw=False, eventloop=None):
"""
Creates a new in-mem capture, a capture capable of receiving binary packets and parsing them using tshark.
Significantly faster if packets are added in a batch.
Expand All @@ -47,7 +47,7 @@ def __init__(self, bpf_filter=None, display_filter=None, only_summaries=False,
decryption_key=decryption_key, encryption_type=encryption_type,
decode_as=decode_as, disable_protocol=disable_protocol,
tshark_path=tshark_path, override_prefs=override_prefs,
use_json=use_json, include_raw=include_raw)
use_json=use_json, include_raw=include_raw, eventloop=eventloop)
self.bpf_filter = bpf_filter
self._packets_to_write = None
self._current_linktype = linktype
Expand Down
6 changes: 4 additions & 2 deletions src/pyshark/capture/live_capture.py
Expand Up @@ -18,7 +18,8 @@ class LiveCapture(Capture):

def __init__(self, interface=None, bpf_filter=None, display_filter=None, only_summaries=False, decryption_key=None,
encryption_type='wpa-pwk', output_file=None, decode_as=None, disable_protocol=None, tshark_path=None,
override_prefs=None, capture_filter=None, monitor_mode=None, use_json=False, include_raw=False):
override_prefs=None, capture_filter=None, monitor_mode=None, use_json=False, include_raw=False,
eventloop=None):
"""
Creates a new live capturer on a given interface. Does not start the actual capture itself.
Expand All @@ -44,7 +45,8 @@ def __init__(self, interface=None, bpf_filter=None, display_filter=None, only_su
decryption_key=decryption_key, encryption_type=encryption_type,
output_file=output_file, decode_as=decode_as, disable_protocol=disable_protocol,
tshark_path=tshark_path, override_prefs=override_prefs,
capture_filter=capture_filter, use_json=use_json, include_raw=include_raw)
capture_filter=capture_filter, use_json=use_json, include_raw=include_raw,
eventloop=eventloop)
self.bpf_filter = bpf_filter
self.monitor_mode = monitor_mode

Expand Down
5 changes: 3 additions & 2 deletions src/pyshark/capture/live_ring_capture.py
@@ -1,5 +1,6 @@
from pyshark import LiveCapture


class LiveRingCapture(LiveCapture):
"""
Represents a live ringbuffer capture on a network interface.
Expand All @@ -8,7 +9,7 @@ class LiveRingCapture(LiveCapture):
def __init__(self, ring_file_size=1024, num_ring_files=1, ring_file_name='/tmp/pyshark.pcap', interface=None,
bpf_filter=None, display_filter=None, only_summaries=False, decryption_key=None,
encryption_type='wpa-pwk', decode_as=None, disable_protocol=None,
tshark_path=None, override_prefs=None, include_raw=False):
tshark_path=None, override_prefs=None, include_raw=False, eventloop=None):
"""
Creates a new live capturer on a given interface. Does not start the actual capture itself.
:param ring_file_size: Size of the ring file in kB, default is 1024
Expand All @@ -31,7 +32,7 @@ def __init__(self, ring_file_size=1024, num_ring_files=1, ring_file_name='/tmp/p
super(LiveRingCapture, self).__init__(interface, bpf_filter=bpf_filter, display_filter=display_filter, only_summaries=only_summaries,
decryption_key=decryption_key, encryption_type=encryption_type,
tshark_path=tshark_path, decode_as=decode_as, disable_protocol=disable_protocol,
override_prefs=override_prefs, include_raw=include_raw)
override_prefs=override_prefs, include_raw=include_raw, eventloop=eventloop)

self.ring_file_size = ring_file_size
self.num_ring_files = num_ring_files
Expand Down
5 changes: 3 additions & 2 deletions src/pyshark/capture/pipe_capture.py
Expand Up @@ -7,7 +7,8 @@
class PipeCapture(Capture):
def __init__(self, pipe, display_filter=None, only_summaries=False,
decryption_key=None, encryption_type='wpa-pwk', decode_as=None,
disable_protocol=None, tshark_path=None, override_prefs=None, use_json=False, include_raw=False):
disable_protocol=None, tshark_path=None, override_prefs=None, use_json=False, include_raw=False,
eventloop=None):
"""
Receives a file-like and reads the packets from there (pcap format).
Expand All @@ -31,7 +32,7 @@ def __init__(self, pipe, display_filter=None, only_summaries=False,
encryption_type=encryption_type,
decode_as=decode_as, disable_protocol=disable_protocol,
tshark_path=tshark_path, override_prefs=override_prefs,
use_json=use_json, include_raw=include_raw)
use_json=use_json, include_raw=include_raw, eventloop=eventloop)
self._pipe = pipe

def get_parameters(self, packet_count=None):
Expand Down
4 changes: 2 additions & 2 deletions src/pyshark/capture/remote_capture.py
Expand Up @@ -8,7 +8,7 @@ class RemoteCapture(LiveCapture):

def __init__(self, remote_host, remote_interface, remote_port=2002, bpf_filter=None, only_summaries=False,
decryption_key=None, encryption_type='wpa-pwk', decode_as=None,
disable_protocol=None,tshark_path=None, override_prefs=None):
disable_protocol=None,tshark_path=None, override_prefs=None, eventloop=None):
"""
Creates a new remote capture which will connect to a remote machine which is running rpcapd. Use the sniff()
method to get packets.
Expand All @@ -35,4 +35,4 @@ def __init__(self, remote_host, remote_interface, remote_port=2002, bpf_filter=N
super(RemoteCapture, self).__init__(interface, bpf_filter=bpf_filter, only_summaries=only_summaries,
decryption_key=decryption_key, encryption_type=encryption_type,
tshark_path=tshark_path, decode_as=decode_as, disable_protocol=disable_protocol,
override_prefs=override_prefs)
override_prefs=override_prefs, eventloop=eventloop)

0 comments on commit 6311e3e

Please sign in to comment.