- Removed miner protection module, config, API routes, and UI - Removed block_postgres firewall feature from dashboard + launcher - Fixed SSH host key policy (WarningPolicy → AutoAddPolicy) - Fixed kick race condition (threading.Lock for iptables) - Tuned Argon2 password parameters (time_cost=3, memory_cost=65536) - Added login rate-limit (10/min) + IP cooldown after 5 failed attempts - Created scripts/db_check.py for launcher pre-flight DB check - Updated README and .gitignore for sanitized repo state
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Pre-flight database connectivity check for the launcher scripts."""
|
|
|
|
import sys
|
|
import os
|
|
import yaml
|
|
import psycopg2
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
print("Usage: db_check.py <port>")
|
|
sys.exit(1)
|
|
|
|
port = int(sys.argv[1])
|
|
|
|
settings_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'settings.yaml')
|
|
if not os.path.exists(settings_path):
|
|
print("settings.yaml not found")
|
|
sys.exit(1)
|
|
|
|
with open(settings_path) as f:
|
|
settings = yaml.safe_load(f) or {}
|
|
|
|
db = settings.get('database', {})
|
|
config = {
|
|
'host': '127.0.0.1',
|
|
'port': port,
|
|
'user': db.get('user', 'postgres'),
|
|
'password': db.get('password', ''),
|
|
'dbname': db.get('name', 'dune'),
|
|
}
|
|
|
|
try:
|
|
conn = psycopg2.connect(**config)
|
|
cur = conn.cursor()
|
|
cur.execute('SELECT 1')
|
|
cur.close()
|
|
conn.close()
|
|
print("ok")
|
|
except Exception as e:
|
|
print(f"failed: {e}")
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|