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
d7dfa801
Commit
d7dfa801
authored
Mar 22, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) spaces and curly braces in openvpn_wizard.inc
parent
0af2ca39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
684 additions
and
626 deletions
+684
-626
openvpn_wizard.inc
src/etc/inc/openvpn_wizard.inc
+684
-626
No files found.
src/etc/inc/openvpn_wizard.inc
View file @
d7dfa801
<?php
<?php
/*
/*
Copyright (C) 2010 Ermal Luçi
Copyright (C) 2010 Ermal Luçi
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
POSSIBILITY OF SUCH DAMAGE.
*/
*/
require_once
(
"openvpn.inc"
);
require_once
(
"openvpn.inc"
);
require_once
(
"pfsense-utils.inc"
);
require_once
(
"pfsense-utils.inc"
);
function
cert_get_subject_hash
(
$crt
)
{
function
cert_get_subject_hash
(
$crt
)
$str_crt
=
base64_decode
(
$crt
);
{
$inf_crt
=
openssl_x509_parse
(
$str_crt
);
$str_crt
=
base64_decode
(
$crt
);
return
$inf_crt
[
'subject'
];
$inf_crt
=
openssl_x509_parse
(
$str_crt
);
return
$inf_crt
[
'subject'
];
}
}
function
has_special_chars
(
$text
)
{
function
has_special_chars
(
$text
)
return
preg_match
(
'/[^A-Za-z0-9 _-]/'
,
$text
);
{
return
preg_match
(
'/[^A-Za-z0-9 _-]/'
,
$text
);
}
}
function
step1_submitphpaction
()
{
function
step1_submitphpaction
()
global
$stepid
,
$config
;
{
if
(
$_POST
[
'authtype'
]
==
"local"
)
{
global
$stepid
,
$config
;
$stepid
=
4
;
if
(
$_POST
[
'authtype'
]
==
"local"
)
{
$config
[
'ovpnserver'
][
'step1'
][
'type'
]
=
"local"
;
$stepid
=
4
;
}
else
if
(
$_POST
[
'authtype'
]
==
"ldap"
)
{
$config
[
'ovpnserver'
][
'step1'
][
'type'
]
=
"local"
;
$stepid
=
0
;
}
elseif
(
$_POST
[
'authtype'
]
==
"ldap"
)
{
}
else
if
(
$_POST
[
'authtype'
]
==
"radius"
)
{
$stepid
=
0
;
$stepid
=
2
;
}
elseif
(
$_POST
[
'authtype'
]
==
"radius"
)
{
$config
[
'ovpnserver'
][
'step1'
][
'type'
]
=
"radius"
;
$stepid
=
2
;
unset
(
$config
[
'ovpnserver'
][
'step1'
][
'uselist'
]);
$config
[
'ovpnserver'
][
'step1'
][
'type'
]
=
"radius"
;
}
unset
(
$config
[
'ovpnserver'
][
'step1'
][
'uselist'
]);
}
}
}
function
step2_stepbeforeformdisplay
()
{
function
step2_stepbeforeformdisplay
()
global
$pkg
,
$stepid
;
{
global
$pkg
,
$stepid
;
$fields
=&
$pkg
[
'step'
][
1
][
'fields'
][
'field'
];
$fields
=&
$pkg
[
'step'
][
1
][
'fields'
][
'field'
];
$found
=
false
;
$authlist
=
auth_get_authserver_list
();
$found
=
false
;
$fields
[
1
][
'options'
][
'option'
]
=
array
();
$authlist
=
auth_get_authserver_list
();
foreach
(
$authlist
as
$key
=>
$auth
)
{
$fields
[
1
][
'options'
][
'option'
]
=
array
();
if
(
$auth
[
'type'
]
!=
'ldap'
)
{
foreach
(
$authlist
as
$key
=>
$auth
)
{
continue
;
if
(
$auth
[
'type'
]
!=
'ldap'
)
{
}
continue
;
$found
=
true
;
}
$opts
=
array
();
$found
=
true
;
$opts
[
'name'
]
=
$auth
[
'name'
];
$opts
=
array
();
$opts
[
'value'
]
=
$key
;
$opts
[
'name'
]
=
$auth
[
'name'
];
$fields
[
1
][
'options'
][
'option'
][]
=
$opts
;
$opts
[
'value'
]
=
$key
;
}
$fields
[
1
][
'options'
][
'option'
][]
=
$opts
;
if
(
$found
==
false
)
{
}
$stepid
=
2
;
if
(
$found
==
false
)
{
}
$stepid
=
2
;
}
}
}
function
step2_submitphpaction
()
{
function
step2_submitphpaction
()
global
$stepid
;
{
global
$stepid
;
if
(
isset
(
$_POST
[
'next'
]))
{
if
(
isset
(
$_POST
[
'next'
]))
{
$_POST
[
'uselist'
]
=
""
;
$_POST
[
'uselist'
]
=
""
;
$stepid
+=
3
;
$stepid
+=
3
;
}
}
}
}
function
step3_submitphpaction
()
{
function
step3_submitphpaction
()
{
global
$stepid
,
$savemsg
,
$config
;
global
$stepid
,
$savemsg
,
$config
;
/* Default LDAP port is 389 for TCP and 636 for SSL */
/* Default LDAP port is 389 for TCP and 636 for SSL */
if
(
empty
(
$_POST
[
'port'
]))
{
if
(
empty
(
$_POST
[
'port'
]))
{
if
(
$_POST
[
'transport'
]
==
"tcp"
)
if
(
$_POST
[
'transport'
]
==
"tcp"
)
{
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
389
;
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
389
;
elseif
(
$_POST
[
'transport'
]
==
"ssl"
)
}
elseif
(
$_POST
[
'transport'
]
==
"ssl"
)
{
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
636
;
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
636
;
}
elseif
(
!
is_port
(
$_POST
[
'port'
]))
{
}
$stepid
--
;
}
elseif
(
!
is_port
(
$_POST
[
'port'
]))
{
$savemsg
=
"Please enter a valid port number."
;
$stepid
--
;
}
$savemsg
=
"Please enter a valid port number."
;
}
if
(
empty
(
$_POST
[
'name'
])
||
empty
(
$_POST
[
'ip'
])
||
empty
(
$_POST
[
'transport'
])
||
empty
(
$_POST
[
'scope'
])
||
empty
(
$_POST
[
'basedn'
])
||
empty
(
$_POST
[
'authscope'
])
||
empty
(
$_POST
[
'nameattr'
]))
{
if
(
empty
(
$_POST
[
'name'
])
||
empty
(
$_POST
[
'ip'
])
||
empty
(
$_POST
[
'transport'
])
||
$stepid
--
;
empty
(
$_POST
[
'scope'
])
||
empty
(
$_POST
[
'basedn'
])
||
empty
(
$_POST
[
'authscope'
])
||
empty
(
$_POST
[
'nameattr'
]))
{
$savemsg
=
"Please enter all information for authentication server."
;
$stepid
--
;
}
else
if
(
count
((
$authcfg
=
auth_get_authserver
(
$_POST
[
'name'
])))
>
0
)
{
$savemsg
=
"Please enter all information for authentication server."
;
$stepid
--
;
}
elseif
(
count
((
$authcfg
=
auth_get_authserver
(
$_POST
[
'name'
])))
>
0
)
{
$savemsg
=
"Please choose a different name because an authentication server with this name already exists."
;
$stepid
--
;
}
elseif
(
!
is_fqdn
(
$_POST
[
'ip'
])
&&
!
is_ipaddr
(
$_POST
[
'ip'
]))
{
$savemsg
=
"Please choose a different name because an authentication server with this name already exists."
;
$stepid
--
;
}
elseif
(
!
is_fqdn
(
$_POST
[
'ip'
])
&&
!
is_ipaddr
(
$_POST
[
'ip'
]))
{
$savemsg
=
"Please enter a valid IP address or hostname for the authentication server."
;
$stepid
--
;
}
else
{
$savemsg
=
"Please enter a valid IP address or hostname for the authentication server."
;
$config
[
'ovpnserver'
][
'step2'
][
'uselist'
]
=
"on"
;
}
else
{
$_POST
[
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step2'
][
'uselist'
]
=
"on"
;
$stepid
+=
2
;
$_POST
[
'uselist'
]
=
"on"
;
}
$stepid
+=
2
;
}
}
}
function
step4_stepbeforeformdisplay
()
{
function
step4_stepbeforeformdisplay
()
{
global
$pkg
,
$stepid
;
global
$pkg
,
$stepid
;
$fields
=&
$pkg
[
'step'
][
3
][
'fields'
][
'field'
];
$fields
=&
$pkg
[
'step'
][
3
][
'fields'
][
'field'
];
$found
=
false
;
$found
=
false
;
$authlist
=
auth_get_authserver_list
();
$authlist
=
auth_get_authserver_list
();
$fields
[
1
][
'options'
][
'option'
]
=
array
();
$fields
[
1
][
'options'
][
'option'
]
=
array
();
foreach
(
$authlist
as
$key
=>
$auth
)
{
foreach
(
$authlist
as
$key
=>
$auth
)
{
if
(
$auth
[
'type'
]
!=
'radius'
)
{
if
(
$auth
[
'type'
]
!=
'radius'
)
{
continue
;
continue
;
}
}
$found
=
true
;
$found
=
true
;
$opts
=
array
();
$opts
=
array
();
$opts
[
'name'
]
=
$auth
[
'name'
];
$opts
[
'name'
]
=
$auth
[
'name'
];
$opts
[
'value'
]
=
$key
;
$opts
[
'value'
]
=
$key
;
$fields
[
1
][
'options'
][
'option'
][]
=
$opts
;
$fields
[
1
][
'options'
][
'option'
][]
=
$opts
;
}
}
if
(
$found
==
false
)
if
(
$found
==
false
)
{
$stepid
=
4
;
$stepid
=
4
;
}
}
}
function
step4_submitphpaction
()
{
function
step4_submitphpaction
()
global
$stepid
;
{
global
$stepid
;
if
(
isset
(
$_POST
[
'next'
]))
{
if
(
isset
(
$_POST
[
'next'
]))
{
$_POST
[
'uselist'
]
=
""
;
$_POST
[
'uselist'
]
=
""
;
$stepid
++
;
$stepid
++
;
}
}
}
}
function
step5_submitphpaction
()
{
function
step5_submitphpaction
()
global
$stepid
,
$savemsg
,
$config
;
{
global
$stepid
,
$savemsg
,
$config
;
/* Default RADIUS Auth port = 1812 */
if
(
empty
(
$_POST
[
'port'
]))
{
/* Default RADIUS Auth port = 1812 */
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
1812
;
if
(
empty
(
$_POST
[
'port'
]))
{
}
elseif
(
!
is_port
(
$_POST
[
'port'
]))
{
$config
[
'ovpnserver'
][
'step2'
][
'port'
]
=
1812
;
$stepid
--
;
}
elseif
(
!
is_port
(
$_POST
[
'port'
]))
{
$savemsg
=
"Please enter a valid port number."
;
$stepid
--
;
}
$savemsg
=
"Please enter a valid port number."
;
}
if
(
empty
(
$_POST
[
'name'
])
||
empty
(
$_POST
[
'ip'
])
||
empty
(
$_POST
[
'secret'
]))
{
$stepid
--
;
if
(
empty
(
$_POST
[
'name'
])
||
empty
(
$_POST
[
'ip'
])
||
empty
(
$_POST
[
'secret'
]))
{
$savemsg
=
"Please enter all information for authentication server."
;
$stepid
--
;
}
else
if
(
count
((
$authcfg
=
auth_get_authserver
(
$_POST
[
'name'
])))
>
0
)
{
$savemsg
=
"Please enter all information for authentication server."
;
$stepid
--
;
}
elseif
(
count
((
$authcfg
=
auth_get_authserver
(
$_POST
[
'name'
])))
>
0
)
{
$savemsg
=
"Please choose a different name because an authentication server with this name already exists."
;
$stepid
--
;
}
elseif
(
!
is_fqdn
(
$_POST
[
'ip'
])
&&
!
is_ipaddr
(
$_POST
[
'ip'
]))
{
$savemsg
=
"Please choose a different name because an authentication server with this name already exists."
;
$stepid
--
;
}
elseif
(
!
is_fqdn
(
$_POST
[
'ip'
])
&&
!
is_ipaddr
(
$_POST
[
'ip'
]))
{
$savemsg
=
"Please enter a valid IP address or hostname for the authentication server."
;
$stepid
--
;
}
else
{
$savemsg
=
"Please enter a valid IP address or hostname for the authentication server."
;
$config
[
'ovpnserver'
][
'step2'
][
'uselist'
]
=
"on"
;
}
else
{
$_POST
[
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step2'
][
'uselist'
]
=
"on"
;
}
$_POST
[
'uselist'
]
=
"on"
;
}
}
}
function
step6_stepbeforeformdisplay
()
{
function
step6_stepbeforeformdisplay
()
global
$stepid
,
$config
;
{
global
$stepid
,
$config
;
if
(
count
(
$config
[
'ca'
])
<
1
)
{
if
(
count
(
$config
[
'ca'
])
<
1
)
{
$stepid
++
;
$stepid
++
;
}
}
}
}
function
step6_submitphpaction
()
{
function
step6_submitphpaction
()
global
$stepid
,
$config
;
{
global
$stepid
,
$config
;
if
(
isset
(
$_POST
[
'next'
]))
{
$_POST
[
'uselist'
]
=
""
;
if
(
isset
(
$_POST
[
'next'
]))
{
unset
(
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]);
$_POST
[
'uselist'
]
=
""
;
$stepid
++
;
unset
(
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]);
}
else
{
$stepid
++
;
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
}
else
{
$_POST
[
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
}
$_POST
[
'uselist'
]
=
"on"
;
}
}
}
function
step7_submitphpaction
()
{
function
step7_submitphpaction
()
{
global
$input_errors
,
$stepid
,
$savemsg
,
$_POST
,
$config
;
global
$input_errors
,
$stepid
,
$savemsg
,
$_POST
,
$config
;
$canames
=
array
();
$canames
=
array
();
$cacns
=
array
();
$cacns
=
array
();
if
(
is_array
(
$config
[
'ca'
]))
{
if
(
is_array
(
$config
[
'ca'
]))
{
foreach
(
$config
[
'ca'
]
as
$ca
)
{
foreach
(
$config
[
'ca'
]
as
$ca
)
{
$canames
[]
=
$ca
[
'descr'
];
$canames
[]
=
$ca
[
'descr'
];
$cainfo
=
cert_get_subject_hash
(
$ca
[
'crt'
]);
$cainfo
=
cert_get_subject_hash
(
$ca
[
'crt'
]);
$cacns
[]
=
$cainfo
[
"CN"
];
$cacns
[]
=
$cainfo
[
"CN"
];
}
}
}
}
if
(
empty
(
$_POST
[
'descr'
])
||
empty
(
$_POST
[
'keylength'
])
||
empty
(
$_POST
[
'lifetime'
])
||
if
(
empty
(
$_POST
[
'descr'
])
||
empty
(
$_POST
[
'keylength'
])
||
empty
(
$_POST
[
'lifetime'
])
||
empty
(
$_POST
[
'country'
])
||
empty
(
$_POST
[
'state'
])
||
empty
(
$_POST
[
'city'
])
||
empty
(
$_POST
[
'country'
])
||
empty
(
$_POST
[
'state'
])
||
empty
(
$_POST
[
'city'
])
||
empty
(
$_POST
[
'organization'
])
||
empty
(
$_POST
[
'email'
]))
{
empty
(
$_POST
[
'organization'
])
||
empty
(
$_POST
[
'email'
]))
{
$stepid
--
;
$stepid
--
;
$savemsg
=
"Please enter all information for the new Certificate Authority."
;
$savemsg
=
"Please enter all information for the new Certificate Authority."
;
}
elseif
(
has_special_chars
(
$_POST
[
'country'
])
||
has_special_chars
(
$_POST
[
'state'
])
||
}
elseif
(
has_special_chars
(
$_POST
[
'country'
])
||
has_special_chars
(
$_POST
[
'state'
])
||
has_special_chars
(
$_POST
[
'city'
])
||
has_special_chars
(
$_POST
[
'organization'
]))
{
has_special_chars
(
$_POST
[
'city'
])
||
has_special_chars
(
$_POST
[
'organization'
]))
{
$stepid
--
;
$stepid
--
;
$input_errors
[]
=
gettext
(
"Please do not use special characters in Certificate field names."
);
$input_errors
[]
=
gettext
(
"Please do not use special characters in Certificate field names."
);
}
elseif
(
in_array
(
$_POST
[
'descr'
],
$canames
)
||
in_array
(
$_POST
[
'descr'
],
$cacns
))
{
}
elseif
(
in_array
(
$_POST
[
'descr'
],
$canames
)
||
in_array
(
$_POST
[
'descr'
],
$cacns
))
{
$stepid
--
;
$stepid
--
;
$savemsg
=
"Please enter a different name for the Certicicate Authority. A Certificate Authority with that name already exists."
;
$savemsg
=
"Please enter a different name for the Certicicate Authority. A Certificate Authority with that name already exists."
;
}
elseif
(
strlen
(
$_POST
[
'country'
])
!=
2
)
{
}
elseif
(
strlen
(
$_POST
[
'country'
])
!=
2
)
{
$stepid
--
;
$stepid
--
;
$savemsg
=
"Please enter only a two-letter ISO country code"
;
$savemsg
=
"Please enter only a two-letter ISO country code"
;
}
else
{
}
else
{
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
$_POST
[
'uselist'
]
=
"on"
;
$_POST
[
'uselist'
]
=
"on"
;
}
}
}
}
function
step8_stepbeforeformdisplay
()
{
function
step8_stepbeforeformdisplay
()
global
$stepid
,
$config
;
{
global
$stepid
,
$config
;
if
(
count
(
$config
[
'cert'
])
<
1
||
if
(
count
(
$config
[
'cert'
])
<
1
||
(
count
(
$config
[
'cert'
])
==
1
&&
stristr
(
$config
[
'cert'
][
0
][
'descr'
],
"webconf"
)))
{
(
count
(
$config
[
'cert'
])
==
1
&&
stristr
(
$config
[
'cert'
][
0
][
'descr'
],
"webconf"
)))
{
$stepid
++
;
$stepid
++
;
}
}
}
}
function
step8_submitphpaction
()
{
function
step8_submitphpaction
()
{
global
$stepid
,
$config
,
$_POST
;
global
$stepid
,
$config
,
$_POST
;
if
(
isset
(
$_POST
[
'next'
]))
{
if
(
isset
(
$_POST
[
'next'
]))
{
$_POST
[
'uselist'
]
=
""
;
$_POST
[
'uselist'
]
=
""
;
unset
(
$config
[
'ovpnserver'
][
'step9'
][
'uselist'
]);
unset
(
$config
[
'ovpnserver'
][
'step9'
][
'uselist'
]);
$stepid
++
;
$stepid
++
;
}
else
{
}
else
{
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step6'
][
'uselist'
]
=
"on"
;
$_POST
[
'uselist'
]
=
"on"
;
$_POST
[
'uselist'
]
=
"on"
;
}
}
}
}
function
step9_stepbeforeformdisplay
()
{
function
step9_stepbeforeformdisplay
()
{
global
$config
,
$pkg
,
$stepid
;
global
$config
,
$pkg
,
$stepid
;
$pconfig
=
$config
[
'ovpnserver'
];
$pconfig
=
$config
[
'ovpnserver'
];
if
(
isset
(
$pconfig
[
'step6'
][
'uselist'
]))
{
if
(
isset
(
$pconfig
[
'step6'
][
'uselist'
]))
{
$country
=
$pconfig
[
'step6'
][
'country'
];
$country
=
$pconfig
[
'step6'
][
'country'
];
$state
=
$pconfig
[
'step6'
][
'state'
];
$state
=
$pconfig
[
'step6'
][
'state'
];
$city
=
$pconfig
[
'step6'
][
'city'
];
$city
=
$pconfig
[
'step6'
][
'city'
];
$org
=
$pconfig
[
'step6'
][
'organization'
];
$org
=
$pconfig
[
'step6'
][
'organization'
];
$email
=
$pconfig
[
'step6'
][
'email'
];
$email
=
$pconfig
[
'step6'
][
'email'
];
}
else
{
}
else
{
$ca
=
lookup_ca
(
$pconfig
[
'step6'
][
'authcertca'
]);
$ca
=
lookup_ca
(
$pconfig
[
'step6'
][
'authcertca'
]);
$cavl
=
cert_get_subject_array
(
$ca
[
'crt'
]);
$cavl
=
cert_get_subject_array
(
$ca
[
'crt'
]);
$country
=
$cavl
[
0
][
'v'
];
$country
=
$cavl
[
0
][
'v'
];
$state
=
$cavl
[
1
][
'v'
];
$state
=
$cavl
[
1
][
'v'
];
$city
=
$cavl
[
2
][
'v'
];
$city
=
$cavl
[
2
][
'v'
];
$org
=
$cavl
[
3
][
'v'
];
$org
=
$cavl
[
3
][
'v'
];
$email
=
$cavl
[
4
][
'v'
];
$email
=
$cavl
[
4
][
'v'
];
}
}
$fields
=&
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
];
$fields
=&
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
];
foreach
(
$fields
as
$idx
=>
$field
)
{
foreach
(
$fields
as
$idx
=>
$field
)
{
switch
(
$field
[
'name'
])
{
switch
(
$field
[
'name'
])
{
case
'country'
:
case
'country'
:
$fields
[
$idx
][
'value'
]
=
$country
;
$fields
[
$idx
][
'value'
]
=
$country
;
break
;
break
;
case
'state'
:
case
'state'
:
$fields
[
$idx
][
'value'
]
=
$state
;
$fields
[
$idx
][
'value'
]
=
$state
;
break
;
break
;
case
'city'
:
case
'city'
:
$fields
[
$idx
][
'value'
]
=
$city
;
$fields
[
$idx
][
'value'
]
=
$city
;
break
;
break
;
case
'organization'
:
case
'organization'
:
$fields
[
$idx
][
'value'
]
=
$org
;
$fields
[
$idx
][
'value'
]
=
$org
;
break
;
break
;
case
'email'
:
case
'email'
:
$fields
[
$idx
][
'value'
]
=
$email
;
$fields
[
$idx
][
'value'
]
=
$email
;
break
;
break
;
}
}
}
}
}
}
function
step9_submitphpaction
()
{
function
step9_submitphpaction
()
global
$input_errors
,
$stepid
,
$savemsg
,
$_POST
,
$config
;
{
global
$input_errors
,
$stepid
,
$savemsg
,
$_POST
,
$config
;
$certnames
=
array
();
$certcns
=
array
();
$certnames
=
array
();
if
(
is_array
(
$config
[
'cert'
]))
{
$certcns
=
array
();
foreach
(
$config
[
'cert'
]
as
$cert
)
{
if
(
is_array
(
$config
[
'cert'
]))
{
$certnames
[]
=
$cert
[
'descr'
];
foreach
(
$config
[
'cert'
]
as
$cert
)
{
$certinfo
=
cert_get_subject_hash
(
$cert
[
'crt'
]);
$certnames
[]
=
$cert
[
'descr'
];
$certcns
[]
=
$certinfo
[
"CN"
];
$certinfo
=
cert_get_subject_hash
(
$cert
[
'crt'
]);
}
$certcns
[]
=
$certinfo
[
"CN"
];
}
}
}
if
(
empty
(
$_POST
[
'descr'
])
||
empty
(
$_POST
[
'keylength'
])
||
empty
(
$_POST
[
'lifetime'
])
||
empty
(
$_POST
[
'country'
])
||
empty
(
$_POST
[
'state'
])
||
empty
(
$_POST
[
'city'
])
||
if
(
empty
(
$_POST
[
'descr'
])
||
empty
(
$_POST
[
'keylength'
])
||
empty
(
$_POST
[
'lifetime'
])
||
empty
(
$_POST
[
'organization'
])
||
empty
(
$_POST
[
'email'
]))
{
empty
(
$_POST
[
'country'
])
||
empty
(
$_POST
[
'state'
])
||
empty
(
$_POST
[
'city'
])
||
$stepid
--
;
empty
(
$_POST
[
'organization'
])
||
empty
(
$_POST
[
'email'
]))
{
$savemsg
=
"Please enter all information for the new certificate."
;
$stepid
--
;
}
elseif
(
has_special_chars
(
$_POST
[
'country'
])
||
has_special_chars
(
$_POST
[
'state'
])
||
$savemsg
=
"Please enter all information for the new certificate."
;
has_special_chars
(
$_POST
[
'city'
])
||
has_special_chars
(
$_POST
[
'organization'
]))
{
}
elseif
(
has_special_chars
(
$_POST
[
'country'
])
||
has_special_chars
(
$_POST
[
'state'
])
||
$stepid
--
;
has_special_chars
(
$_POST
[
'city'
])
||
has_special_chars
(
$_POST
[
'organization'
]))
{
$input_errors
[]
=
gettext
(
"Please do not use special characters in Certificate field names."
);
$stepid
--
;
}
elseif
(
in_array
(
$_POST
[
'descr'
],
$certnames
)
||
in_array
(
$_POST
[
'descr'
],
$certcns
))
{
$input_errors
[]
=
gettext
(
"Please do not use special characters in Certificate field names."
);
$stepid
--
;
}
elseif
(
in_array
(
$_POST
[
'descr'
],
$certnames
)
||
in_array
(
$_POST
[
'descr'
],
$certcns
))
{
$savemsg
=
"Please enter a different name for the Certicicate. A Certificate with that name/common name already exists."
;
$stepid
--
;
}
elseif
(
strlen
(
$_POST
[
'country'
])
!=
2
)
{
$savemsg
=
"Please enter a different name for the Certicicate. A Certificate with that name/common name already exists."
;
$stepid
--
;
}
elseif
(
strlen
(
$_POST
[
'country'
])
!=
2
)
{
$savemsg
=
"Please enter only a two-letter ISO country code"
;
$stepid
--
;
}
else
{
$savemsg
=
"Please enter only a two-letter ISO country code"
;
$config
[
'ovpnserver'
][
'step9'
][
'uselist'
]
=
"on"
;
}
else
{
$_POST
[
'uselist'
]
=
"on"
;
$config
[
'ovpnserver'
][
'step9'
][
'uselist'
]
=
"on"
;
}
$_POST
[
'uselist'
]
=
"on"
;
}
}
}
function
step10_stepbeforeformdisplay
()
{
function
step10_stepbeforeformdisplay
()
global
$pkg
,
$stepid
,
$netbios_nodetypes
;
{
global
$pkg
,
$stepid
,
$netbios_nodetypes
;
foreach
(
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
]
as
$idx
=>
$field
)
{
if
(
$field
[
'name'
]
==
"crypto"
)
{
foreach
(
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
]
as
$idx
=>
$field
)
{
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
if
(
$field
[
'name'
]
==
"crypto"
)
{
$cipherlist
=
openvpn_get_cipherlist
();
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
foreach
(
$cipherlist
as
$name
=>
$desc
)
{
$cipherlist
=
openvpn_get_cipherlist
();
$opt
=
array
();
foreach
(
$cipherlist
as
$name
=>
$desc
)
{
$opt
[
'name'
]
=
$desc
;
$opt
=
array
();
$opt
[
'value'
]
=
$name
;
$opt
[
'name'
]
=
$desc
;
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
$opt
[
'value'
]
=
$name
;
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
}
else
if
(
$field
[
'name'
]
==
"digest"
)
{
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
}
elseif
(
$field
[
'name'
]
==
"digest"
)
{
$digestlist
=
openvpn_get_digestlist
();
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
foreach
(
$digestlist
as
$name
=>
$desc
)
{
$digestlist
=
openvpn_get_digestlist
();
$opt
=
array
();
foreach
(
$digestlist
as
$name
=>
$desc
)
{
$opt
[
'name'
]
=
$desc
;
$opt
=
array
();
$opt
[
'value'
]
=
$name
;
$opt
[
'name'
]
=
$desc
;
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
$opt
[
'value'
]
=
$name
;
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
}
else
if
(
$field
[
'name'
]
==
"compression"
)
{
}
global
$openvpn_compression_modes
;
}
elseif
(
$field
[
'name'
]
==
"compression"
)
{
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
global
$openvpn_compression_modes
;
foreach
(
$openvpn_compression_modes
as
$name
=>
$desc
)
{
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
$opt
=
array
();
foreach
(
$openvpn_compression_modes
as
$name
=>
$desc
)
{
$opt
[
'name'
]
=
$desc
;
$opt
=
array
();
$opt
[
'value'
]
=
$name
;
$opt
[
'name'
]
=
$desc
;
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
$opt
[
'value'
]
=
$name
;
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
}
else
if
(
$field
[
'name'
]
==
"engine"
)
{
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
}
elseif
(
$field
[
'name'
]
==
"engine"
)
{
$engines
=
openvpn_get_engines
();
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
foreach
(
$engines
as
$name
=>
$desc
)
{
$engines
=
openvpn_get_engines
();
$opt
=
array
();
foreach
(
$engines
as
$name
=>
$desc
)
{
$opt
[
'name'
]
=
$desc
;
$opt
=
array
();
$opt
[
'value'
]
=
$name
;
$opt
[
'name'
]
=
$desc
;
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
$opt
[
'value'
]
=
$name
;
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
}
else
if
(
$field
[
'name'
]
==
"nbttype"
)
{
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
}
elseif
(
$field
[
'name'
]
==
"nbttype"
)
{
foreach
(
$netbios_nodetypes
as
$type
=>
$name
)
{
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
]
=
array
();
$opt
=
array
();
foreach
(
$netbios_nodetypes
as
$type
=>
$name
)
{
$opt
[
'name'
]
=
$name
;
$opt
=
array
();
$opt
[
'value'
]
=
$type
;
$opt
[
'name'
]
=
$name
;
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
$opt
[
'value'
]
=
$type
;
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'options'
][
'option'
][]
=
$opt
;
}
else
if
(
$field
[
'name'
]
==
"localport"
)
{
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'value'
]
=
openvpn_port_next
(
'UDP'
);
}
elseif
(
$field
[
'name'
]
==
"localport"
)
{
}
$pkg
[
'step'
][
$stepid
][
'fields'
][
'field'
][
$idx
][
'value'
]
=
openvpn_port_next
(
'UDP'
);
}
}
}
}
}
function
step10_submitphpaction
()
{
function
step10_submitphpaction
()
global
$savemsg
,
$stepid
;
{
global
$savemsg
,
$stepid
;
/* Default OpenVPN port to next available port if left empty. */
if
(
empty
(
$_POST
[
'localport'
]))
/* Default OpenVPN port to next available port if left empty. */
$pconfig
[
"step10"
][
"localport"
]
=
openvpn_port_next
(
'UDP'
);
if
(
empty
(
$_POST
[
'localport'
]))
{
$pconfig
[
"step10"
][
"localport"
]
=
openvpn_port_next
(
'UDP'
);
/* input validation */
}
if
(
$result
=
openvpn_validate_port
(
$_POST
[
'localport'
],
'Local port'
))
$input_errors
[]
=
$result
;
/* input validation */
if
(
$result
=
openvpn_validate_port
(
$_POST
[
'localport'
],
'Local port'
))
{
if
(
$result
=
openvpn_validate_cidr
(
$_POST
[
'tunnelnet'
],
'Tunnel Network'
,
false
,
"ipv4"
))
$input_errors
[]
=
$result
;
$input_errors
[]
=
$result
;
}
if
(
$result
=
openvpn_validate_cidr
(
$_POST
[
'localnet'
],
'Local Network'
,
true
,
"ipv4"
))
if
(
$result
=
openvpn_validate_cidr
(
$_POST
[
'tunnelnet'
],
'Tunnel Network'
,
false
,
"ipv4"
))
{
$input_errors
[]
=
$result
;
$input_errors
[]
=
$result
;
}
$portused
=
openvpn_port_used
(
$_POST
[
'protocol'
],
$_POST
[
'interface'
],
$_POST
[
'localport'
]);
if
(
$portused
!=
0
)
if
(
$result
=
openvpn_validate_cidr
(
$_POST
[
'localnet'
],
'Local Network'
,
true
,
"ipv4"
))
{
$input_errors
[]
=
gettext
(
"The specified 'Local port' is in use. Please select another value."
);
$input_errors
[]
=
$result
;
}
if
(
!
isset
(
$_POST
[
'generatetlskey'
])
&&
isset
(
$_POST
[
'tlsauthentication'
]))
if
(
!
strstr
(
$_POST
[
'tlssharedkey'
],
"-----BEGIN OpenVPN Static key V1-----"
)
||
$portused
=
openvpn_port_used
(
$_POST
[
'protocol'
],
$_POST
[
'interface'
],
$_POST
[
'localport'
]);
!
strstr
(
$_POST
[
'tlssharedkey'
],
"-----END OpenVPN Static key V1-----"
))
if
(
$portused
!=
0
)
{
$input_errors
[]
=
gettext
(
"The field 'TLS Authentication Key' does not appear to be valid."
);
$input_errors
[]
=
gettext
(
"The specified 'Local port' is in use. Please select another value."
);
}
if
(
!
empty
(
$_POST
[
'dnsserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver1'
])))
$input_errors
[]
=
gettext
(
"The field 'DNS Server #1' must contain a valid IP address"
);
if
(
!
isset
(
$_POST
[
'generatetlskey'
])
&&
isset
(
$_POST
[
'tlsauthentication'
]))
{
if
(
!
empty
(
$_POST
[
'dnsserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver2'
])))
if
(
!
strstr
(
$_POST
[
'tlssharedkey'
],
"-----BEGIN OpenVPN Static key V1-----"
)
||
$input_errors
[]
=
gettext
(
"The field 'DNS Server #2' must contain a valid IP address"
);
!
strstr
(
$_POST
[
'tlssharedkey'
],
"-----END OpenVPN Static key V1-----"
))
{
if
(
!
empty
(
$_POST
[
'dnsserver3'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver3'
])))
$input_errors
[]
=
gettext
(
"The field 'TLS Authentication Key' does not appear to be valid."
);
$input_errors
[]
=
gettext
(
"The field 'DNS Server #3' must contain a valid IP address"
);
}
if
(
!
empty
(
$_POST
[
'dnsserver4'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver4'
])))
}
$input_errors
[]
=
gettext
(
"The field 'DNS Server #4' must contain a valid IP address"
);
if
(
!
empty
(
$_POST
[
'dnsserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver1'
])))
{
if
(
!
empty
(
$_POST
[
'ntpserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'ntpserver1'
])))
$input_errors
[]
=
gettext
(
"The field 'DNS Server #1' must contain a valid IP address"
);
$input_errors
[]
=
gettext
(
"The field 'NTP Server #1' must contain a valid IP address"
);
}
if
(
!
empty
(
$_POST
[
'ntpserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'ntpserver2'
])))
if
(
!
empty
(
$_POST
[
'dnsserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver2'
])))
{
$input_errors
[]
=
gettext
(
"The field 'NTP Server #2' must contain a valid IP address"
);
$input_errors
[]
=
gettext
(
"The field 'DNS Server #2' must contain a valid IP address"
);
}
if
(
!
empty
(
$_POST
[
'winsserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'winsserver1'
])))
if
(
!
empty
(
$_POST
[
'dnsserver3'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver3'
])))
{
$input_errors
[]
=
gettext
(
"The field 'WINS Server #1' must contain a valid IP address"
);
$input_errors
[]
=
gettext
(
"The field 'DNS Server #3' must contain a valid IP address"
);
if
(
!
empty
(
$_POST
[
'winsserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'winsserver2'
])))
}
$input_errors
[]
=
gettext
(
"The field 'WINS Server #2' must contain a valid IP address"
);
if
(
!
empty
(
$_POST
[
'dnsserver4'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'dnsserver4'
])))
{
$input_errors
[]
=
gettext
(
"The field 'DNS Server #4' must contain a valid IP address"
);
if
(
$_POST
[
'concurrentcon'
]
&&
!
is_numeric
(
$_POST
[
'concurrentcon'
]))
}
$input_errors
[]
=
gettext
(
"The field 'Concurrent connections' must be numeric."
);
if
(
!
empty
(
$_POST
[
'ntpserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'ntpserver1'
])))
{
if
(
empty
(
$_POST
[
'tunnelnet'
]))
$input_errors
[]
=
gettext
(
"The field 'NTP Server #1' must contain a valid IP address"
);
$input_errors
[]
=
gettext
(
"You must specify a 'Tunnel network'."
);
}
if
(
!
empty
(
$_POST
[
'ntpserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'ntpserver2'
])))
{
if
(
count
(
$input_errors
)
>
0
)
{
$input_errors
[]
=
gettext
(
"The field 'NTP Server #2' must contain a valid IP address"
);
$savemsg
=
$input_errors
[
0
];
}
$stepid
=
$stepid
-
1
;
}
if
(
!
empty
(
$_POST
[
'winsserver1'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'winsserver1'
])))
{
$input_errors
[]
=
gettext
(
"The field 'WINS Server #1' must contain a valid IP address"
);
}
if
(
!
empty
(
$_POST
[
'winsserver2'
])
&&
!
is_ipaddr
(
trim
(
$_POST
[
'winsserver2'
])))
{
$input_errors
[]
=
gettext
(
"The field 'WINS Server #2' must contain a valid IP address"
);
}
if
(
$_POST
[
'concurrentcon'
]
&&
!
is_numeric
(
$_POST
[
'concurrentcon'
]))
{
$input_errors
[]
=
gettext
(
"The field 'Concurrent connections' must be numeric."
);
}
if
(
empty
(
$_POST
[
'tunnelnet'
]))
{
$input_errors
[]
=
gettext
(
"You must specify a 'Tunnel network'."
);
}
if
(
count
(
$input_errors
)
>
0
)
{
$savemsg
=
$input_errors
[
0
];
$stepid
=
$stepid
-
1
;
}
}
}
function
step12_submitphpaction
()
{
function
step12_submitphpaction
()
global
$config
;
{
global
$config
;
$pconfig
=
$config
[
'ovpnserver'
];
$pconfig
=
$config
[
'ovpnserver'
];
if
(
!
is_array
(
$config
[
'ovpnserver'
]))
{
$message
=
"No configuration found please retry again."
;
if
(
!
is_array
(
$config
[
'ovpnserver'
]))
{
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
$message
=
"No configuration found please retry again."
;
exit
;
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
}
exit
;
}
if
(
$pconfig
[
'step1'
][
'type'
]
==
"local"
)
{
$auth
=
array
();
if
(
$pconfig
[
'step1'
][
'type'
]
==
"local"
)
{
$auth
[
'name'
]
=
"Local Database"
;
$auth
=
array
();
$auth
[
'type'
]
=
"local"
;
$auth
[
'name'
]
=
"Local Database"
;
}
else
if
(
isset
(
$pconfig
[
'step2'
][
'uselist'
]))
{
$auth
[
'type'
]
=
"local"
;
$auth
=
array
();
}
elseif
(
isset
(
$pconfig
[
'step2'
][
'uselist'
]))
{
$auth
[
'type'
]
=
$pconfig
[
'step1'
][
'type'
];
$auth
=
array
();
$auth
[
'refid'
]
=
uniqid
();
$auth
[
'type'
]
=
$pconfig
[
'step1'
][
'type'
];
$auth
[
'name'
]
=
$pconfig
[
'step2'
][
'authtype'
];
$auth
[
'refid'
]
=
uniqid
();
$auth
[
'name'
]
=
$pconfig
[
'step2'
][
'authtype'
];
if
(
$auth
[
'type'
]
==
"ldap"
)
{
$auth
[
'host'
]
=
$pconfig
[
'step2'
][
'ip'
];
if
(
$auth
[
'type'
]
==
"ldap"
)
{
$auth
[
'ldap_port'
]
=
$pconfig
[
'step2'
][
'port'
];
$auth
[
'host'
]
=
$pconfig
[
'step2'
][
'ip'
];
if
(
$pconfig
[
'step1'
][
'transport'
]
==
"tcp"
)
$auth
[
'ldap_port'
]
=
$pconfig
[
'step2'
][
'port'
];
$auth
[
'ldap_urltype'
]
=
'TCP - Standard'
;
if
(
$pconfig
[
'step1'
][
'transport'
]
==
"tcp"
)
{
else
$auth
[
'ldap_urltype'
]
=
'TCP - Standard'
;
$auth
[
'ldap_urltype'
]
=
'SSL - Encrypted'
;
}
else
{
$auth
[
'ldap_protver'
]
=
3
;
$auth
[
'ldap_urltype'
]
=
'SSL - Encrypted'
;
$auth
[
'ldap_scope'
]
=
$pconfig
[
'step2'
][
'scope'
];
}
$auth
[
'ldap_basedn'
]
=
$pconfig
[
'step2'
][
'basedn'
];
$auth
[
'ldap_protver'
]
=
3
;
$auth
[
'ldap_authcn'
]
=
$pconfig
[
'step2'
][
'authscope'
];
$auth
[
'ldap_scope'
]
=
$pconfig
[
'step2'
][
'scope'
];
$auth
[
'ldap_binddn'
]
=
$pconfig
[
'step2'
][
'userdn'
];
$auth
[
'ldap_basedn'
]
=
$pconfig
[
'step2'
][
'basedn'
];
$auth
[
'ldap_bindpw'
]
=
$pconfig
[
'step2'
][
'passdn'
];
$auth
[
'ldap_authcn'
]
=
$pconfig
[
'step2'
][
'authscope'
];
$auth
[
'ldap_attr_user'
]
=
$pconfig
[
'step1'
][
'nameattr'
];
$auth
[
'ldap_binddn'
]
=
$pconfig
[
'step2'
][
'userdn'
];
$auth
[
'ldap_attr_member'
]
=
$pconfig
[
'step1'
][
'memberattr'
];
$auth
[
'ldap_bindpw'
]
=
$pconfig
[
'step2'
][
'passdn'
];
$auth
[
'ldap_attr_group'
]
=
$pconfig
[
'step1'
][
'groupattr'
];
$auth
[
'ldap_attr_user'
]
=
$pconfig
[
'step1'
][
'nameattr'
];
}
else
if
(
$auth
[
'type'
]
==
"radius"
)
{
$auth
[
'ldap_attr_member'
]
=
$pconfig
[
'step1'
][
'memberattr'
];
$auth
[
'host'
]
=
$pconfig
[
'step2'
][
'ip'
];
$auth
[
'ldap_attr_group'
]
=
$pconfig
[
'step1'
][
'groupattr'
];
$auth
[
'radius_auth_port'
]
=
$pconfig
[
'step2'
][
'port'
];
}
elseif
(
$auth
[
'type'
]
==
"radius"
)
{
$auth
[
'radius_secret'
]
=
$pconfig
[
'step2'
][
'password'
];
$auth
[
'host'
]
=
$pconfig
[
'step2'
][
'ip'
];
$auth
[
'radius_srvcs'
]
=
"auth"
;
$auth
[
'radius_auth_port'
]
=
$pconfig
[
'step2'
][
'port'
];
}
$auth
[
'radius_secret'
]
=
$pconfig
[
'step2'
][
'password'
];
if
(
!
is_array
(
$config
[
'system'
][
'authserver'
]))
$auth
[
'radius_srvcs'
]
=
"auth"
;
$config
[
'system'
][
'authserver'
]
=
array
();
}
if
(
!
is_array
(
$config
[
'system'
][
'authserver'
]))
{
$config
[
'system'
][
'authserver'
][]
=
$auth
;
$config
[
'system'
][
'authserver'
]
=
array
();
}
else
if
(
!
isset
(
$pconfig
[
'step2'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step2'
][
'authserv'
]))
{
}
$message
=
"Please choose an authentication server ."
;
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
$config
[
'system'
][
'authserver'
][]
=
$auth
;
exit
;
}
elseif
(
!
isset
(
$pconfig
[
'step2'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step2'
][
'authserv'
]))
{
}
else
if
(
!
(
$auth
=
auth_get_authserver
(
$pconfig
[
'step2'
][
'authserv'
])))
{
$message
=
"Please choose an authentication server ."
;
$message
=
"Not a valid authentication server has been specified."
;
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
exit
;
exit
;
}
elseif
(
!
(
$auth
=
auth_get_authserver
(
$pconfig
[
'step2'
][
'authserv'
])))
{
}
$message
=
"Not a valid authentication server has been specified."
;
header
(
"Location:wizard.php?xml=openvpn&stepid=1&message=
{
$message
}
"
);
if
(
isset
(
$pconfig
[
'step6'
][
'uselist'
])
&&
!
empty
(
$pconfig
[
'step6'
][
'certca'
]))
{
exit
;
$ca
=
array
();
}
$ca
[
'refid'
]
=
uniqid
();
$ca
[
'descr'
]
=
$pconfig
[
'step6'
][
'certca'
];
if
(
isset
(
$pconfig
[
'step6'
][
'uselist'
])
&&
!
empty
(
$pconfig
[
'step6'
][
'certca'
]))
{
$dn
=
array
(
$ca
=
array
();
'countryName'
=>
$pconfig
[
'step6'
][
'country'
],
$ca
[
'refid'
]
=
uniqid
();
'stateOrProvinceName'
=>
$pconfig
[
'step6'
][
'state'
],
$ca
[
'descr'
]
=
$pconfig
[
'step6'
][
'certca'
];
'localityName'
=>
$pconfig
[
'step6'
][
'city'
],
$dn
=
array
(
'organizationName'
=>
$pconfig
[
'step6'
][
'organization'
],
'countryName'
=>
$pconfig
[
'step6'
][
'country'
],
'emailAddress'
=>
$pconfig
[
'step6'
][
'email'
],
'stateOrProvinceName'
=>
$pconfig
[
'step6'
][
'state'
],
'commonName'
=>
$pconfig
[
'step6'
][
'certca'
]);
'localityName'
=>
$pconfig
[
'step6'
][
'city'
],
'organizationName'
=>
$pconfig
[
'step6'
][
'organization'
],
ca_create
(
$ca
,
$pconfig
[
'step6'
][
'keylength'
],
$pconfig
[
'step6'
][
'lifetime'
],
$dn
,
"sha256"
);
'emailAddress'
=>
$pconfig
[
'step6'
][
'email'
],
if
(
!
is_array
(
$config
[
'ca'
]))
'commonName'
=>
$pconfig
[
'step6'
][
'certca'
]);
$config
[
'ca'
]
=
array
();
ca_create
(
$ca
,
$pconfig
[
'step6'
][
'keylength'
],
$pconfig
[
'step6'
][
'lifetime'
],
$dn
,
"sha256"
);
$config
[
'ca'
][]
=
$ca
;
if
(
!
is_array
(
$config
[
'ca'
]))
{
}
else
if
(
!
isset
(
$pconfig
[
'step6'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step6'
][
'authcertca'
]))
{
$config
[
'ca'
]
=
array
();
$message
=
"Please choose a Certificate Authority."
;
}
header
(
"Location:wizard.php?xml=openvpn&stepid=5&message=
{
$message
}
"
);
exit
;
$config
[
'ca'
][]
=
$ca
;
}
else
if
(
!
(
$ca
=
lookup_ca
(
$pconfig
[
'step6'
][
'authcertca'
])))
{
}
elseif
(
!
isset
(
$pconfig
[
'step6'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step6'
][
'authcertca'
]))
{
$message
=
"Not a valid Certificate Authority specified."
;
$message
=
"Please choose a Certificate Authority."
;
header
(
"Location:wizard.php?xml=openvpn&stepid=5&message=
{
$message
}
"
);
header
(
"Location:wizard.php?xml=openvpn&stepid=5&message=
{
$message
}
"
);
exit
;
exit
;
}
}
elseif
(
!
(
$ca
=
lookup_ca
(
$pconfig
[
'step6'
][
'authcertca'
])))
{
$message
=
"Not a valid Certificate Authority specified."
;
if
(
isset
(
$pconfig
[
'step9'
][
'uselist'
]))
{
header
(
"Location:wizard.php?xml=openvpn&stepid=5&message=
{
$message
}
"
);
$cert
=
array
();
exit
;
$cert
[
'refid'
]
=
uniqid
();
}
$cert
[
'descr'
]
=
$pconfig
[
'step9'
][
'certname'
];
$dn
=
array
(
if
(
isset
(
$pconfig
[
'step9'
][
'uselist'
]))
{
'countryName'
=>
$pconfig
[
'step9'
][
'country'
],
$cert
=
array
();
'stateOrProvinceName'
=>
$pconfig
[
'step9'
][
'state'
],
$cert
[
'refid'
]
=
uniqid
();
'localityName'
=>
$pconfig
[
'step9'
][
'city'
],
$cert
[
'descr'
]
=
$pconfig
[
'step9'
][
'certname'
];
'organizationName'
=>
$pconfig
[
'step9'
][
'organization'
],
$dn
=
array
(
'emailAddress'
=>
$pconfig
[
'step9'
][
'email'
],
'countryName'
=>
$pconfig
[
'step9'
][
'country'
],
'commonName'
=>
$pconfig
[
'step9'
][
'certname'
]
'stateOrProvinceName'
=>
$pconfig
[
'step9'
][
'state'
],
);
'localityName'
=>
$pconfig
[
'step9'
][
'city'
],
'organizationName'
=>
$pconfig
[
'step9'
][
'organization'
],
cert_create
(
$cert
,
$ca
[
'refid'
],
$pconfig
[
'step9'
][
'keylength'
],
$pconfig
[
'step9'
][
'lifetime'
],
$dn
,
'sha256'
,
'server_cert'
);
'emailAddress'
=>
$pconfig
[
'step9'
][
'email'
],
'commonName'
=>
$pconfig
[
'step9'
][
'certname'
]
if
(
!
is_array
(
$config
[
'cert'
]))
{
);
$config
[
'cert'
]
=
array
();
}
cert_create
(
$cert
,
$ca
[
'refid'
],
$pconfig
[
'step9'
][
'keylength'
],
$pconfig
[
'step9'
][
'lifetime'
],
$dn
,
'sha256'
,
'server_cert'
);
$config
[
'cert'
][]
=
$cert
;
if
(
!
is_array
(
$config
[
'cert'
]))
{
}
else
if
(
!
isset
(
$pconfig
[
'step9'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step9'
][
'authcertname'
]))
{
$config
[
'cert'
]
=
array
();
$message
=
"Please choose a Certificate."
;
}
header
(
"Location:wizard.php?xml=openvpn&stepid=7&message=
{
$message
}
"
);
exit
;
$config
[
'cert'
][]
=
$cert
;
}
else
if
(
!
(
$cert
=
lookup_cert
(
$pconfig
[
'step9'
][
'authcertname'
])))
{
}
elseif
(
!
isset
(
$pconfig
[
'step9'
][
'uselist'
])
&&
empty
(
$pconfig
[
'step9'
][
'authcertname'
]))
{
$message
=
"Not a valid Certificate specified."
;
$message
=
"Please choose a Certificate."
;
header
(
"Location:wizard.php?xml=openvpn&stepid=7&message=
{
$message
}
"
);
header
(
"Location:wizard.php?xml=openvpn&stepid=7&message=
{
$message
}
"
);
exit
;
exit
;
}
}
elseif
(
!
(
$cert
=
lookup_cert
(
$pconfig
[
'step9'
][
'authcertname'
])))
{
$server
=
array
();
$message
=
"Not a valid Certificate specified."
;
$server
[
'vpnid'
]
=
openvpn_vpnid_next
();
header
(
"Location:wizard.php?xml=openvpn&stepid=7&message=
{
$message
}
"
);
switch
(
$auth
[
'type'
])
{
exit
;
case
"ldap"
:
}
$server
[
'authmode'
]
=
$auth
[
'name'
];
$server
=
array
();
$server
[
'mode'
]
=
"server_user"
;
$server
[
'vpnid'
]
=
openvpn_vpnid_next
();
break
;
switch
(
$auth
[
'type'
])
{
case
"radius"
:
case
"ldap"
:
$server
[
'authmode'
]
=
$auth
[
'name'
];
$server
[
'authmode'
]
=
$auth
[
'name'
];
$server
[
'mode'
]
=
"server_user"
;
$server
[
'mode'
]
=
"server_user"
;
break
;
break
;
default
:
case
"radius"
:
$server
[
'authmode'
]
=
"Local Database"
;
$server
[
'authmode'
]
=
$auth
[
'name'
];
$server
[
'mode'
]
=
"server_tls_user"
;
$server
[
'mode'
]
=
"server_user"
;
break
;
break
;
}
default
:
$server
[
'caref'
]
=
$ca
[
'refid'
];
$server
[
'authmode'
]
=
"Local Database"
;
$server
[
'certref'
]
=
$cert
[
'refid'
];
$server
[
'mode'
]
=
"server_tls_user"
;
$server
[
'protocol'
]
=
$pconfig
[
'step10'
][
'protocol'
];
break
;
$server
[
'interface'
]
=
$pconfig
[
'step10'
][
'interface'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'localport'
]))
$server
[
'caref'
]
=
$ca
[
'refid'
];
$server
[
'local_port'
]
=
$pconfig
[
'step10'
][
'localport'
];
$server
[
'certref'
]
=
$cert
[
'refid'
];
$server
[
'protocol'
]
=
$pconfig
[
'step10'
][
'protocol'
];
if
(
strlen
(
$pconfig
[
'step10'
][
'descr'
])
>
30
)
$server
[
'interface'
]
=
$pconfig
[
'step10'
][
'interface'
];
$pconfig
[
'step10'
][
'descr'
]
=
substr
(
$pconfig
[
'step10'
][
'descr'
],
0
,
30
);
if
(
isset
(
$pconfig
[
'step10'
][
'localport'
]))
{
$server
[
'description'
]
=
$pconfig
[
'step10'
][
'descr'
];
$server
[
'local_port'
]
=
$pconfig
[
'step10'
][
'localport'
];
$server
[
'custom_options'
]
=
$pconfig
[
'step10'
][
'advanced'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'tlsauth'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'gentlskey'
]))
if
(
strlen
(
$pconfig
[
'step10'
][
'descr'
])
>
30
)
{
$tlskey
=
openvpn_create_key
();
$pconfig
[
'step10'
][
'descr'
]
=
substr
(
$pconfig
[
'step10'
][
'descr'
],
0
,
30
);
else
}
$tlskey
=
$pconfig
[
'step10'
][
'tlskey'
];
$server
[
'description'
]
=
$pconfig
[
'step10'
][
'descr'
];
$server
[
'tls'
]
=
base64_encode
(
$tlskey
);
$server
[
'custom_options'
]
=
$pconfig
[
'step10'
][
'advanced'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'tlsauth'
]))
{
$server
[
'dh_length'
]
=
$pconfig
[
'step10'
][
'dhkey'
];
if
(
isset
(
$pconfig
[
'step10'
][
'gentlskey'
]))
{
$server
[
'tunnel_network'
]
=
$pconfig
[
'step10'
][
'tunnelnet'
];
$tlskey
=
openvpn_create_key
();
if
(
isset
(
$pconfig
[
'step10'
][
'rdrgw'
]))
}
else
{
$server
[
'gwredir'
]
=
$pconfig
[
'step10'
][
'rdrgw'
];
$tlskey
=
$pconfig
[
'step10'
][
'tlskey'
];
if
(
isset
(
$pconfig
[
'step10'
][
'localnet'
]))
}
$server
[
'local_network'
]
=
$pconfig
[
'step10'
][
'localnet'
];
$server
[
'tls'
]
=
base64_encode
(
$tlskey
);
if
(
isset
(
$pconfig
[
'step10'
][
'concurrentcon'
]))
}
$server
[
'maxclients'
]
=
$pconfig
[
'step10'
][
'concurrentcon'
];
$server
[
'dh_length'
]
=
$pconfig
[
'step10'
][
'dhkey'
];
if
(
isset
(
$pconfig
[
'step10'
][
'compression'
]))
$server
[
'tunnel_network'
]
=
$pconfig
[
'step10'
][
'tunnelnet'
];
$server
[
'compression'
]
=
$pconfig
[
'step10'
][
'compression'
];
if
(
isset
(
$pconfig
[
'step10'
][
'rdrgw'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'tos'
]))
$server
[
'gwredir'
]
=
$pconfig
[
'step10'
][
'rdrgw'
];
$server
[
'passtos'
]
=
$pconfig
[
'step10'
][
'tos'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'interclient'
]))
if
(
isset
(
$pconfig
[
'step10'
][
'localnet'
]))
{
$server
[
'client2client'
]
=
$pconfig
[
'step10'
][
'interclient'
];
$server
[
'local_network'
]
=
$pconfig
[
'step10'
][
'localnet'
];
if
(
isset
(
$pconfig
[
'step10'
][
'duplicate_cn'
]))
}
$server
[
'duplicate_cn'
]
=
$pconfig
[
'step10'
][
'duplicate_cn'
];
if
(
isset
(
$pconfig
[
'step10'
][
'concurrentcon'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'dynip'
]))
$server
[
'maxclients'
]
=
$pconfig
[
'step10'
][
'concurrentcon'
];
$server
[
'dynamic_ip'
]
=
$pconfig
[
'step10'
][
'dynip'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'addrpool'
]))
if
(
isset
(
$pconfig
[
'step10'
][
'compression'
]))
{
$server
[
'pool_enable'
]
=
$pconfig
[
'step10'
][
'addrpool'
];
$server
[
'compression'
]
=
$pconfig
[
'step10'
][
'compression'
];
if
(
isset
(
$pconfig
[
'step10'
][
'defaultdomain'
]))
}
$server
[
'dns_domain'
]
=
$pconfig
[
'step10'
][
'defaultdomain'
];
if
(
isset
(
$pconfig
[
'step10'
][
'tos'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'dns1'
]))
$server
[
'passtos'
]
=
$pconfig
[
'step10'
][
'tos'
];
$server
[
'dns_server1'
]
=
$pconfig
[
'step10'
][
'dns1'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'dns2'
]))
if
(
isset
(
$pconfig
[
'step10'
][
'interclient'
]))
{
$server
[
'dns_server2'
]
=
$pconfig
[
'step10'
][
'dns2'
];
$server
[
'client2client'
]
=
$pconfig
[
'step10'
][
'interclient'
];
if
(
isset
(
$pconfig
[
'step10'
][
'dns3'
]))
}
$server
[
'dns_server3'
]
=
$pconfig
[
'step10'
][
'dns3'
];
if
(
isset
(
$pconfig
[
'step10'
][
'duplicate_cn'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'dns4'
]))
$server
[
'duplicate_cn'
]
=
$pconfig
[
'step10'
][
'duplicate_cn'
];
$server
[
'dns_server4'
]
=
$pconfig
[
'step10'
][
'dns4'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'ntp1'
]))
if
(
isset
(
$pconfig
[
'step10'
][
'dynip'
]))
{
$server
[
'ntp_server1'
]
=
$pconfig
[
'step10'
][
'ntp1'
];
$server
[
'dynamic_ip'
]
=
$pconfig
[
'step10'
][
'dynip'
];
if
(
isset
(
$pconfig
[
'step10'
][
'ntp2'
]))
}
$server
[
'ntp_server2'
]
=
$pconfig
[
'step10'
][
'ntp2'
];
if
(
isset
(
$pconfig
[
'step10'
][
'addrpool'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'wins1'
]))
$server
[
'pool_enable'
]
=
$pconfig
[
'step10'
][
'addrpool'
];
$server
[
'wins_server1'
]
=
$pconfig
[
'step10'
][
'wins1'
];
}
if
(
isset
(
$pconfig
[
'step10'
][
'wins2'
]))
if
(
isset
(
$pconfig
[
'step10'
][
'defaultdomain'
]))
{
$server
[
'wins_server2'
]
=
$pconfig
[
'step10'
][
'wins2'
];
$server
[
'dns_domain'
]
=
$pconfig
[
'step10'
][
'defaultdomain'
];
if
(
isset
(
$pconfig
[
'step10'
][
'nbtenable'
]))
{
}
$server
[
'netbios_ntype'
]
=
$pconfig
[
'step10'
][
'nbttype'
];
if
(
isset
(
$pconfig
[
'step10'
][
'dns1'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'nbtscope'
]))
$server
[
'dns_server1'
]
=
$pconfig
[
'step10'
][
'dns1'
];
$server
[
'netbios_scope'
]
=
$pconfig
[
'step10'
][
'nbtscope'
];
}
$server
[
'netbios_enable'
]
=
$pconfig
[
'step10'
][
'nbtenable'
];
if
(
isset
(
$pconfig
[
'step10'
][
'dns2'
]))
{
}
$server
[
'dns_server2'
]
=
$pconfig
[
'step10'
][
'dns2'
];
$server
[
'crypto'
]
=
$pconfig
[
'step10'
][
'crypto'
];
}
$server
[
'digest'
]
=
$pconfig
[
'step10'
][
'digest'
];
if
(
isset
(
$pconfig
[
'step10'
][
'dns3'
]))
{
$server
[
'engine'
]
=
$pconfig
[
'step10'
][
'engine'
];
$server
[
'dns_server3'
]
=
$pconfig
[
'step10'
][
'dns3'
];
}
if
(
isset
(
$pconfig
[
'step11'
][
'ovpnrule'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'dns4'
]))
{
$rule
=
array
();
$server
[
'dns_server4'
]
=
$pconfig
[
'step10'
][
'dns4'
];
$rule
[
'descr'
]
=
sprintf
(
gettext
(
"OpenVPN %s wizard"
),
$server
[
'description'
]);
}
/* Ensure the rule descr is not too long for pf to handle */
if
(
isset
(
$pconfig
[
'step10'
][
'ntp1'
]))
{
if
(
strlen
(
$rule
[
'descr'
])
>
52
)
$server
[
'ntp_server1'
]
=
$pconfig
[
'step10'
][
'ntp1'
];
$rule
[
'descr'
]
=
substr
(
$rule
[
'descr'
],
0
,
52
);
}
$rule
[
'direction'
]
=
"in"
;
if
(
isset
(
$pconfig
[
'step10'
][
'ntp2'
]))
{
$rule
[
'source'
][
'any'
]
=
TRUE
;
$server
[
'ntp_server2'
]
=
$pconfig
[
'step10'
][
'ntp2'
];
$rule
[
'destination'
][
'network'
]
=
$server
[
'interface'
]
.
"ip"
;
}
$rule
[
'destination'
][
'port'
]
=
$server
[
'local_port'
];
if
(
isset
(
$pconfig
[
'step10'
][
'wins1'
]))
{
$rule
[
'interface'
]
=
$server
[
'interface'
];
$server
[
'wins_server1'
]
=
$pconfig
[
'step10'
][
'wins1'
];
$rule
[
'protocol'
]
=
strtolower
(
$server
[
'protocol'
]);
}
$rule
[
'type'
]
=
"pass"
;
if
(
isset
(
$pconfig
[
'step10'
][
'wins2'
]))
{
$rule
[
'enabled'
]
=
"on"
;
$server
[
'wins_server2'
]
=
$pconfig
[
'step10'
][
'wins2'
];
$rule
[
'created'
]
=
make_config_revision_entry
();
}
$config
[
'filter'
][
'rule'
][]
=
$rule
;
if
(
isset
(
$pconfig
[
'step10'
][
'nbtenable'
]))
{
}
$server
[
'netbios_ntype'
]
=
$pconfig
[
'step10'
][
'nbttype'
];
if
(
isset
(
$pconfig
[
'step11'
][
'ovpnallow'
]))
{
if
(
isset
(
$pconfig
[
'step10'
][
'nbtscope'
]))
{
$rule
=
array
();
$server
[
'netbios_scope'
]
=
$pconfig
[
'step10'
][
'nbtscope'
];
$rule
[
'descr'
]
=
sprintf
(
gettext
(
"OpenVPN %s wizard"
),
$server
[
'description'
]);
}
/* Ensure the rule descr is not too long for pf to handle */
$server
[
'netbios_enable'
]
=
$pconfig
[
'step10'
][
'nbtenable'
];
if
(
strlen
(
$rule
[
'descr'
])
>
52
)
}
$rule
[
'descr'
]
=
substr
(
$rule
[
'descr'
],
0
,
52
);
$server
[
'crypto'
]
=
$pconfig
[
'step10'
][
'crypto'
];
$rule
[
'source'
][
'any'
]
=
TRUE
;
$server
[
'digest'
]
=
$pconfig
[
'step10'
][
'digest'
];
$rule
[
'destination'
][
'any'
]
=
TRUE
;
$server
[
'engine'
]
=
$pconfig
[
'step10'
][
'engine'
];
$rule
[
'interface'
]
=
"openvpn"
;
//$rule['protocol'] = $server['protocol'];
if
(
isset
(
$pconfig
[
'step11'
][
'ovpnrule'
]))
{
$rule
[
'type'
]
=
"pass"
;
$rule
=
array
();
$rule
[
'enabled'
]
=
"on"
;
$rule
[
'descr'
]
=
sprintf
(
gettext
(
"OpenVPN %s wizard"
),
$server
[
'description'
]);
$rule
[
'created'
]
=
make_config_revision_entry
();
/* Ensure the rule descr is not too long for pf to handle */
$config
[
'filter'
][
'rule'
][]
=
$rule
;
if
(
strlen
(
$rule
[
'descr'
])
>
52
)
{
}
$rule
[
'descr'
]
=
substr
(
$rule
[
'descr'
],
0
,
52
);
}
if
(
!
isset
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
$rule
[
'direction'
]
=
"in"
;
$config
[
'openvpn'
][
'openvpn-server'
]
=
array
();
$rule
[
'source'
][
'any'
]
=
TRUE
;
}
$rule
[
'destination'
][
'network'
]
=
$server
[
'interface'
]
.
"ip"
;
$rule
[
'destination'
][
'port'
]
=
$server
[
'local_port'
];
$config
[
'openvpn'
][
'openvpn-server'
][]
=
$server
;
$rule
[
'interface'
]
=
$server
[
'interface'
];
$rule
[
'protocol'
]
=
strtolower
(
$server
[
'protocol'
]);
openvpn_resync
(
'server'
,
$server
);
$rule
[
'type'
]
=
"pass"
;
write_config
();
$rule
[
'enabled'
]
=
"on"
;
header
(
"Location: vpn_openvpn_server.php"
);
$rule
[
'created'
]
=
make_config_revision_entry
();
exit
;
$config
[
'filter'
][
'rule'
][]
=
$rule
;
}
if
(
isset
(
$pconfig
[
'step11'
][
'ovpnallow'
]))
{
$rule
=
array
();
$rule
[
'descr'
]
=
sprintf
(
gettext
(
"OpenVPN %s wizard"
),
$server
[
'description'
]);
/* Ensure the rule descr is not too long for pf to handle */
if
(
strlen
(
$rule
[
'descr'
])
>
52
)
{
$rule
[
'descr'
]
=
substr
(
$rule
[
'descr'
],
0
,
52
);
}
$rule
[
'source'
][
'any'
]
=
TRUE
;
$rule
[
'destination'
][
'any'
]
=
TRUE
;
$rule
[
'interface'
]
=
"openvpn"
;
//$rule['protocol'] = $server['protocol'];
$rule
[
'type'
]
=
"pass"
;
$rule
[
'enabled'
]
=
"on"
;
$rule
[
'created'
]
=
make_config_revision_entry
();
$config
[
'filter'
][
'rule'
][]
=
$rule
;
}
if
(
!
isset
(
$config
[
'openvpn'
][
'openvpn-server'
]))
{
$config
[
'openvpn'
][
'openvpn-server'
]
=
array
();
}
$config
[
'openvpn'
][
'openvpn-server'
][]
=
$server
;
openvpn_resync
(
'server'
,
$server
);
write_config
();
header
(
"Location: vpn_openvpn_server.php"
);
exit
;
}
}
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