mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-12-18 13:23:26 +00:00
Refactor and integrate ddns resolution with nginx module
Refactored ddns resolver so that no patching is done. nginx.js will automatically resolve ddns addresses if needed. Added dedicated logger scope for ddns resovler.
This commit is contained in:
@@ -4,6 +4,7 @@ const execFile = require('child_process').execFile;
|
||||
const { Liquid } = require('liquidjs');
|
||||
const logger = require('../logger').global;
|
||||
const error = require('./error');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -26,6 +27,37 @@ module.exports = {
|
||||
return stdout;
|
||||
},
|
||||
|
||||
/**
|
||||
* Run the given command. Safer than using exec since args are passed as a list instead of in shell mode as a single string.
|
||||
* @param {string} cmd The command to run
|
||||
* @param {string} args The args to pass to the command
|
||||
* @returns Promise that resolves to stdout or an object with error code and stderr if there's an error
|
||||
*/
|
||||
execSafe: (cmd, args) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
const proc = spawn(cmd, args);
|
||||
proc.stdout.on('data', (data) => {
|
||||
stdout += data;
|
||||
});
|
||||
proc.stderr.on('data', (data) => {
|
||||
stderr += data;
|
||||
});
|
||||
|
||||
proc.on('close', (exitCode) => {
|
||||
if (!exitCode) {
|
||||
resolve(stdout.trim());
|
||||
} else {
|
||||
reject({
|
||||
exitCode: exitCode,
|
||||
stderr: stderr
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} cmd
|
||||
* @param {Array} args
|
||||
|
||||
Reference in New Issue
Block a user