diff options
Diffstat (limited to 'usr/local/www')
-rwxr-xr-x | usr/local/www/wizard.php | 8 | ||||
-rw-r--r-- | usr/local/www/wizards/openvpn_wizard.inc | 255 | ||||
-rw-r--r-- | usr/local/www/wizards/openvpn_wizard.xml | 87 |
3 files changed, 329 insertions, 21 deletions
diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php index 9640d79..6915523 100755 --- a/usr/local/www/wizard.php +++ b/usr/local/www/wizard.php @@ -119,7 +119,7 @@ $title = $pkg['step'][$stepid]['title']; $description = $pkg['step'][$stepid]['description']; function update_config_field($field, $updatetext, $unset, $arraynum, $field_type) { - global $config, $savemsg; + global $config; $field_split = split("->",$field); foreach ($field_split as $f) $field_conv .= "['" . $f . "']"; @@ -231,7 +231,6 @@ function enablechange() { <form action="wizard.php" method="post" name="iform" id="iform"> <input type="hidden" name="xml" value="<?= $xml ?>"> <input type="hidden" name="stepid" value="<?= $stepid ?>"> -<?php if ($savemsg) print_info_box($savemsg); ?> <center> @@ -253,6 +252,8 @@ function enablechange() { <tr><td> </td></tr> <tr><td colspan='2'> <?php + if ($savemsg) + print_info_box($savemsg); if ($_GET['message'] != "") print_info_box(htmlspecialchars($_GET['message'])); if ($_POST['message'] != "") @@ -642,7 +643,8 @@ function enablechange() { echo ":</td>"; } $checked = ""; - if($value <> "") $checked = " CHECKED"; + if($value <> "") + $checked = " CHECKED"; echo "<td class=\"vtable\"><input value=\"on\" type='checkbox' id='" . $name . "' name='" . $name . "' " . $checked; if(isset($field['enablefields']) or isset($field['checkenablefields'])) echo " onClick=\"enablechange()\""; diff --git a/usr/local/www/wizards/openvpn_wizard.inc b/usr/local/www/wizards/openvpn_wizard.inc index fb9da32..319b49a 100644 --- a/usr/local/www/wizards/openvpn_wizard.inc +++ b/usr/local/www/wizards/openvpn_wizard.inc @@ -1,15 +1,14 @@ <?php +require_once("openvpn.inc"); function step2_submitphpaction() { + global $stepid; if ($_POST['authtype'] == "local") { - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3"); - exit; + $stepid = 2; } else if ($_POST['authtype'] == "ldap") { - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1"); - exit; + $stepid = 0; } else if ($_POST['authtype'] == "radius") { - header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=2"); - exit; + $stepid = 1; } } @@ -46,6 +45,7 @@ function step3_submitphpaction() { header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); exit; } + $stepid = 2; } function step4_stepbeforeformdisplay() { @@ -99,6 +99,7 @@ function step5_submitphpaction() { header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3&message={$message}"); exit; } + $stepid = 3; } function step6_submitphpaction() { @@ -117,10 +118,87 @@ function step6_submitphpaction() { header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}"); exit; } + $stepid = 4; +} + +function step7_stepbeforeformdisplay() { + global $pkg, $stepid, $netbios_nodetypes; + + foreach ($pkg['step'][$stepid]['fields']['field'] as $idx => $field) { + if ($field['name'] == "crypto") { + $pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'] = array(); + $cipherlist = openvpn_get_cipherlist(); + foreach ($cipherlist as $name => $desc) + $opt = array(); + $opt['name'] = $desc; + $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(); + foreach ($netbios_nodetypes as $type => $name) { + $opt = array(); + $opt['name'] = $name; + $opt['value'] = $type; + $pkg['step'][$stepid]['fields']['field'][$idx]['options']['option'][] = $opt; + } + } + } } function step7_submitphpaction() { + global $savemsg, $stepid; + + /* input validation */ + if ($result = openvpn_validate_port($_POST['localport'], 'Local port')) + $input_errors[] = $result; + + if ($result = openvpn_validate_cidr($_POST['tunnelnet'], 'Tunnel network')) + $input_errors[] = $result; + + if ($result = openvpn_validate_cidr($_POST['remotenet'], 'Remote network')) + $input_errors[] = $result; + + if ($result = openvpn_validate_cidr($_POST['localnet'], 'Local network')) + $input_errors[] = $result; + + $portused = openvpn_port_used($_POST['protocol'], $_POST['localport']); + if ($portused != 0) + $input_errors[] = "The specified 'Local port' is in use. Please select another value"; + + if (!isset($_POST['generatetlskey']) && isset($_POST['tlsauthentication'])) + if (!strstr($_POST['tlssharedkey'], "-----BEGIN OpenVPN Static key V1-----") || + !strstr($_POST['tlssharedkey'], "-----END OpenVPN Static key V1-----")) + $input_errors[] = "The field 'TLS Authentication Key' does not appear to be valid"; + + if (!empty($_POST['dnsserver1']) && !is_ipaddr(trim($_POST['dnsserver1']))) + $input_errors[] = "The field 'DNS Server #1' must contain a valid IP address"; + if (!empty($_POST['dnsserver2']) && !is_ipaddr(trim($_POST['dnsserver2']))) + $input_errors[] = "The field 'DNS Server #2' must contain a valid IP address"; + if (!empty($_POST['dnsserver3']) && !is_ipaddr(trim($_POST['dnsserver3']))) + $input_errors[] = "The field 'DNS Server #3' must contain a valid IP address"; + if (!empty($_POST['dnsserver4']) && !is_ipaddr(trim($_POST['dnsserver4']))) + $input_errors[] = "The field 'DNS Server #4' must contain a valid IP address"; + + if (!empty($_POST['ntpserver1']) && !is_ipaddr(trim($_POST['ntpserver1']))) + $input_errors[] = "The field 'NTP Server #1' must contain a valid IP address"; + if (!empty($_POST['ntpserver2']) && !is_ipaddr(trim($_POST['ntpserver2']))) + $input_errors[] = "The field 'NTP Server #2' must contain a valid IP address"; + + if (!empty($_POST['winsserver1']) && !is_ipaddr(trim($_POST['winsserver1']))) + $input_errors[] = "The field 'WINS Server #1' must contain a valid IP address"; + if (!empty($_POST['winsserver2']) && !is_ipaddr(trim($_POST['winsserver2']))) + $input_errors[] = "The field 'WINS Server #2' must contain a valid IP address"; + + if ($_POST['concurrentcon'] && !is_numeric($_POST['concurrentcon'])) + $input_errors[] = "The field 'Concurrent connections' must be numeric."; + if (empty($_POST['tunnelnet'])) + $input_errors[] = "You must specify a 'Tunnel network'."; + + if (count($input_errors) > 0) { + $savemsg = $input_errors[0]; + $stepid = $stepid - 1; + } } function step9_submitphpaction() { @@ -134,26 +212,183 @@ function step9_submitphpaction() { exit; } - if (empty($pconfig['step5']['certca'])) { + if (isset($pconfig['step2']['uselist'])) { + $auth = array(); + $auth['type'] = $pconfig['step1']['type']; + $auth['refid'] = uniqid(); + $auth['name'] = $pconfig['step2']['authtype']; + + if ($auth['type'] == "ldap") { + $auth['host'] = $pconfig['step2']['ip']; + $auth['ldap_port'] = $pconfig['step2']['port']; + if ($pconfig['step1']['transport'] == "tcp") + $auth['ldap_urltype'] = 'TCP - Standard'; + else + $auth['ldap_urltype'] = 'SSL - Encrypted'; + $auth['ldap_protver'] = 3; + $auth['ldap_scope'] = $pconfig['step2']['scope']; + $auth['ldap_authcn'] = $pconfig['step2']['authscope']; + $auth['ldap_binddn'] = $pconfig['step2']['userdn']; + $auth['ldap_bindpw'] = $pconfig['step2']['passdn']; + $auth['ldap_attr_user'] = $pconfig['step1']['nameattr']; + $auth['ldap_attr_member'] = $pconfig['step1']['memberattr']; + $auth['ldap_attr_group'] = $pconfig['step1']['groupattr']; + } else if ($auth['type'] == "radius") { + $auth['host'] = $pconfig['step2']['ip']; + $auth['radius_auth_port'] = $pconfig['step2']['port']; + $auth['radius_secret'] = $pconfig['step2']['password']; + $auth['radius_srvcs'] = "auth"; + } + if (!is_array($config['system']['authserver'])) + $config['system']['authserver'] = array(); + + $config['system']['authserver'][] = $auth; + } else if (!isset($pconfig['step2']['uselist']) && empty($pconfig['step2']['authserv'])) { + $message = "Please choose an authentication server ."; + header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); + exit; + } else if (!($auth = auth_get_authserver($pconfig['step2']['authserv']))) { + $message = "Not a valid authentication server has been specified."; + header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}"); + exit; + } + + if (isset($pconfig['step5']['uselist'])) { + $ca = array(); + $ca['refid'] = uniqid(); + $ca['name'] = $pconfig['step5']['certname']; + $dn = array( + 'countryName' => $pconfig['step5']['country'], + 'stateOrProvinceName' => $pconfig['step5']['state'], + 'localityName' => $pconfig['step5']['city'], + 'organizationName' => $pconfig['step5']['organization'], + 'emailAddress' => $pconfig['step5']['email'], + 'commonName' => $pconfig['step6']['cn']); + + ca_create($ca, $pconfig['step5']['keylength'], $pconfig['step5']['lifetime'], $dn); + if (!is_array($config['system']['ca'])) + $config['system']['ca'] = array(); + + $config['system']['ca'][] = $ca; + } else if (!isset($pconfig['step5']['uselist']) && empty($pconfig['step5']['authcertca'])) { $message = "Please choose a CA authority."; header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3&message={$message}"); exit; - } else if (!($ca = lookup_ca($pconfig['step5']['certca']))) { + } else if (!($ca = lookup_ca($pconfig['step5']['authcertca']))) { $message = "Not a valid CA authority specified."; header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3&message={$message}"); exit; } - if (empty($pconfig['step5']['certname'])) { + + if (isset($pconfig['step6']['uselist'])) { + $cert = array(); + $cert['refid'] = uniqid(); + $cert['name'] = $pconfig['step6']['certname']; + $dn = array( + 'countryName' => $pconfig['step6']['country'], + 'stateOrProvinceName' => $pconfig['step6']['state'], + 'localityName' => $pconfig['step6']['city'], + 'organizationName' => $pconfig['step6']['organization'], + 'emailAddress' => $pconfig['step6']['email'], + 'commonName' => $pconfig['step6']['cn']); + + cert_create($cert, $ca['refid'], $pconfig['step6']['keylength'], $pconfig['step6']['lifetime'], $dn); + if (!is_array($config['system']['cert'])) + $config['system']['cert'] = array(); + + $config['system']['cert'][] = $cert; + } else if (!isset($pconfig['step6']['uselist']) && empty($pconfig['step6']['authcertname'])) { $message = "Please choose a Certificate."; header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}"); exit; - } else if (!($cert = lookup_cert($pconfig['step5']['certname']))) { + } else if (!($cert = lookup_cert($pconfig['step6']['authcertname']))) { $message = "Not a valid Certificate specified."; header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}"); exit; } $server = array(); $server['vpnid'] = openvpn_vpnid_next(); + switch ($auth['type']) { + case "ldap": + $server['authmode'] = $auth['name']; + $server['mode'] = "server_user"; + break; + case "radius": + $server['authmode'] = $auth['name']; + $server['mode'] = "server_user"; + break; + default: + $server['authmode'] = "Local Database"; + $server['mode'] = "server_tls_user"; + break; + } + $server['caref'] = $ca['refid']; + $server['certref'] = $cert['refid']; + $server['protocol'] = $pconfig['step7']['protocol']; + $server['interface'] = $pconfig['step7']['interface']; + if (isset($pconfig['step7']['localport'])) + $server['localport'] = $pconfig['step7']['localport']; + $server['description'] = $pconfig['step7']['descr']; + $server['custom_options'] = $pconfig['step7']['advanced']; + if (isset($pconfig['step7']['tlsauth'])) { + if (isset($pconfig['step7']['gentlskey'])) + $tlskey = openvpn_create_key(); + else + $tlskey = $pconfig['step7']['tlskey']; + $server['tls'] = base64_encode($tlskey); + } + $server['dh_length'] = $pconfig['step7']['dhkey']; + $server['tunnel_network'] = $pconfig['step7']['tunnelnet']; + if (isset($pconfig['step7']['rdrgw'])) + $server['gwredir'] = $pconfig['step7']['rdrgw']; + if (isset($pconfig['step7']['localnet'])) + $server['local_network'] = $pconfig['step7']['localnet']; + if (isset($pconfig['step7']['remotenet'])) + $server['remote_network'] = $pconfig['step7']['remotenet']; + if (isset($pconfig['step7']['concurrentcon'])) + $server['maxclients'] = $pconfig['step7']['concurrentcon']; + if (isset($pconfig['step7']['compression'])) + $server['compression'] = $pconfig['step7']['compression']; + if (isset($pconfig['step7']['tos'])) + $server['passtos'] = $pconfig['step7']['tos']; + if (isset($pconfig['step7']['interclient'])) + $server['client2client'] = $pconfig['step7']['interclient']; + if (isset($pconfig['step7']['addrpool'])) + $server['pool_enable'] = $pconfig['step7']['addrpool']; + if (isset($pconfig['step7']['defaultdomain'])) + $server['dns_domain'] = $pconfig['step7']['defaultdomain']; + if (isset($pconfig['step7']['dns1'])) + $server['dns_server1'] = $pconfig['step7']['dns1']; + if (isset($pconfig['step7']['dns2'])) + $server['dns_server2'] = $pconfig['step7']['dns2']; + if (isset($pconfig['step7']['dns3'])) + $server['dns_server3'] = $pconfig['step7']['dns3']; + if (isset($pconfig['step7']['dns4'])) + $server['dns_server4'] = $pconfig['step7']['dns4']; + if (isset($pconfig['step7']['ntp1'])) + $server['ntp_server1'] = $pconfig['step7']['ntp1']; + if (isset($pconfig['step7']['ntp2'])) + $server['ntp_server2'] = $pconfig['step7']['ntp2']; + if (isset($pconfig['step7']['wins1'])) + $server['wins_server1'] = $pconfig['step7']['wins1']; + if (isset($pconfig['step7']['wins2'])) + $server['wins_server2'] = $pconfig['step7']['wins2']; + if (isset($pconfig['step7']['nbtenable'])) { + $server['netbios_ntype'] = $pconfig['step7']['nbttype']; + if (isset($pconfig['step7']['nbtscope'])) + $server['netbios_scope'] = $pconfig['step7']['nbtscope']; + $server['netbios_enable'] = $pconfig['step7']['nbtenable']; + } + $server['crypto'] = $pconfig['step7']['crypto']; + + if (!is_array($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; } ?> diff --git a/usr/local/www/wizards/openvpn_wizard.xml b/usr/local/www/wizards/openvpn_wizard.xml index 2e36763..1030f88 100644 --- a/usr/local/www/wizards/openvpn_wizard.xml +++ b/usr/local/www/wizards/openvpn_wizard.xml @@ -42,7 +42,7 @@ <displayname>Type of Server</displayname> <name>authtype</name> <description>Choose authentication backend type.</description> - <bindstofield>ovpnserver->step2->authtype</bindstofield> + <bindstofield>ovpnserver->step1->type</bindstofield> <options> <option> <name>Local User Access</name> @@ -81,6 +81,7 @@ <enablefields>name,ip,port,transport,scope,authscope,userdn,passdn,nameattr</enablefields> <description>Use authentication server from list</description> <displayname>Server from list</displayname> + <bindstofield>ovpnserver->step2->uselist</bindstofield> </field> <field> <name>authserv</name> @@ -157,14 +158,14 @@ <type>input</type> <size>20</size> <description>If you leave it blank an anonymous bind will be done.</description> - <bindstofield>ovpnserver->step2->user</bindstofield> + <bindstofield>ovpnserver->step2->userdn</bindstofield> </field> <field> <name>passdn</name> <displayname>Password</displayname> <type>password</type> <size>20</size> - <bindstofield>ovpnserver->step2->password</bindstofield> + <bindstofield>ovpnserver->step2->passdn</bindstofield> </field> <field> <name>nameattr</name> @@ -173,6 +174,18 @@ <bindstofield>ovpnserver->step2->nameattr</bindstofield> </field> <field> + <name>memberattr</name> + <displayname>Member naming attribute</displayname> + <type>input</type> + <bindstofield>ovpnserver->step2->memberattr</bindstofield> + </field> + <field> + <name>groupattr</name> + <displayname>Group naming attribute</displayname> + <type>input</type> + <bindstofield>ovpnserver->step2->groupattr</bindstofield> + </field> + <field> <type>submit</type> <name>Add new Server</name> </field> @@ -197,6 +210,7 @@ <enablefields>name,ip,port,secret</enablefields> <description>Use authentication server from list</description> <displayname>Server from list</displayname> + <bindstofield>ovpnserver->step2->uselist</bindstofield> </field> <field> <name>authserv</name> @@ -265,6 +279,7 @@ <enablefields>name,keylength,lifetime,country,state,city,organization,email,cn</enablefields> <description>Use authentication server from list</description> <displayname>Server from list</displayname> + <bindstofield>ovpnserver->step5->uselist</bindstofield> </field> <field> <type>certca_selection</type> @@ -380,6 +395,7 @@ <enablefields>name,keylength,lifetime,country,state,city,organization,email,cn,ca</enablefields> <description>Use authentication server from list</description> <displayname>Server from list</displayname> + <bindstofield>ovpnserver->step6->uselist</bindstofield> </field> <field> <type>cert_selection</type> @@ -541,14 +557,15 @@ <field> <name>TLS Authentication</name> <type>checkbox</type> + <value>on</value> <description>Enable authentication of TLS packets.</description> - <combinefieldsbegin>true</combinefieldsbegin> <bindstofield>ovpnserver->step7->tlsauth</bindstofield> </field> <field> <displayname>Automatically generate a TLS key</displayname> <name>generatetlskey</name> <enablefields>tlssharedkey</enablefields> + <value>on</value> <type>checkbox</type> <description>Automatically generate a shared TLS authentication key.</description> <bindstofield>ovpnserver->step7->gentlskey</bindstofield> @@ -558,7 +575,6 @@ <type>textarea</type> <cols>30</cols> <rows>5</rows> - <combinefieldsbegin>true</combinefieldsbegin> <bindstofield>ovpnserver->step7->tlskey</bindstofield> </field> <field> @@ -582,12 +598,24 @@ </options> </field> <field> + <name>crypto</name> + <type>select</type> + <displayname>Encryption algorithm</displayname> + <bindstofield>ovpnserver->step7->crypto</bindstofield> + <options> + <option> + <name>dummy</name> + <value>dummy</value> + </option> + </options> + </field> + <field> <type>listtopic</type> <name>Tunnel Settings</name> </field> <field> <displayname>Tunnel network</displayname> - <name>tunnel</name> + <name>tunnelnet</name> <type>input</type> <size>20</size> <bindstofield>ovpnserver->step7->tunnelnet</bindstofield> @@ -600,11 +628,18 @@ <bindstofield>ovpnserver->step7->rdrgw</bindstofield> </field> <field> + <displayname>Remote network</displayname> + <name>remotenet</name> + <type>input</type> + <size>20</size> + <bindstofield>ovpnserver->step7->remotenet</bindstofield> + </field> + <field> <displayname>Local network</displayname> - <name>local</name> + <name>localnet</name> <type>input</type> <size>20</size> - <bindstofield>ovpnserver->step7->local</bindstofield> + <bindstofield>ovpnserver->step7->localnet</bindstofield> </field> <field> <displayname>Concurrent Connections</displayname> @@ -690,6 +725,41 @@ <bindstofield>ovpnserver->step7->ntp2</bindstofield> </field> <field> + <name>nbtenable</name> + <type>checkbox</type> + <displayname>Enable NetBios option</displayname> + </field> + <field> + <displayname>NetBios Node Type</displayname> + <name>nbttype</name> + <type>select</type> + <bindstofield>ovpnserver->step7->nbttype</bindstofield> + <options> + <option> + <name>dummy</name> + <value>dummy</value> + </option> + </options> + </field> + <field> + <displayname>NetBios Scope</displayname> + <name>nbtscope</name> + <type>input</type> + <bindstofield>ovpnserver->step7->nbtscope</bindstofield> + </field> + <field> + <displayname>WINS Server 1</displayname> + <name>winsserver1</name> + <type>input</type> + <bindstofield>ovpnserver->step7->wins1</bindstofield> + </field> + <field> + <displayname>WINS Server 2</displayname> + <name>winsserver2</name> + <type>input</type> + <bindstofield>ovpnserver->step7->wins2</bindstofield> + </field> + <field> <name>Advanced</name> <type>textarea</type> <cols>30</cols> @@ -702,6 +772,7 @@ <type>submit</type> </field> </fields> + <stepbeforeformdisplay>step7_stepbeforeformdisplay();</stepbeforeformdisplay> <stepsubmitphpaction>step7_submitphpaction();</stepsubmitphpaction> <includefile>/usr/local/www/wizards/openvpn_wizard.inc</includefile> </step> |