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
39751b96
Commit
39751b96
authored
Apr 02, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge merge_config_section_xmlrpc, restore_config_section_xmlrpc back in after cleanup
parent
59e71355
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
legacy.inc
src/etc/inc/xmlrpc/legacy.inc
+141
-0
No files found.
src/etc/inc/xmlrpc/legacy.inc
View file @
39751b96
...
...
@@ -99,6 +99,7 @@ function interfaces_carp_configure_xmlrpc()
*/
function
filter_configure_xmlrpc
()
{
global
$config
;
require_once
(
"config.inc"
);
require_once
(
"filter.inc"
);
require_once
(
"system.inc"
);
...
...
@@ -128,3 +129,143 @@ function filter_configure_xmlrpc()
return
true
;
}
/**
* @param $confData array containing config data
* @return bool
*/
function
merge_config_section_xmlrpc
(
$confData
)
{
global
$config
;
require_once
(
"config.inc"
);
$config_new
=
array_overlay
(
$config
,
$confData
);
$config
=
$config_new
;
$mergedkeys
=
implode
(
","
,
array_keys
(
$confData
));
write_config
(
sprintf
(
gettext
(
"Merged in config (%s sections) from XMLRPC client."
),
$mergedkeys
));
return
true
;
}
/**
* restore config section
* @param $new_config
* @return bool
*/
function
restore_config_section_xmlrpc
(
$new_config
)
{
global
$config
;
require_once
(
"config.inc"
);
require_once
(
"interfaces.inc"
);
// TODO: initial cleanup operation performed, but a full rewrite is probably a better plan.
$old_config
=
$config
;
// Some sections should just be copied and not merged or we end
// up unable to sync the deletion of the last item in a section
$sync_full
=
array
(
'ipsec'
,
'aliases'
,
'wol'
,
'load_balancer'
,
'openvpn'
,
'cert'
,
'ca'
,
'crl'
,
'schedules'
,
'filter'
,
'nat'
,
'dhcpd'
,
'dhcpv6'
);
$sync_full_done
=
array
();
foreach
(
$sync_full
as
$syncfull
)
{
if
(
isset
(
$new_config
[
$syncfull
]))
{
$config
[
$syncfull
]
=
$new_config
[
$syncfull
];
unset
(
$new_config
[
$syncfull
]);
$sync_full_done
[]
=
$syncfull
;
}
}
$vipbackup
=
array
();
$oldvips
=
array
();
if
(
isset
(
$new_config
[
'virtualip'
]))
{
if
(
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vipindex
=>
$vip
)
{
if
(
$vip
[
'mode'
]
==
"carp"
)
$oldvips
[
"
{
$vip
[
'interface'
]
}
_vip
{
$vip
[
'vhid'
]
}
"
]
=
"
{
$vip
[
'password'
]
}{
$vip
[
'advskew'
]
}{
$vip
[
'subnet'
]
}{
$vip
[
'subnet_bits'
]
}{
$vip
[
'advbase'
]
}
"
;
else
if
(
$vip
[
'mode'
]
==
"ipalias"
&&
(
strstr
(
$vip
[
'interface'
],
"_vip"
)
||
strstr
(
$vip
[
'interface'
],
"lo0"
)))
$oldvips
[
$vip
[
'subnet'
]]
=
"
{
$vip
[
'interface'
]
}{
$vip
[
'subnet'
]
}{
$vip
[
'subnet_bits'
]
}
"
;
else
if
((
$vip
[
'mode'
]
==
"ipalias"
||
$vip
[
'mode'
]
==
'proxyarp'
)
&&
!
(
strstr
(
$vip
[
'interface'
],
"_vip"
)
||
strstr
(
$vip
[
'interface'
],
"lo0"
)))
$vipbackup
[]
=
$vip
;
}
}
}
// For vip section, first keep items sent from the master
$config
=
array_merge_recursive_unique
(
$config
,
$new_config
);
/* Then add ipalias and proxyarp types already defined on the backup */
if
(
is_array
(
$vipbackup
)
&&
!
empty
(
$vipbackup
))
{
if
(
!
is_array
(
$config
[
'virtualip'
]))
{
$config
[
'virtualip'
]
=
array
();
}
if
(
!
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
$config
[
'virtualip'
][
'vip'
]
=
array
();
}
foreach
(
$vipbackup
as
$vip
)
{
array_unshift
(
$config
[
'virtualip'
][
'vip'
],
$vip
);
}
}
/* Log what happened */
$mergedkeys
=
implode
(
","
,
array_merge
(
array_keys
(
$new_config
),
$sync_full_done
));
write_config
(
sprintf
(
gettext
(
"Merged in config (%s sections) from XMLRPC client."
),
$mergedkeys
));
/*
* The real work on handling the vips specially
* This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps
*/
if
(
isset
(
$new_config
[
'virtualip'
])
&&
is_array
(
$config
[
'virtualip'
])
&&
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
$carp_setuped
=
false
;
$anyproxyarp
=
false
;
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vip
)
{
if
(
$vip
[
'mode'
]
==
"carp"
&&
isset
(
$oldvips
[
"
{
$vip
[
'interface'
]
}
_vip
{
$vip
[
'vhid'
]
}
"
]))
{
if
(
$oldvips
[
"
{
$vip
[
'interface'
]
}
_vip
{
$vip
[
'vhid'
]
}
"
]
==
"
{
$vip
[
'password'
]
}{
$vip
[
'advskew'
]
}{
$vip
[
'subnet'
]
}{
$vip
[
'subnet_bits'
]
}{
$vip
[
'advbase'
]
}
"
)
{
if
(
does_vip_exist
(
$vip
))
{
unset
(
$oldvips
[
"
{
$vip
[
'interface'
]
}
_vip
{
$vip
[
'vhid'
]
}
"
]);
continue
;
// Skip reconfiguring this vips since nothing has changed.
}
}
unset
(
$oldvips
[
"
{
$vip
[
'interface'
]
}
_vip
{
$vip
[
'vhid'
]
}
"
]);
}
else
if
(
$vip
[
'mode'
]
==
"ipalias"
&&
strstr
(
$vip
[
'interface'
],
"_vip"
)
&&
isset
(
$oldvips
[
$vip
[
'subnet'
]]))
{
if
(
$oldvips
[
$vip
[
'subnet'
]]
==
"
{
$vip
[
'interface'
]
}{
$vip
[
'subnet'
]
}{
$vip
[
'subnet_bits'
]
}
"
)
{
if
(
does_vip_exist
(
$vip
))
{
unset
(
$oldvips
[
$vip
[
'subnet'
]]);
continue
;
// Skip reconfiguring this vips since nothing has changed.
}
}
unset
(
$oldvips
[
$vip
[
'subnet'
]]);
}
switch
(
$vip
[
'mode'
])
{
case
"proxyarp"
:
$anyproxyarp
=
true
;
break
;
case
"ipalias"
:
interface_ipalias_configure
(
$vip
);
break
;
case
"carp"
:
if
(
!
$carp_setuped
)
{
$carp_setuped
=
true
;
}
interface_carp_configure
(
$vip
);
break
;
}
}
if
(
$carp_setuped
)
{
interfaces_carp_setup
();
}
if
(
$anyproxyarp
)
{
interface_proxyarp_configure
();
}
}
if
(
isset
(
$old_config
[
'ipsec'
][
'enable'
])
!==
isset
(
$config
[
'ipsec'
][
'enable'
]))
{
vpn_ipsec_configure
();
}
unset
(
$old_config
);
return
true
;
}
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