From 05c4c0470eceecf6ee231a8990d552c640de50c4 Mon Sep 17 00:00:00 2001 From: Luca Krawczyk Date: Thu, 18 Jul 2024 00:17:52 +0200 Subject: [PATCH] fixed ip in dns table --- backend/internal/PiHoleDNSPlugin.js | 7 +++++-- backend/internal/proxy-host.js | 12 ++++++------ docker/docker-compose.dev.yml | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/internal/PiHoleDNSPlugin.js b/backend/internal/PiHoleDNSPlugin.js index 833146c9..2aac300d 100644 --- a/backend/internal/PiHoleDNSPlugin.js +++ b/backend/internal/PiHoleDNSPlugin.js @@ -7,8 +7,11 @@ const PIHOLE_PASSWORD = process.env.PIHOLE_PASSWORD; const PIHOLE_LOGIN_URL = 'http://'+process.env.PIHOLE_IP+'/admin/index.php'; const PIHOLE_CUSTOMDNS_URL = 'http://'+process.env.PIHOLE_IP+'/admin/scripts/pi-hole/php/customdns.php'; +// IP to entry in pihole dns table +const DNS_TABLE_IP = process.env.DNS_TABLE_IP; + // Function to update Pi-hole with domain and IP -async function updatePihole(domain, ip, action) { +async function updatePihole(domain, action) { // Check if the Pi-hole plugin is enabled if (!PIHOLE_PLUGIN_ENABLED) { return; @@ -63,7 +66,7 @@ async function updatePihole(domain, ip, action) { // Request data including token const requestData = { action: action, - ip: ip, + ip: DNS_TABLE_IP, domain: domain, token: token // Use the token retrieved from the HTML page }; diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index e1676692..8324e0dd 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -68,7 +68,7 @@ const internalProxyHost = { // Update PiHole for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'add').then(); + piHole.updatePihole(row.domain_names[i], 'add').then(); } return row; @@ -77,7 +77,7 @@ const internalProxyHost = { // Update PiHole for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'add').then(); + piHole.updatePihole(row.domain_names[i], 'add').then(); } return row; @@ -168,14 +168,14 @@ const internalProxyHost = { .then(() => { // Update PiHole for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'delete').then(); + piHole.updatePihole(row.domain_names[i], 'delete').then(); } return row; }); } else { // Update PiHole for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'delete').then(); + piHole.updatePihole(row.domain_names[i], 'delete').then(); } return row; @@ -224,7 +224,7 @@ const internalProxyHost = { row.meta = new_meta; row = internalHost.cleanRowCertificateMeta(row); for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'add').then(); + piHole.updatePihole(row.domain_names[i], 'add').then(); } return _.omit(row, omissions()); }); @@ -304,7 +304,7 @@ const internalProxyHost = { // Update PiHole for (let i = 0; i < row.domain_names.length; i++) { - piHole.updatePihole(row.domain_names[i], row.forward_host, 'delete').then(); + piHole.updatePihole(row.domain_names[i], 'delete').then(); } // Delete Nginx Config return internalNginx.deleteConfig('proxy_host', row) diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 3590fb59..6621ce7a 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -30,6 +30,7 @@ services: # DB_SQLITE_FILE: "/data/database.sqlite" # DISABLE_IPV6: "true" # pihole: + # DNS_TABLE_IP: '192.168.10.10' # PIHOLE_PLUGIN_ENABLED: 'true' # PIHOLE_PASSWORD: 'password' # PIHOLE_IP: '192.168.10.2'