From 8ccf17d4b7cf7b14dd36a0d7328ee2ff8038983a Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 24 Mar 2026 15:44:50 -0700 Subject: [PATCH] change IPs in code --- Dockerfile | 1 + api/app.py | 12 +++++++----- build.sh | 2 +- docker-compose.yaml | 3 ++- www/index.php | 6 +++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7aea924..c8d1845 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \ nginx \ supervisor \ net-tools \ + iputils-ping \ && rm -rf /var/lib/apt/lists/* # Copy your application code & config files diff --git a/api/app.py b/api/app.py index 54b691f..5ea3151 100644 --- a/api/app.py +++ b/api/app.py @@ -27,9 +27,11 @@ password_types = [ ################################################# # Hash Record Functions ################################################# +# Create the file if it doesn’t exist if not HASH_FILE.exists(): - # Nothing to load – create an empty file for future use HASH_FILE.touch(exist_ok=True) + +# Read the hashes try: with HASH_FILE.open("r", encoding="utf-8") as fh: password_hashes = {line.strip() for line in fh if line.strip()} @@ -125,7 +127,7 @@ def get_password(): "password_types": password_types }), 404 # 404 Not Found - # Success – return the password + # Success - return the password return jsonify({ "password": get_password_by_index(index) }), 200 @@ -151,7 +153,7 @@ def verbose_password(): "error": f"Index {index} is out of bounds (0 ≤ index < {len(password_types)})", "password_types": password_types }), 404 # 404 Not Found - # Success – return the result + # Success - return the result result = { "password": get_password_by_index(index), "descriptor": password_function_descriptor[password_types[index]], @@ -166,7 +168,7 @@ def custom_password(): payload = request.get_json() - # Basic presence check – you can relax this if you want defaults + # Basic presence check - you can relax this if you want defaults required_keys = {"w_min", "w_max", "w_count", "s_char", "num_len"} missing = required_keys - payload.keys() if missing: @@ -411,7 +413,7 @@ def check_and_add_hash(password: str) -> bool: hash_value = sha256_hex(password) if hash_value in password_hashes: return False - # Hash was missing – add it and report that it was newly inserted. + # Hash was missing - add it and report that it was newly inserted. password_hashes.add(hash_value) save_hashes() return True diff --git a/build.sh b/build.sh index 7495ad0..0cdfc02 100755 --- a/build.sh +++ b/build.sh @@ -1 +1 @@ -docker build -t pwdgen-v2 /opt/containers/pwdgen-v2 +docker build -t pwdgen-v2 . diff --git a/docker-compose.yaml b/docker-compose.yaml index b776061..68961e0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,7 +6,8 @@ services: image: pwdgen_v2:latest container_name: pwd.matt-cloud.com ports: - - "80:80" + - "8080:80" volumes: - ./pwdgen:/opt/pwdgen + network_mode: bridge restart: always diff --git a/www/index.php b/www/index.php index 0368f2b..be371e3 100644 --- a/www/index.php +++ b/www/index.php @@ -92,7 +92,7 @@ function curlHelper($url, $APIKey){ // Password Generator API Function function getStandardPasswordFromAPI($passType){ - $apiUrl = "http://172.17.0.1:8189/get_password"; + $apiUrl = "http://0.0.0.0:8189/get_password"; // Build the query string and full URL $query = http_build_query(['pwd_index' => $passType]); $url = rtrim($apiUrl, '?') . '?' . $query; @@ -101,7 +101,7 @@ function getStandardPasswordFromAPI($passType){ // Password Generator API Function for Custom Password function getCustomPasswordFromAPI($passType, $payload){ - $url = 'http://172.17.0.1:8189/custom_password'; + $url = 'http://0.0.0.0:8189/custom_password'; // Initialise a cURL handle $ch = curl_init($url); @@ -159,7 +159,7 @@ function getCustomPasswordFromAPI($passType, $payload){ // Password Count API Function function getPasswordCountFromAPI(){ - $apiUrl = "http://172.17.0.1:8189/get_count"; + $apiUrl = "http://0.0.0.0:8189/get_count"; // Build the query string and full URL $url = rtrim($apiUrl, '?') ; return curlHelper($url, "total_passwords");