wip
This commit is contained in:
parent
fd5840df94
commit
9e295a6f18
2 changed files with 73 additions and 9 deletions
21
app.py
21
app.py
|
@ -20,6 +20,9 @@ DEBUG_MODE = os.getenv('DEBUG_MODE', 'false').lower() == 'true'
|
|||
CADDYFILE_PATH = "/app/Caddyfile" # Fixed internal path
|
||||
NGINX_CONFIG_PATH = os.getenv('NGINX_CONFIG_PATH', '/app/nginx/conf.d') # Path to nginx config directory
|
||||
|
||||
# Add SERVER_NAME environment variable near the top with other configs
|
||||
SERVER_NAME = os.getenv('SERVER_NAME', 'Local Server') # Get server name from env variable
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG if DEBUG_MODE else logging.INFO,
|
||||
|
@ -181,7 +184,9 @@ def index():
|
|||
caddy_count=stats['caddy_servers'],
|
||||
nginx_count=stats['nginx_servers'],
|
||||
domain_count=stats['total_domains'],
|
||||
last_update=stats['last_update'])
|
||||
last_update=stats['last_update'],
|
||||
caddy_proxies=caddy_proxies, # Pass all proxies data
|
||||
nginx_proxies=nginx_proxies) # Pass all proxies data
|
||||
|
||||
@app.route('/caddy')
|
||||
def caddy_dashboard():
|
||||
|
@ -207,7 +212,7 @@ def update_proxies():
|
|||
if not data or not isinstance(data, dict):
|
||||
return jsonify({"status": "error", "message": "Invalid data format"}), 400
|
||||
|
||||
server_name = data.get("server", "Local Server") # Default to 'Local Server' if not provided
|
||||
server_name = data.get("server", SERVER_NAME) # Default to SERVER_NAME if not provided
|
||||
entries = data.get("entries", {})
|
||||
server_type = data.get("type", "caddy").lower() # Default to caddy if not specified
|
||||
|
||||
|
@ -257,15 +262,15 @@ def delete_server():
|
|||
if USE_LOCAL_CADDYFILE:
|
||||
entries = parse_local_caddyfile()
|
||||
if entries:
|
||||
caddy_proxies["Local Server"] = entries
|
||||
timestamps["Local Server"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
caddy_proxies[SERVER_NAME] = entries
|
||||
timestamps[SERVER_NAME] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
logger.info(f"Loaded {len(entries)} entries from local Caddyfile")
|
||||
|
||||
if USE_LOCAL_NGINX:
|
||||
entries = parse_nginx_configs()
|
||||
if entries:
|
||||
nginx_proxies["Local Nginx"] = entries
|
||||
timestamps["Local Nginx"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
nginx_proxies[f"{SERVER_NAME} Nginx"] = entries
|
||||
timestamps[f"{SERVER_NAME} Nginx"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
logger.info(f"Loaded {len(entries)} entries from local Nginx configs")
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
|
@ -281,8 +286,8 @@ if __name__ == '__main__':
|
|||
# Load it initially
|
||||
local_data = parse_local_caddyfile()
|
||||
if local_data:
|
||||
caddy_proxies["Local Server"] = local_data
|
||||
timestamps["Local Server"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
caddy_proxies[SERVER_NAME] = local_data
|
||||
timestamps[SERVER_NAME] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
if not API_KEY:
|
||||
logger.warning("API_KEY not set - running without authentication!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue