Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
983134be
Commit
983134be
authored
Mar 19, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rfc2136: rework dyndnsCheckIP() as get_dyndns_ip(); closes #1478
parent
0dd2c697
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
17 deletions
+26
-17
plist
plist
+2
-0
rfc2136.inc
src/etc/inc/plugins.inc.d/rfc2136.inc
+1
-1
services.inc
src/etc/inc/services.inc
+13
-10
services_dyndns.php
src/www/services_dyndns.php
+2
-2
services_rfc2136.php
src/www/services_rfc2136.php
+6
-2
dyn_dns_status.widget.php
src/www/widgets/widgets/dyn_dns_status.widget.php
+2
-2
No files found.
plist
View file @
983134be
...
...
@@ -129,6 +129,7 @@
/usr/local/etc/rc.reload_interfaces
/usr/local/etc/rc.resolv_conf_generate
/usr/local/etc/rc.restart_webgui
/usr/local/etc/rc.rfc2136.update
/usr/local/etc/rc.shutdown
/usr/local/etc/rc.sshd
/usr/local/etc/rc.syshook
...
...
@@ -632,6 +633,7 @@
/usr/local/opnsense/service/conf/actions.d/actions_openssh.conf
/usr/local/opnsense/service/conf/actions.d/actions_openvpn.conf
/usr/local/opnsense/service/conf/actions.d/actions_proxy.conf
/usr/local/opnsense/service/conf/actions.d/actions_rfc2136.conf
/usr/local/opnsense/service/conf/actions.d/actions_routedns.conf
/usr/local/opnsense/service/conf/actions.d/actions_system.conf
/usr/local/opnsense/service/conf/actions.d/actions_systemhealth.conf
...
...
src/etc/inc/plugins.inc.d/rfc2136.inc
View file @
983134be
...
...
@@ -65,7 +65,7 @@ function rfc2136_configure_do($verbose = false, $int = '', $updatehost = '', $fo
$if
=
get_real_interface
(
$dnsupdate
[
'interface'
]);
if
(
isset
(
$dnsupdate
[
'usepublicip'
]))
{
$wanip
=
dyndnsCheckIP
(
$dnsupdate
[
'interface'
]);
$wanip
=
get_dyndns_ip
(
$dnsupdate
[
'interface'
]);
}
else
{
$wanip
=
get_interface_ip
(
$dnsupdate
[
'interface'
]);
}
...
...
src/etc/inc/services.inc
View file @
983134be
...
...
@@ -1551,33 +1551,36 @@ function services_dhcrelay6_configure($verbose = false)
}
}
function
dyndnsCheckIP
(
$int
)
function
get_dyndns_ip
(
$int
,
$ipver
=
4
)
{
global
$config
;
$ip_address
=
get_interface_ip
(
$int
);
$ip_address
=
$ipver
==
6
?
get_interface_ipv6
(
$int
)
:
get_interface_ip
(
$int
);
if
(
is_private_ip
(
$ip_address
))
{
if
(
$ipver
==
6
||
is_private_ip
(
$ip_address
))
{
$gateways_status
=
return_gateways_status
(
true
);
// If the gateway for this interface is down, then the external check cannot work.
// Avoid the long wait for the external check to timeout.
if
(
stristr
(
$gateways_status
[
$config
[
'interfaces'
][
$int
][
'gateway'
]][
'status'
],
"down"
))
{
return
"down"
;
return
'down'
;
}
$hosttocheck
=
"http://checkip.dyndns.org"
;
$hosttocheck
=
$ipver
==
6
?
'http://checkipv6.dyndns.org'
:
'http://checkip.dyndns.org'
;
$ip_ch
=
curl_init
(
$hosttocheck
);
curl_setopt
(
$ip_ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ip_ch
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$ip_ch
,
CURLOPT_INTERFACE
,
$ip_address
);
curl_setopt
(
$ip_ch
,
CURLOPT_CONNECTTIMEOUT
,
'30'
);
curl_setopt
(
$ip_ch
,
CURLOPT_TIMEOUT
,
12
0
);
curl_setopt
(
$ip_ch
,
CURLOPT_IPRESOLVE
,
CURL_IPRESOLVE_V4
);
curl_setopt
(
$ip_ch
,
CURLOPT_CONNECTTIMEOUT
,
5
);
curl_setopt
(
$ip_ch
,
CURLOPT_TIMEOUT
,
3
0
);
curl_setopt
(
$ip_ch
,
CURLOPT_IPRESOLVE
,
$ipver
==
6
?
CURL_IPRESOLVE_V6
:
CURL_IPRESOLVE_V4
);
$ip_result_page
=
curl_exec
(
$ip_ch
);
curl_close
(
$ip_ch
);
$ip_result_decoded
=
urldecode
(
$ip_result_page
);
preg_match
(
'=Current IP Address: (.*)</body>=siU'
,
$ip_result_decoded
,
$matches
);
preg_match
(
'=
<body>
Current IP Address: (.*)</body>=siU'
,
$ip_result_decoded
,
$matches
);
$ip_address
=
trim
(
$matches
[
1
]);
if
((
$ipver
==
6
&&
!
is_ipaddrv6
(
$ip_address
))
||
(
$ipver
!=
6
&&
!
is_ipaddrv4
(
$ip_address
)))
{
return
'down'
;
}
}
return
$ip_address
;
}
...
...
src/www/services_dyndns.php
View file @
983134be
...
...
@@ -143,14 +143,14 @@ $main_buttons = array(
$filename
=
"/conf/dyndns_
{
$dyndns
[
'interface'
]
}{
$dyndns
[
'type'
]
}
"
.
escapeshellarg
(
$dyndns
[
'host'
])
.
"
{
$dyndns
[
'id'
]
}
.cache"
;
$fdata
=
''
;
if
(
file_exists
(
$filename
)
&&
!
empty
(
$dyndns
[
'enable'
]))
{
$ipaddr
=
dyndnsCheckIP
(
$dyndns
[
'interface'
]
);
$ipaddr
=
get_dyndns_ip
(
$dyndns
[
'interface'
],
4
);
$fdata
=
@
file_get_contents
(
$filename
);
}
$filename_v6
=
"/conf/dyndns_
{
$dyndns
[
'interface'
]
}{
$dyndns
[
'type'
]
}
"
.
escapeshellarg
(
$dyndns
[
'host'
])
.
"
{
$dyndns
[
'id'
]
}
_v6.cache"
;
$fdata6
=
''
;
if
(
file_exists
(
$filename_v6
)
&&
!
empty
(
$dyndns
[
'enable'
]))
{
$ipv6addr
=
get_
interface_ipv6
(
$dyndns
[
'interface'
]
);
$ipv6addr
=
get_
dyndns_ip
(
$dyndns
[
'interface'
],
6
);
$fdata6
=
@
file_get_contents
(
$filename_v6
);
}
...
...
src/www/services_rfc2136.php
View file @
983134be
...
...
@@ -143,7 +143,7 @@ $main_buttons = array(
if
(
file_exists
(
$filename
)
&&
!
empty
(
$rfc2136
[
'enable'
])
&&
(
empty
(
$dnsupdate
[
'recordtype'
])
||
$dnsupdate
[
'recordtype'
]
==
'A'
))
{
echo
"IPv4: "
;
if
(
isset
(
$rfc2136
[
'usepublicip'
]))
{
$ipaddr
=
dyndnsCheckIP
(
$rfc2136
[
'interface'
]
);
$ipaddr
=
get_dyndns_ip
(
$rfc2136
[
'interface'
],
4
);
}
else
{
$ipaddr
=
get_interface_ip
(
$rfc2136
[
'interface'
]);
}
...
...
@@ -162,7 +162,11 @@ $main_buttons = array(
echo
"<br />"
;
if
(
file_exists
(
"
{
$filename
}
.ipv6"
)
&&
!
empty
(
$rfc2136
[
'enable'
])
&&
(
empty
(
$dnsupdate
[
'recordtype'
])
||
$dnsupdate
[
'recordtype'
]
==
'AAAA'
))
{
echo
"IPv6: "
;
$ipaddr
=
get_interface_ipv6
(
$rfc2136
[
'interface'
]);
if
(
isset
(
$rfc2136
[
'usepublicip'
]))
{
$ipaddr
=
get_dyndns_ip
(
$rfc2136
[
'interface'
],
6
);
}
else
{
$ipaddr
=
get_interface_ipv6
(
$rfc2136
[
'interface'
]);
}
$cached_ip_s
=
explode
(
"|"
,
file_get_contents
(
"
{
$filename
}
.ipv6"
));
$cached_ip
=
$cached_ip_s
[
0
];
if
(
$ipaddr
<>
$cached_ip
)
{
...
...
src/www/widgets/widgets/dyn_dns_status.widget.php
View file @
983134be
...
...
@@ -53,14 +53,14 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
$filename
=
"/conf/dyndns_
{
$dyndns
[
'interface'
]
}{
$dyndns
[
'type'
]
}
"
.
escapeshellarg
(
$dyndns
[
'host'
])
.
"
{
$dyndns
[
'id'
]
}
.cache"
;
$fdata
=
''
;
if
(
!
empty
(
$dyndns
[
'enable'
])
&&
file_exists
(
$filename
))
{
$ipaddr
=
dyndnsCheckIP
(
$dyndns
[
'interface'
]
);
$ipaddr
=
get_dyndns_ip
(
$dyndns
[
'interface'
],
4
);
$fdata
=
@
file_get_contents
(
$filename
);
}
$filename_v6
=
"/conf/dyndns_
{
$dyndns
[
'interface'
]
}{
$dyndns
[
'type'
]
}
"
.
escapeshellarg
(
$dyndns
[
'host'
])
.
"
{
$dyndns
[
'id'
]
}
_v6.cache"
;
$fdata6
=
''
;
if
(
!
empty
(
$dyndns
[
'enable'
])
&&
file_exists
(
$filename_v6
))
{
$ipv6addr
=
get_
interface_ipv6
(
$dyndns
[
'interface'
]
);
$ipv6addr
=
get_
dyndns_ip
(
$dyndns
[
'interface'
],
6
);
$fdata6
=
@
file_get_contents
(
$filename_v6
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment