From c0be695c2fd06c5deb03eb41138e7224407bce57 Mon Sep 17 00:00:00 2001 From: Bryan Cerrati Date: Thu, 19 Jun 2025 14:22:45 -0400 Subject: [PATCH] Sending --- SendingMechanism/AutoPoster-GUI.py | 82 ++++++++++++++++++++++++++++ SendingMechanism/keepalive-daemon.py | 20 +++++++ SendingMechanism/teminalcommand.ps1 | 4 ++ 3 files changed, 106 insertions(+) create mode 100644 SendingMechanism/AutoPoster-GUI.py create mode 100644 SendingMechanism/keepalive-daemon.py create mode 100644 SendingMechanism/teminalcommand.ps1 diff --git a/SendingMechanism/AutoPoster-GUI.py b/SendingMechanism/AutoPoster-GUI.py new file mode 100644 index 0000000..bc0b8c4 --- /dev/null +++ b/SendingMechanism/AutoPoster-GUI.py @@ -0,0 +1,82 @@ +import sys +import threading +import time +import requests +from PyQt6.QtWidgets import ( + QApplication, QWidget, QVBoxLayout, QLabel, + QLineEdit, QPushButton, QMessageBox +) +from PyQt6.QtCore import QTimer + +class PosterApp(QWidget): + def __init__(self): + super().__init__() + self.setWindowTitle("Auto Poster") + self.setFixedSize(300, 250) + + self.layout = QVBoxLayout() + + self.ip_label = QLabel("IP Address:") + self.ip_input = QLineEdit() + self.layout.addWidget(self.ip_label) + self.layout.addWidget(self.ip_input) + + self.name_label = QLabel("Name:") + self.name_input = QLineEdit() + self.layout.addWidget(self.name_label) + self.layout.addWidget(self.name_input) + + self.seconds_label = QLabel("Seconds Interval:") + self.seconds_input = QLineEdit() + self.seconds_input.setText("10") + self.layout.addWidget(self.seconds_label) + self.layout.addWidget(self.seconds_input) + + self.start_button = QPushButton("Start") + self.stop_button = QPushButton("Stop") + self.layout.addWidget(self.start_button) + self.layout.addWidget(self.stop_button) + + self.setLayout(self.layout) + + self.running = False + self.thread = None + + self.start_button.clicked.connect(self.start_posting) + self.stop_button.clicked.connect(self.stop_posting) + + def start_posting(self): + if self.running: + return + + ip = self.ip_input.text().strip() + name = self.name_input.text().strip() + seconds = self.seconds_input.text().strip() + + if not ip or not name or not seconds.isdigit(): + QMessageBox.warning(self, "Invalid Input", "Please provide valid IP, name, and seconds.") + return + + self.running = True + self.thread = threading.Thread(target=self.post_loop, args=(ip, name, int(seconds)), daemon=True) + self.thread.start() + + def stop_posting(self): + self.running = False + + def post_loop(self, ip, name, seconds): + url = f"http://{ip}/{name}/" + while self.running: + try: + print(f"POST to {url}") + response = requests.post(url) + print(f"Status: {response.status_code}") + except Exception as e: + print(f"Error: {e}") + time.sleep(seconds) + +if __name__ == "__main__": + app = QApplication(sys.argv) + window = PosterApp() + window.show() + sys.exit(app.exec()) diff --git a/SendingMechanism/keepalive-daemon.py b/SendingMechanism/keepalive-daemon.py new file mode 100644 index 0000000..1c6ba9d --- /dev/null +++ b/SendingMechanism/keepalive-daemon.py @@ -0,0 +1,20 @@ +# keepalive_daemon.py +import time +import requests + +IP = "47.21.28.174:5050" +NAME = "TEST-daemon" +INTERVAL = 10 # seconds + +def main(): + while True: + try: + url = f"http://{IP}/{NAME}/" + print(f"POST to {url}") + requests.post(url) + except Exception as e: + print("Error:", e) + time.sleep(INTERVAL) + +if __name__ == "__main__": + main() diff --git a/SendingMechanism/teminalcommand.ps1 b/SendingMechanism/teminalcommand.ps1 new file mode 100644 index 0000000..1db6675 --- /dev/null +++ b/SendingMechanism/teminalcommand.ps1 @@ -0,0 +1,4 @@ +$CurlArgument = '-X', 'POST', + 'http://IP:PORT//' +$CURLEXE = 'curl.exe' +& $CURLEXE @CurlArgument \ No newline at end of file