@@ -3,17 +3,8 @@ const logger = require('../../logger').ddns;
3
3
const utils = require ( '../utils' ) ;
4
4
5
5
const ddnsResolver = {
6
- /**
7
- * Checks whether the address requires resolution (i.e. starts with ddns:)
8
- * @param {String } address
9
- * @returns {boolean }
10
- */
11
- requiresResolution : ( address ) => {
12
- if ( typeof address !== 'undefined' && address && address . toLowerCase ( ) . startsWith ( 'ddns:' ) ) {
13
- return true ;
14
- }
15
- return false ;
16
- } ,
6
+ /** Pattern to match any valid domain/subdomain */
7
+ ddnsRegex : / ' ^ ( (? ! - ) [ A - Z a - z \d - ] { 1 , 63 } (?< ! - ) \. ) + [ A - Z a - z ] { 2 , 6 } $ ' / ,
17
8
18
9
/**
19
10
* Resolves the given address to its IP
@@ -35,9 +26,6 @@ const ddnsResolver = {
35
26
ddnsResolver . _cache . delete ( address ) ;
36
27
// Reach here only if cache value doesn't exist or needs to be updated
37
28
let host = address . toLowerCase ( ) ;
38
- if ( host . startsWith ( 'ddns:' ) ) {
39
- host = host . substring ( 5 ) ;
40
- }
41
29
return ddnsResolver . _queryHost ( host )
42
30
. then ( ( resolvedIP ) => {
43
31
ddnsResolver . _cache . set ( address , [ resolvedIP , Date . now ( ) ] ) ;
@@ -64,7 +52,7 @@ const ddnsResolver = {
64
52
* @returns {Promise }
65
53
*/
66
54
_queryHost : ( host ) => {
67
- return utils . execSafe ( 'getent' , [ 'hosts' , host ] )
55
+ return utils . execSafe ( 'getent' , [ 'ahostsv4' , ' hosts', host ] )
68
56
. then ( ( result ) => {
69
57
if ( result . length < 8 ) {
70
58
logger . error ( `IP lookup for ${ host } returned invalid output: ${ result } ` ) ;
0 commit comments