Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c21f648de | ||
|
|
424982cd3c | ||
|
|
6584c1b85e | ||
|
|
af2e98e091 | ||
|
|
c698eb6394 | ||
|
|
1ee7344df6 | ||
|
|
9317472071 | ||
|
|
f3c4681e49 |
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__/
|
||||||
|
.env
|
||||||
|
*.log
|
||||||
|
app.ico
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# UTF-8
|
||||||
|
#
|
||||||
|
# For more details about fixed file info 'ffi' see:
|
||||||
|
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
|
||||||
|
|
||||||
|
VSVersionInfo(
|
||||||
|
ffi=FixedFileInfo(
|
||||||
|
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||||
|
# Set not needed items to zero 0. Must always contain 4 elements.
|
||||||
|
filevers=(2025,5,6,0),
|
||||||
|
prodvers=(2025,5,6,0),
|
||||||
|
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||||
|
mask=0x3f,
|
||||||
|
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||||
|
flags=0x0,
|
||||||
|
# The operating system for which this file was designed.
|
||||||
|
# 0x4 - NT and there is no need to change it.
|
||||||
|
OS=0x40004,
|
||||||
|
# The general type of file.
|
||||||
|
# 0x1 - the file is an application.
|
||||||
|
fileType=0x1,
|
||||||
|
# The function of the file.
|
||||||
|
# 0x0 - the function is not defined for this fileType
|
||||||
|
subtype=0x0,
|
||||||
|
# Creation date and time stamp.
|
||||||
|
date=(0, 0)
|
||||||
|
),
|
||||||
|
kids=[
|
||||||
|
StringFileInfo(
|
||||||
|
[
|
||||||
|
StringTable(
|
||||||
|
u'040904B0',
|
||||||
|
[StringStruct(u'CompanyName', u''),
|
||||||
|
StringStruct(u'FileDescription', u'HTTP service that resolves hostnames from IPs (POST only)'),
|
||||||
|
StringStruct(u'FileVersion', u'2025.5.6.0'),
|
||||||
|
StringStruct(u'InternalName', u'HostnameHTTPServicePython'),
|
||||||
|
StringStruct(u'LegalCopyright', u'© iamdoubz'),
|
||||||
|
StringStruct(u'OriginalFilename', u'hostname_service.exe'),
|
||||||
|
StringStruct(u'ProductName', u'HostnameHTTPServicePython'),
|
||||||
|
StringStruct(u'ProductVersion', u'2025.5.6.0')])
|
||||||
|
]),
|
||||||
|
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
|
||||||
|
]
|
||||||
|
)
|
||||||
+9
-7
@@ -1,5 +1,6 @@
|
|||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from pathlib import Path
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
@@ -12,11 +13,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
dotenv_p = Path('./.env')
|
||||||
|
load_dotenv(dotenv_path=dotenv_p)
|
||||||
|
|
||||||
HOST = os.getenv("HOST", "0.0.0.0")
|
HOST = os.getenv("HOST", "0.0.0.0")
|
||||||
PORT = int(os.getenv("PORT", 8999))
|
PORT = int(os.getenv("PORT", 8999))
|
||||||
LOG_FILE = os.path.join(os.path.dirname(__file__), 'hostname_service.log')
|
LOG_FILE = os.getenv("LOG_FILE", os.path.join(os.path.dirname(__file__), 'hostname_service.log'))
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename=LOG_FILE,
|
filename=LOG_FILE,
|
||||||
@@ -73,9 +75,9 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
return # Silence default stdout logging
|
return # Silence default stdout logging
|
||||||
|
|
||||||
class HostnameService(win32serviceutil.ServiceFramework):
|
class HostnameService(win32serviceutil.ServiceFramework):
|
||||||
_svc_name_ = "HostnameHTTPService"
|
_svc_name_ = "HostnameHTTPServicePython"
|
||||||
_svc_display_name_ = "Hostname HTTP Resolver Service"
|
_svc_display_name_ = "Hostname HTTP Resolver Service"
|
||||||
_svc_description_ = "HTTP service that resolves hostnames from IPs on port 8999 (POST only)."
|
_svc_description_ = "HTTP service that resolves hostnames from IPs (POST only)."
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
super().__init__(args)
|
super().__init__(args)
|
||||||
@@ -105,7 +107,7 @@ class HostnameService(win32serviceutil.ServiceFramework):
|
|||||||
def run_server(self):
|
def run_server(self):
|
||||||
try:
|
try:
|
||||||
self.httpd = HTTPServer((HOST, PORT), RequestHandler)
|
self.httpd = HTTPServer((HOST, PORT), RequestHandler)
|
||||||
logging.info(f"HTTP server started on port {PORT}")
|
logging.info(f"HTTP server started on port {PORT} for host {HOST}")
|
||||||
self.httpd.serve_forever()
|
self.httpd.serve_forever()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("Server failed: %s", str(e))
|
logging.exception("Server failed: %s", str(e))
|
||||||
@@ -117,9 +119,9 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
if sys.argv[1] == "run":
|
if sys.argv[1] == "run":
|
||||||
# Allow running standalone (not as service)
|
# Allow running standalone (not as service)
|
||||||
logging.info("Running in standalone HTTP mode.")
|
logging.info("Running in standalone HTTP mode on port {PORT} for host {HOST}")
|
||||||
httpd = HTTPServer((HOST, PORT), RequestHandler)
|
httpd = HTTPServer((HOST, PORT), RequestHandler)
|
||||||
print(f"Listening on port {PORT}...")
|
print(f"Listening on port {PORT} for host {HOST}...")
|
||||||
try:
|
try:
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['hostname_service.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=[],
|
||||||
|
datas=[],
|
||||||
|
hiddenimports=['win32timezone'],
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
noarchive=False,
|
||||||
|
optimize=0,
|
||||||
|
)
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name='hostname_service',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
runtime_tmpdir=None,
|
||||||
|
console=True,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
version='file_version_info.txt',
|
||||||
|
icon=['app.ico'],
|
||||||
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Version: VERSION
|
||||||
|
FileDescription: HTTP service that resolves hostnames from IPs (POST only)
|
||||||
|
InternalName: HostnameHTTPServicePython
|
||||||
|
LegalCopyright: © iamdoubz
|
||||||
|
OriginalFilename: hostname_service.exe
|
||||||
|
ProductName: HostnameHTTPServicePython
|
||||||
Reference in New Issue
Block a user