diff --git a/src/pyshark/capture/file_capture.py b/src/pyshark/capture/file_capture.py index 8ccd83c1..cdfa4e10 100644 --- a/src/pyshark/capture/file_capture.py +++ b/src/pyshark/capture/file_capture.py @@ -45,8 +45,8 @@ def __init__(self, input_file=None, keep_packets=True, display_filter=None, only self.input_filepath = pathlib.Path(input_file) if not self.input_filepath.exists(): raise FileNotFoundError(f"[Errno 2] No such file or directory: {self.input_filepath}") - if not self.input_filepath.is_file(): - raise FileNotFoundError(f"{self.input_filepath} is a directory") + if not self.input_filepath.is_file() and not self.input_filepath.is_fifo(): + raise FileNotFoundError(f"{self.input_filepath} is not a file or fifo") self.keep_packets = keep_packets self._packet_generator = self._packets_from_tshark_sync() diff --git a/src/pyshark/capture/live_capture.py b/src/pyshark/capture/live_capture.py index f5c27c65..66562bf9 100644 --- a/src/pyshark/capture/live_capture.py +++ b/src/pyshark/capture/live_capture.py @@ -65,15 +65,19 @@ def __init__(self, interface=None, bpf_filter=None, display_filter=None, only_su def get_parameters(self, packet_count=None): """Returns the special tshark parameters to be used according to the configuration of this class.""" - params = super(LiveCapture, self).get_parameters(packet_count=packet_count) - # Read from STDIN - params += ["-i", "-"] + params = super(LiveCapture, self).get_parameters( + packet_count=packet_count) + # Read directly from interfaces + for interface in self.interfaces: + params += ["-i", interface] return params def _verify_capture_parameters(self): all_interfaces_names = tshark.get_all_tshark_interfaces_names(self.tshark_path) all_interfaces_lowercase = [interface.lower() for interface in all_interfaces_names] for each_interface in self.interfaces: + if each_interface.startswith("rpcap://"): + continue if each_interface.isnumeric(): continue if each_interface.lower() not in all_interfaces_lowercase: diff --git a/src/pyshark/packet/packet.py b/src/pyshark/packet/packet.py index da8f6ead..2c066ab6 100644 --- a/src/pyshark/packet/packet.py +++ b/src/pyshark/packet/packet.py @@ -120,7 +120,7 @@ def __getattr__(self, item): Allows layers to be retrieved via get attr. For instance: pkt.ip """ for layer in self.layers: - if layer.layer_name == item: + if layer.layer_name.lower() == item: return layer raise AttributeError("No attribute named %s" % item)