fixed ip in dns table

This commit is contained in:
Luca Krawczyk 2024-07-18 00:17:52 +02:00
parent c0598c5827
commit 05c4c0470e
3 changed files with 12 additions and 8 deletions

View File

@ -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_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'; 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 // 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 // Check if the Pi-hole plugin is enabled
if (!PIHOLE_PLUGIN_ENABLED) { if (!PIHOLE_PLUGIN_ENABLED) {
return; return;
@ -63,7 +66,7 @@ async function updatePihole(domain, ip, action) {
// Request data including token // Request data including token
const requestData = { const requestData = {
action: action, action: action,
ip: ip, ip: DNS_TABLE_IP,
domain: domain, domain: domain,
token: token // Use the token retrieved from the HTML page token: token // Use the token retrieved from the HTML page
}; };

View File

@ -68,7 +68,7 @@ const internalProxyHost = {
// Update PiHole // Update PiHole
for (let i = 0; i < row.domain_names.length; i++) { 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; return row;
@ -77,7 +77,7 @@ const internalProxyHost = {
// Update PiHole // Update PiHole
for (let i = 0; i < row.domain_names.length; i++) { 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; return row;
@ -168,14 +168,14 @@ const internalProxyHost = {
.then(() => { .then(() => {
// Update PiHole // Update PiHole
for (let i = 0; i < row.domain_names.length; i++) { 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; return row;
}); });
} else { } else {
// Update PiHole // Update PiHole
for (let i = 0; i < row.domain_names.length; i++) { 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; return row;
@ -224,7 +224,7 @@ const internalProxyHost = {
row.meta = new_meta; row.meta = new_meta;
row = internalHost.cleanRowCertificateMeta(row); row = internalHost.cleanRowCertificateMeta(row);
for (let i = 0; i < row.domain_names.length; i++) { 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()); return _.omit(row, omissions());
}); });
@ -304,7 +304,7 @@ const internalProxyHost = {
// Update PiHole // Update PiHole
for (let i = 0; i < row.domain_names.length; i++) { 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 // Delete Nginx Config
return internalNginx.deleteConfig('proxy_host', row) return internalNginx.deleteConfig('proxy_host', row)

View File

@ -30,6 +30,7 @@ services:
# DB_SQLITE_FILE: "/data/database.sqlite" # DB_SQLITE_FILE: "/data/database.sqlite"
# DISABLE_IPV6: "true" # DISABLE_IPV6: "true"
# pihole: # pihole:
# DNS_TABLE_IP: '192.168.10.10'
# PIHOLE_PLUGIN_ENABLED: 'true' # PIHOLE_PLUGIN_ENABLED: 'true'
# PIHOLE_PASSWORD: 'password' # PIHOLE_PASSWORD: 'password'
# PIHOLE_IP: '192.168.10.2' # PIHOLE_IP: '192.168.10.2'