From 425a6c356ab393e2f1acc07955b49117eb293ba9 Mon Sep 17 00:00:00 2001 From: DomySh Date: Thu, 16 Jun 2022 08:39:07 +0200 Subject: [PATCH] Allow localhost listen service on windows (Not possible to publish on the host machine yet) --- backend/utils.py | 10 ++++++---- start.py | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/utils.py b/backend/utils.py index ef60ffa..2fa6a36 100755 --- a/backend/utils.py +++ b/backend/utils.py @@ -1,9 +1,10 @@ from asyncore import file_dispatcher from proxy import Filter, Proxy -import random, string, os, threading, sqlite3, time, atexit +import random, string, os, threading, sqlite3, time, atexit, socket from kthread import KThread from base64 import b64decode +LOCALHOST_IP = socket.gethostbyname(os.getenv("LOCALHOST_IP","127.0.0.1")) class SQLite(): def __init__(self, db_name) -> None: @@ -217,7 +218,8 @@ class ProxyManager: proxy = Proxy( internal_port=data['internal_port'], public_port=data['public_port'], - filters=[] + filters=[], + internal_host=LOCALHOST_IP, ) previous_status = next_status[0] = STATUS.PAUSE self.__update_status_db(id, STATUS.WAIT) @@ -237,7 +239,8 @@ class ProxyManager: proxy = Proxy( internal_port=data['internal_port'], public_port=data['public_port'], - filters=list(filters.values()) + filters=list(filters.values()), + internal_host=LOCALHOST_IP, ) previous_status = next_status[0] = STATUS.ACTIVE self.__update_status_db(id, STATUS.WAIT) @@ -251,7 +254,6 @@ class ProxyManager: def check_port_is_open(port): - import socket try: sock = socket.socket() sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) diff --git a/start.py b/start.py index a67656f..0e32035 100755 --- a/start.py +++ b/start.py @@ -39,7 +39,10 @@ services: - {args.port}:{args.port} environment: - NGINX_PORT={args.port} + - LOCALHOST_IP=host.docker.internal volumes: - /execute/db + extra_hosts: + - host.docker.internal:host-gateway """) print("Done! You can start firegex with docker-compose up -d --build")