Last active
July 23, 2024 17:19
-
-
Save BoQsc/69985a2c1cf4ac157e9255f66496498f to your computer and use it in GitHub Desktop.
A simple 7 Days To Die TCP HTTP Steam Link redirecter. Once you visit the webpage, it opens up steam://connect/127.0.0.1:26900 link that auto joins player to the gameserver. This is only a proof of concept, replace 127.0.0.1 with your Public IP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
import logging | |
PORT = 26900 | |
REDIRECT_URL = 'steam://connect/127.0.0.1:26900' | |
# Configure logging to log to a file | |
logging.basicConfig(filename='server.log', level=logging.INFO, format='%(asctime)s - %(message)s') | |
logger = logging.getLogger() | |
class RedirectHandler(http.server.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
logger.info(f"Received request from {self.client_address}") | |
try: | |
self.send_response(302) | |
self.send_header('Location', REDIRECT_URL) | |
self.end_headers() | |
logger.info(f"Redirected to {REDIRECT_URL}") | |
except Exception as e: | |
logger.error(f"Failed to handle request: {e}") | |
def log_message(self, format, *args): | |
# Override to prevent logging to stderr | |
logger.info(f"{self.client_address} - {format % args}") | |
with socketserver.TCPServer(("", PORT), RedirectHandler) as httpd: | |
logger.info(f"Serving on port {PORT}") | |
try: | |
httpd.serve_forever() | |
except Exception as e: | |
logger.error(f"Server stopped due to an error: {e}") |
Example html web page of usage demonstration.
index.html
<a href="http://localhost:26900/">localhost:26900</a>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Threaded, Fixes the CTRL+C Not working when someone keeps webpage as opened.