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
99973edc
Commit
99973edc
authored
Mar 13, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: add route features to RA
parent
f89f1b34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
7 deletions
+112
-7
services.inc
src/etc/inc/services.inc
+10
-2
services_router_advertisements.php
src/www/services_router_advertisements.php
+102
-5
No files found.
src/etc/inc/services.inc
View file @
99973edc
...
@@ -193,12 +193,20 @@ function services_radvd_configure($blacklist = array())
...
@@ -193,12 +193,20 @@ function services_radvd_configure($blacklist = array())
$radvdconf
.=
"
\t
route ::/0 {\n"
;
$radvdconf
.=
"
\t
route ::/0 {\n"
;
$radvdconf
.=
"
\t\t
RemoveRoute off;
\n
"
;
$radvdconf
.=
"
\t\t
RemoveRoute off;
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
}
else
{
}
else
if
(
empty
(
$dhcpv6ifconf
[
'ranodefault'
]))
{
$radvdconf
.=
"
\t
route ::/0 {\n"
;
$radvdconf
.=
"
\t
route ::/0 {\n"
;
$radvdconf
.=
"
\t\t
RemoveRoute on;
\n
"
;
$radvdconf
.=
"
\t\t
RemoveRoute on;
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
}
}
if
(
!
empty
(
$dhcpv6ifconf
[
'raroutes'
]))
{
foreach
(
explode
(
','
,
$dhcpv6ifconf
[
'raroutes'
])
as
$raroute
)
{
$radvdconf
.=
"
\t
route
{
$raroute
}
{\n"
;
$radvdconf
.=
"
\t\t
RemoveRoute on;
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
}
}
/* add DNS servers */
/* add DNS servers */
$dnslist_tmp
=
array
();
$dnslist_tmp
=
array
();
if
(
isset
(
$dhcpv6ifconf
[
'rasamednsasdhcp6'
])
&&
!
empty
(
$dhcpv6ifconf
[
'dnsserver'
][
0
]))
{
if
(
isset
(
$dhcpv6ifconf
[
'rasamednsasdhcp6'
])
&&
!
empty
(
$dhcpv6ifconf
[
'dnsserver'
][
0
]))
{
...
@@ -2034,7 +2042,7 @@ function get_service_control_links($service, $addname = false)
...
@@ -2034,7 +2042,7 @@ function get_service_control_links($service, $addname = false)
'srv_status_act'
,
'srv_status_act'
,
'glyphicon glyphicon-refresh'
'glyphicon glyphicon-refresh'
);
);
if
(
empty
(
$service
[
'nocheck'
]))
{
if
(
empty
(
$service
[
'nocheck'
]))
{
$output
.=
sprintf
(
$output
.=
sprintf
(
$template
,
$template
,
$service_id
,
$service_id
,
...
...
src/www/services_router_advertisements.php
View file @
99973edc
...
@@ -58,9 +58,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -58,9 +58,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
// boolean
// boolean
$pconfig
[
'rasamednsasdhcp6'
]
=
isset
(
$config
[
'dhcpdv6'
][
$if
][
'rasamednsasdhcp6'
]);
$pconfig
[
'rasamednsasdhcp6'
]
=
isset
(
$config
[
'dhcpdv6'
][
$if
][
'rasamednsasdhcp6'
]);
if
(
empty
(
$config
[
'dhcpdv6'
][
$if
][
'ranosend'
]))
{
$pconfig
[
'rasend'
]
=
empty
(
$config
[
'dhcpdv6'
][
$if
][
'ranosend'
])
?
true
:
null
;
$pconfig
[
'rasend'
]
=
true
;
$pconfig
[
'radefault'
]
=
empty
(
$config
[
'dhcpdv6'
][
$if
][
'ranodefault'
])
?
true
:
null
;
}
// defaults
// defaults
if
(
empty
(
$pconfig
[
'ramininterval'
]))
{
if
(
empty
(
$pconfig
[
'ramininterval'
]))
{
...
@@ -73,6 +72,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -73,6 +72,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// arrays
// arrays
$pconfig
[
'radns1'
]
=
!
empty
(
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
0
])
?
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
0
]
:
null
;
$pconfig
[
'radns1'
]
=
!
empty
(
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
0
])
?
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
0
]
:
null
;
$pconfig
[
'radns2'
]
=
!
empty
(
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
1
])
?
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
1
]
:
null
;
$pconfig
[
'radns2'
]
=
!
empty
(
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
1
])
?
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
][
1
]
:
null
;
// csvs
if
(
!
empty
(
$config
[
'dhcpdv6'
][
$if
][
'raroutes'
]))
{
$pconfig
[
'raroutes'
]
=
explode
(
','
,
$config
[
'dhcpdv6'
][
$if
][
'raroutes'
]);
}
else
{
$pconfig
[
'raroutes'
]
=
array
();
}
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
if
(
!
empty
(
$_POST
[
'if'
])
&&
!
empty
(
$config
[
'interfaces'
][
$_POST
[
'if'
]]))
{
if
(
!
empty
(
$_POST
[
'if'
])
&&
!
empty
(
$config
[
'interfaces'
][
$_POST
[
'if'
]]))
{
$if
=
$_POST
[
'if'
];
$if
=
$_POST
[
'if'
];
...
@@ -82,6 +88,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -82,6 +88,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors
=
array
();
$input_errors
=
array
();
$pconfig
=
$_POST
;
$pconfig
=
$_POST
;
$pconfig
[
'raroutes'
]
=
array
();
foreach
(
$pconfig
[
'route_address'
]
as
$idx
=>
$address
)
{
if
(
!
empty
(
$address
))
{
$route
=
"
{
$address
}
/
{
$pconfig
[
'route_bits'
][
$idx
]
}
"
;
if
(
!
is_subnetv6
(
$route
))
{
$input_errors
[]
=
sprintf
(
gettext
(
'An invalid subnet route was supplied: %s'
),
$route
);
}
$pconfig
[
'raroutes'
][]
=
$route
;
}
}
if
((
!
empty
(
$pconfig
[
'radns1'
])
&&
!
is_ipaddrv6
(
$pconfig
[
'radns1'
]))
||
(
$pconfig
[
'radns2'
]
&&
!
is_ipaddrv6
(
$pconfig
[
'radns2'
])))
{
if
((
!
empty
(
$pconfig
[
'radns1'
])
&&
!
is_ipaddrv6
(
$pconfig
[
'radns1'
]))
||
(
$pconfig
[
'radns2'
]
&&
!
is_ipaddrv6
(
$pconfig
[
'radns2'
])))
{
$input_errors
[]
=
gettext
(
"A valid IPv6 address must be specified for the primary/secondary DNS servers."
);
$input_errors
[]
=
gettext
(
"A valid IPv6 address must be specified for the primary/secondary DNS servers."
);
}
}
...
@@ -120,6 +137,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -120,6 +137,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset
(
$config
[
'dhcpdv6'
][
$if
][
'ranosend'
]);
unset
(
$config
[
'dhcpdv6'
][
$if
][
'ranosend'
]);
}
}
# flipped in GUI on purpose
if
(
empty
(
$pconfig
[
'radefault'
]))
{
$config
[
'dhcpdv6'
][
$if
][
'ranodefault'
]
=
true
;
}
elseif
(
isset
(
$config
[
'dhcpdv6'
][
$if
][
'ranodefault'
]))
{
unset
(
$config
[
'dhcpdv6'
][
$if
][
'ranodefault'
]);
}
$config
[
'dhcpdv6'
][
$if
][
'radomainsearchlist'
]
=
$pconfig
[
'radomainsearchlist'
];
$config
[
'dhcpdv6'
][
$if
][
'radomainsearchlist'
]
=
$pconfig
[
'radomainsearchlist'
];
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
]
=
array
();
$config
[
'dhcpdv6'
][
$if
][
'radnsserver'
]
=
array
();
if
(
!
empty
(
$pconfig
[
'radns1'
]))
{
if
(
!
empty
(
$pconfig
[
'radns1'
]))
{
...
@@ -130,6 +154,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...
@@ -130,6 +154,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
$config
[
'dhcpdv6'
][
$if
][
'rasamednsasdhcp6'
]
=
!
empty
(
$pconfig
[
'rasamednsasdhcp6'
]);
$config
[
'dhcpdv6'
][
$if
][
'rasamednsasdhcp6'
]
=
!
empty
(
$pconfig
[
'rasamednsasdhcp6'
]);
if
(
count
(
$pconfig
[
'raroutes'
]))
{
$config
[
'dhcpdv6'
][
$if
][
'raroutes'
]
=
implode
(
','
,
$pconfig
[
'raroutes'
]);
}
elseif
(
isset
(
$config
[
'dhcpdv6'
][
$if
][
'raroutes'
]))
{
unset
(
$config
[
'dhcpdv6'
][
$if
][
'raroutes'
]);
}
write_config
();
write_config
();
services_radvd_configure
();
services_radvd_configure
();
$savemsg
=
get_std_save_message
();
$savemsg
=
get_std_save_message
();
...
@@ -270,8 +300,75 @@ include("head.inc");
...
@@ -270,8 +300,75 @@ include("head.inc");
</td>
</td>
</tr>
</tr>
<?php
<?php
endif
;
?>
endif
?>
<tr>
<td><i
class=
"fa fa-info-circle text-muted"
></i>
<?=
gettext
(
'Advertise Default Gateway'
)
?>
</td>
<td>
<input
id=
"radefault"
name=
"radefault"
type=
"checkbox"
value=
"yes"
<?=
!
empty
(
$pconfig
[
'radefault'
])
?
'checked="checked"'
:
''
?>
/>
</td>
</tr>
<tr>
<td><a
id=
"help_for_raroutes"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
'Advertise Routes'
)
?>
</td>
<td>
<table
class=
"table table-striped table-condensed"
id=
"maintable"
>
<thead>
<tr>
<th></th>
<th>
<?=
gettext
(
'Prefix'
)
?>
</th>
<th>
<?=
gettext
(
'Length'
)
?>
</th>
</tr>
</thead>
<tbody>
<?php
$pconfig
[
'raroutes'
][]
=
''
;
foreach
(
$pconfig
[
'raroutes'
]
as
$item
)
:
$parts
=
explode
(
'/'
,
$item
);
if
(
count
(
$parts
)
>
1
)
{
$sn_bits
=
intval
(
$parts
[
1
]);
}
else
{
$sn_bits
=
null
;
}
$sn_address
=
$parts
[
0
];
?>
<tr>
<td>
<?php
if
(
!
empty
(
$item
))
:
?>
<label
class=
"act-removerow btn btn-default btn-xs"
>
<span
class=
"sr-only"
>
<?=
gettext
(
'Remove'
)
?>
</span>
<span
class=
"fa fa-minus"
></span>
</label>
<?php
else
:
?>
<label
id=
"addNew"
class=
"btn btn-default btn-xs"
>
<span
class=
"sr-only"
>
<?=
gettext
(
'Add'
)
?>
</span>
<span
class=
"fa fa-plus"
></span>
</label>
<?php
endif
?>
</td>
<td>
<input
name=
"route_address[]"
type=
"text"
value=
"
<?=
$sn_address
;
?>
"
/>
</td>
<td>
<select
name=
"route_bits[]"
>
<?php
for
(
$i
=
128
;
$i
>=
0
;
$i
-=
1
)
:
?>
<option
value=
"
<?=
$i
?>
"
<?=
$sn_bits
===
$i
?
'selected="selected"'
:
''
?>
>
<?=
$i
?>
</option>
<?php
endfor
?>
</select>
</td>
</tr>
<?php
endforeach
?>
</tbody>
</table>
<div
class=
"hidden"
for=
"help_for_raroutes"
>
<?=
gettext
(
'Routes are specified in CIDR format. The prefix of a route definition should be network prefix; it can be used to advertise more specific routes to the hosts.'
)
?>
</div>
</td>
</tr>
<tr>
<tr>
<td><a
id=
"help_for_radns"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"DNS servers"
);
?>
</td>
<td><a
id=
"help_for_radns"
href=
"#"
class=
"showhelp"
><i
class=
"fa fa-info-circle"
></i></a>
<?=
gettext
(
"DNS servers"
);
?>
</td>
<td>
<td>
...
...
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