From 3e34d0f310b0fade0db7bbd992f520092d77eaa3 Mon Sep 17 00:00:00 2001 From: Fede Luzzi Date: Wed, 13 Aug 2025 16:07:32 -0300 Subject: [PATCH] publish prod version with capture --- connpy/_version.py | 2 +- connpy/ai.py | 2 +- connpy/core_plugins/capture.py | 18 +++++++++++++++--- docs/connpy/index.html | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/connpy/_version.py b/connpy/_version.py index 6cab941..df91a88 100644 --- a/connpy/_version.py +++ b/connpy/_version.py @@ -1,2 +1,2 @@ -__version__ = "4.2b1" +__version__ = "4.2" diff --git a/connpy/ai.py b/connpy/ai.py index 0b963f7..1b4f57a 100755 --- a/connpy/ai.py +++ b/connpy/ai.py @@ -65,7 +65,7 @@ class ai: try: self.model = self.config.config["openai"]["model"] except: - self.model = "o4-mini" + self.model = "gpt-5-nano" self.__prompt = {} self.__prompt["original_system"] = """ You are the AI chatbot and assistant of a network connection manager and automation app called connpy. When provided with user input analyze the input and extract the following information. If user wants to chat just reply and don't call a function: diff --git a/connpy/core_plugins/capture.py b/connpy/core_plugins/capture.py index 5202063..d001293 100644 --- a/connpy/core_plugins/capture.py +++ b/connpy/core_plugins/capture.py @@ -42,6 +42,7 @@ class RemoteCapture: self.wireshark_path = connapp.config.config.get("wireshark_path") def _start_local_listener(self, port, ws_proc=None): + self.fake_connection = False self.listener_active = True self.listener_conn = None self.listener_connected = threading.Event() @@ -55,7 +56,8 @@ class RemoteCapture: conn, addr = s.accept() self.listener_conn = conn - printer.start(f"Connection from {addr}") + if not self.fake_connection: + printer.start(f"Connection from {addr}") self.listener_connected.set() try: @@ -131,7 +133,7 @@ class RemoteCapture: try: self.node.child.sendline(cmd) start_time = time.time() - while time.time() - start_time < 5: + while time.time() - start_time < 3: try: index = self.node.child.expect([ r'listening on', @@ -193,6 +195,8 @@ class RemoteCapture: r'Unable', r'No such', r'illegal', + r'not found', + r'non-ether', r'syntax error' ], timeout=5) @@ -215,7 +219,7 @@ class RemoteCapture: return f"{error}" else: before_last_line = self.node.child.before.decode().splitlines()[-1] - error = f"Tcpdump error detected:" \ + error = f"Tcpdump error detected: " \ f"{before_last_line}{self.node.child.after.decode()}{self.node.child.readline().decode()}".rstrip() return f"{error}" @@ -225,6 +229,7 @@ class RemoteCapture: return False + def _build_tcpdump_command(self): base = f"tcpdump -i {self.interface}" if self.use_wireshark: @@ -297,6 +302,13 @@ class RemoteCapture: printer.error(f"{result}") else: printer.error("Listener connection failed after all retries.") + printer.debug(f"Command used:\n{tcpdump_cmd}") + if not self.listener_conn: + try: + self.fake_connection = True + socket.create_connection(("localhost", self.local_port), timeout=1).close() + except: + pass self.listener_active = False return diff --git a/docs/connpy/index.html b/docs/connpy/index.html index 2ead57c..d78a4aa 100644 --- a/docs/connpy/index.html +++ b/docs/connpy/index.html @@ -868,7 +868,7 @@ class ai: try: self.model = self.config.config["openai"]["model"] except: - self.model = "o4-mini" + self.model = "gpt-5-nano" self.__prompt = {} self.__prompt["original_system"] = """ You are the AI chatbot and assistant of a network connection manager and automation app called connpy. When provided with user input analyze the input and extract the following information. If user wants to chat just reply and don't call a function: