6 Commits
Author SHA1 Message Date
iamdoubz 3c21f648de Add verbage in logging steps 2025-05-21 15:41:28 -05:00
iamdoubz 424982cd3c Add external VERSION file 2025-05-21 15:38:31 -05:00
iamdoubz 6584c1b85e Add files to display version information in executable 2025-05-21 14:58:38 -05:00
iamdoubz af2e98e091 Add more items to ignore 2025-05-21 14:57:25 -05:00
iamdoubz c698eb6394 Add gitignore file for security reasons 2025-05-21 14:38:07 -05:00
iamdoubz 1ee7344df6 dotenv fixes 2025-05-21 14:33:21 -05:00
6 changed files with 106 additions and 7 deletions
+6
View File
@@ -0,0 +1,6 @@
__pycache__/
.env
*.log
app.ico
build/
dist/
+1
View File
@@ -0,0 +1 @@
2025.5.6.0
+44
View File
@@ -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
View File
@@ -1,5 +1,6 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from dotenv import load_dotenv
from pathlib import Path
import socket
import json
import threading
@@ -12,11 +13,12 @@ import os
import sys
# 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")
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(
filename=LOG_FILE,
@@ -73,9 +75,9 @@ class RequestHandler(BaseHTTPRequestHandler):
return # Silence default stdout logging
class HostnameService(win32serviceutil.ServiceFramework):
_svc_name_ = "HostnameHTTPService"
_svc_name_ = "HostnameHTTPServicePython"
_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):
super().__init__(args)
@@ -105,7 +107,7 @@ class HostnameService(win32serviceutil.ServiceFramework):
def run_server(self):
try:
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()
except Exception as e:
logging.exception("Server failed: %s", str(e))
@@ -117,9 +119,9 @@ if __name__ == '__main__':
else:
if sys.argv[1] == "run":
# 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)
print(f"Listening on port {PORT}...")
print(f"Listening on port {PORT} for host {HOST}...")
try:
httpd.serve_forever()
except KeyboardInterrupt:
+40
View File
@@ -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'],
)
+6
View File
@@ -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