Revision: 2774
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2774&view=rev
Author:   owes
Date:     2009-05-03 08:05:09 +0000 (Sun, 03 May 2009)

Log Message:
-----------
Add OpenVPN DHCP push options for NTP server and secondary DNS and WINS. Look 
and feel same as dhcp.cgi.
Fix the domain name testing as suggested by Harry.

Make a start for using client-config-dir, to assign fixed IP addresses to 
roadwarriors.

Modified Paths:
--------------
    ipcop/trunk/html/cgi-bin/ovpnmain.cgi
    ipcop/trunk/lfs/ipcop

Modified: ipcop/trunk/html/cgi-bin/ovpnmain.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/ovpnmain.cgi       2009-05-03 00:37:19 UTC (rev 
2773)
+++ ipcop/trunk/html/cgi-bin/ovpnmain.cgi       2009-05-03 08:05:09 UTC (rev 
2774)
@@ -59,8 +59,12 @@
 $cgiparams{'ACTION'} = '';
 $cgiparams{'CA_NAME'} = '';
 $cgiparams{'DHCP_DOMAIN'} = '';
-$cgiparams{'DHCP_DNS'} = '';
-$cgiparams{'DHCP_WINS'} = '';
+$cgiparams{'DHCP_DNS1'} = '';
+$cgiparams{'DHCP_DNS2'} = '';
+$cgiparams{'DHCP_NTP1'} = '';
+$cgiparams{'DHCP_NTP2'} = '';
+$cgiparams{'DHCP_WINS1'} = '';
+$cgiparams{'DHCP_WINS2'} = '';
 $cgiparams{'NOBIND'} = 'off';
 $cgiparams{'DCOMPLZO'} = 'off';
 $cgiparams{'ACTION'} = '';
@@ -145,6 +149,7 @@
     if ($sovpnsettings{KEEPALIVE_1} > 0 && $sovpnsettings{KEEPALIVE_2} > 0) {
         print CONF "keepalive $sovpnsettings{'KEEPALIVE_1'} 
$sovpnsettings{'KEEPALIVE_2'}\n";
     }
+    print CONF "client-config-dir /var/ipcop/ovpn/ccd\n";
     print CONF "status-version 1\n";
     print CONF "status /var/log/ovpnserver.log 30\n";
     print CONF "cipher $sovpnsettings{DCIPHER}\n";
@@ -157,20 +162,29 @@
     if ($sovpnsettings{DHCP_DOMAIN} ne '') {
         print CONF "push \"dhcp-option DOMAIN $sovpnsettings{DHCP_DOMAIN}\"\n";
     }
-
-    if ($sovpnsettings{DHCP_DNS} ne '') {
-        print CONF "push \"dhcp-option DNS $sovpnsettings{DHCP_DNS}\"\n";
+    if ($sovpnsettings{DHCP_DNS1} ne '') {
+        print CONF "push \"dhcp-option DNS $sovpnsettings{DHCP_DNS1}\"\n";
     }
-
-    if ($sovpnsettings{DHCP_WINS} ne '') {
-        print CONF "push \"dhcp-option WINS $sovpnsettings{DHCP_WINS}\"\n";
+    if ($sovpnsettings{DHCP_DNS2} ne '') {
+        print CONF "push \"dhcp-option DNS $sovpnsettings{DHCP_DNS2}\"\n";
     }
+    if ($sovpnsettings{DHCP_NTP1} ne '') {
+        print CONF "push \"dhcp-option NTP $sovpnsettings{DHCP_NTP1}\"\n";
+    }
+    if ($sovpnsettings{DHCP_NTP2} ne '') {
+        print CONF "push \"dhcp-option NTP $sovpnsettings{DHCP_NTP2}\"\n";
+    }
+    if ($sovpnsettings{DHCP_WINS1} ne '') {
+        print CONF "push \"dhcp-option WINS $sovpnsettings{DHCP_WINS1}\"\n";
+    }
+    if ($sovpnsettings{DHCP_WINS2} ne '') {
+        print CONF "push \"dhcp-option WINS $sovpnsettings{DHCP_WINS2}\"\n";
+    }
 
-    if ($sovpnsettings{DHCP_WINS} eq '') {
+    if ($sovpnsettings{MAX_CLIENTS} eq '') {
         print CONF "max-clients 100\n";
     }
-
-    if ($sovpnsettings{DHCP_WINS} ne '') {
+    else {
         print CONF "max-clients $sovpnsettings{MAX_CLIENTS}\n";
     }
     print CONF "tls-verify /usr/local/bin/openvpnverify\n";
@@ -273,8 +287,12 @@
     $vpnsettings{'REDIRECT_GW_DEF1'} = $cgiparams{'REDIRECT_GW_DEF1'};
     $vpnsettings{'CLIENT2CLIENT'} = $cgiparams{'CLIENT2CLIENT'};
     $vpnsettings{'DHCP_DOMAIN'} = $cgiparams{'DHCP_DOMAIN'};
-    $vpnsettings{'DHCP_DNS'} = $cgiparams{'DHCP_DNS'};
-    $vpnsettings{'DHCP_WINS'} = $cgiparams{'DHCP_WINS'};
+    $vpnsettings{'DHCP_DNS1'} = $cgiparams{'DHCP_DNS1'};
+    $vpnsettings{'DHCP_DNS2'} = $cgiparams{'DHCP_DNS2'};
+    $vpnsettings{'DHCP_NTP1'} = $cgiparams{'DHCP_NTP1'};
+    $vpnsettings{'DHCP_NTP2'} = $cgiparams{'DHCP_NTP2'};
+    $vpnsettings{'DHCP_WINS1'} = $cgiparams{'DHCP_WINS1'};
+    $vpnsettings{'DHCP_WINS2'} = $cgiparams{'DHCP_WINS2'};
     $vpnsettings{'NOBIND'} = $cgiparams{'NOBIND'};
 
     $vpnsettings{'RADIUS_ENABLED'} = $cgiparams{'RADIUS_ENABLED'};
@@ -286,23 +304,59 @@
     $vpnsettings{'RADIUS_PASS1'} = $cgiparams{'RADIUS_PASS1'};
 
     if ($cgiparams{'DHCP_DOMAIN'} ne '') {
-        unless (&General::validfqdn($cgiparams{'DHCP_DOMAIN'}) || 
&General::validip($cgiparams{'DHCP_DOMAIN'})) {
+        unless (&General::validdomainname($cgiparams{'DHCP_DOMAIN'})) {
             $errormessage = $Lang::tr{'invalid input for dhcp domain'};
             goto ADV_ERROR;
         }
     }
-    if ($cgiparams{'DHCP_DNS'} ne '') {
-        unless (&General::validfqdn($cgiparams{'DHCP_DNS'}) || 
&General::validip($cgiparams{'DHCP_DNS'})) {
-            $errormessage = $Lang::tr{'invalid input for dhcp dns'};
+    if ($cgiparams{'DHCP_DNS1'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_DNS1'})) {
+            $errormessage = $Lang::tr{'invalid primary dns'};
             goto ADV_ERROR;
         }
     }
-    if ($cgiparams{'DHCP_WINS'} ne '') {
-        unless (&General::validfqdn($cgiparams{'DHCP_WINS'}) || 
&General::validip($cgiparams{'DHCP_WINS'})) {
-            $errormessage = $Lang::tr{'invalid input for dhcp wins'};
+    if ($cgiparams{'DHCP_DNS2'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_DNS2'})) {
+            $errormessage = $Lang::tr{'invalid secondary dns'};
             goto ADV_ERROR;
         }
+        if ($cgiparams{'DHCP_DNS1'} eq '') {
+            $errormessage = $Lang::tr{'cannot specify secondary dns without 
specifying primary'};
+            goto ADV_ERROR;
+        }
     }
+    if ($cgiparams{'DHCP_NTP1'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_NTP1'})) {
+            $errormessage = $Lang::tr{'invalid primary ntp'};
+            goto ADV_ERROR;
+        }
+    }
+    if ($cgiparams{'DHCP_NTP2'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_NTP2'})) {
+            $errormessage = $Lang::tr{'invalid secondary ntp'};
+            goto ADV_ERROR;
+        }
+        if ($cgiparams{'DHCP_NTP1'} eq '') {
+            $errormessage = $Lang::tr{'cannot specify secondary ntp without 
specifying primary'};
+            goto ADV_ERROR;
+        }
+    }
+    if ($cgiparams{'DHCP_WINS1'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_WINS1'})) {
+            $errormessage = $Lang::tr{'invalid wins address'};
+            goto ADV_ERROR;
+        }
+    }
+    if ($cgiparams{'DHCP_WINS2'} ne '') {
+        unless (&General::validip($cgiparams{'DHCP_WINS2'})) {
+            $errormessage = $Lang::tr{'invalid wins address'};
+            goto ADV_ERROR;
+        }
+        if ($cgiparams{'DHCP_WINS1'} eq '') {
+            $errormessage = $Lang::tr{'cannot specify secondary wins without 
specifying primary'};
+            goto ADV_ERROR;
+        }
+    }
     if ((length($cgiparams{'MAX_CLIENTS'}) == 0) || 
(($cgiparams{'MAX_CLIENTS'}) < 1 ) || (($cgiparams{'MAX_CLIENTS'}) > 255 )) {
         $errormessage = $Lang::tr{'invalid input for max clients'};
         goto ADV_ERROR;
@@ -695,9 +749,9 @@
 
     &Header::showhttpheaders();
     &Header::openpage($Lang::tr{'ovpn configuration main'}, 1, '');
-    &Header::openbigbox('100%', 'left', '', $errormessage);
+    &Header::openbigbox('100%', 'left', '');
     if ($errormessage) {
-        &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}:");
+        &Header::openbox('100%', 'left', "$Lang::tr{'error messages'}:", 
'error');
         print "<font class='base'>$errormessage&nbsp;</font>";
         &Header::closebox();
     }
@@ -706,42 +760,52 @@
 <form method='post' enctype='multipart/form-data' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
 <tr>
-    <td class='boldbase' colspan='2'>$Lang::tr{'dhcp-options'}</td>
+    <td class='boldbase' colspan='4'>$Lang::tr{'dhcp-options'}</td>
 </tr><tr>
-    <td width='40%' class='base'>$Lang::tr{'domain name suffix'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
-    <td width='60%'><input type='text' name='DHCP_DOMAIN' 
value='$cgiparams{'DHCP_DOMAIN'}' size='30' /></td>
+    <td width='25%' class='base'>$Lang::tr{'domain name suffix'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td colspan='3'><input type='text' name='DHCP_DOMAIN' 
value='$cgiparams{'DHCP_DOMAIN'}' size='30' /></td>
 </tr><tr>
-    <td class='base'>$Lang::tr{'primary dns'}:&nbsp;<img src='/blob.gif' 
alt='*' /></td>
-    <td><input type='text' name='DHCP_DNS' value='$cgiparams{'DHCP_DNS'}' 
size='30' /></td>
+    <td width='25%' class='base'>$Lang::tr{'primary dns'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td width='25%'><input type='text' name='DHCP_DNS1' 
value='$cgiparams{'DHCP_DNS1'}' /></td>
+    <td width='25%' class='base'>$Lang::tr{'secondary dns'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td width='25%'><input type='text' name='DHCP_DNS2' 
value='$cgiparams{'DHCP_DNS2'}' /></td>
 </tr><tr>
+    <td class='base'>$Lang::tr{'primary ntp server'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td><input type='text' name='DHCP_NTP1' value='$cgiparams{'DHCP_NTP1'}' 
/></td>
+    <td class='base'>$Lang::tr{'secondary ntp server'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td><input type='text' name='DHCP_NTP2' value='$cgiparams{'DHCP_NTP2'}' 
/></td>
+</tr><tr>
     <td class='base'>$Lang::tr{'primary wins server address'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
-    <td><input type='text' name='DHCP_WINS' value='$cgiparams{'DHCP_WINS'}' 
size='30' /></td>
+    <td><input type='text' name='DHCP_WINS1' value='$cgiparams{'DHCP_WINS1'}' 
/></td>
+    <td class='base'>$Lang::tr{'secondary wins server address'}:&nbsp;<img 
src='/blob.gif' alt='*' /></td>
+    <td><input type='text' name='DHCP_WINS2' value='$cgiparams{'DHCP_WINS2'}' 
/></td>
 </tr><tr>
-    <td colspan='2'><hr /></td>
+    <td colspan='4'><hr /></td>
 </tr><tr>
-    <td class='boldbase' colspan='2'>$Lang::tr{'misc-options'}</td>
+    <td class='boldbase' colspan='4'>$Lang::tr{'misc-options'}</td>
 </tr><tr>
     <td class='base'>Client-To-Client:</td>
-    <td><input type='checkbox' name='CLIENT2CLIENT' 
$checked{'CLIENT2CLIENT'}{'on'} /></td>
+    <td colspan='3'><input type='checkbox' name='CLIENT2CLIENT' 
$checked{'CLIENT2CLIENT'}{'on'} /></td>
 </tr><tr>
     <td class='base'>Redirect-Gateway def1:</td>
-    <td><input type='checkbox' name='REDIRECT_GW_DEF1' 
$checked{'REDIRECT_GW_DEF1'}{'on'} /></td>
+    <td colspan='3'><input type='checkbox' name='REDIRECT_GW_DEF1' 
$checked{'REDIRECT_GW_DEF1'}{'on'} /></td>
 </tr><tr>
     <td class='base'>Nobind:</td>
-    <td><input type='checkbox' name='NOBIND' $checked{'NOBIND'}{'on'} /></td>
+    <td colspan='3'><input type='checkbox' name='NOBIND' 
$checked{'NOBIND'}{'on'} /></td>
 </tr><tr>
     <td class='base'>Max-Clients:</td>
-    <td><input type='text' name='MAX_CLIENTS' 
value='$cgiparams{'MAX_CLIENTS'}' size='10' /></td>
+    <td colspan='3'><input type='text' name='MAX_CLIENTS' 
value='$cgiparams{'MAX_CLIENTS'}' size='10' /></td>
 </tr><tr>
     <td class='base'>Keepalive (ping/ping-restart):</td>
-    <td><input type='text' name='KEEPALIVE_1' 
value='$cgiparams{'KEEPALIVE_1'}' size='10' />&nbsp;
+    <td colspan='3'><input type='text' name='KEEPALIVE_1' 
value='$cgiparams{'KEEPALIVE_1'}' size='10' />&nbsp;
         <input type='text' name='KEEPALIVE_2' 
value='$cgiparams{'KEEPALIVE_2'}' size='10' /></td>
 </tr><tr>
-    <td colspan='2'><hr /></td>
+    <td colspan='4'><hr /></td>
 </tr><tr>
-    <td class='boldbase'>$Lang::tr{'log-options'}</td>
-</tr><tr><td class='base'>VERB</td>
-    <td><select name='LOG_VERB'>
+    <td class='boldbase' colspan='4'>$Lang::tr{'log-options'}</td>
+</tr><tr>
+    <td class='base'>VERB</td>
+    <td colspan='3'><select name='LOG_VERB'>
         <option value='1'  $selected{'LOG_VERB'}{'1'}>1</option>
         <option value='2'  $selected{'LOG_VERB'}{'2'}>2</option>
         <option value='3'  $selected{'LOG_VERB'}{'3'}>3</option>
@@ -756,30 +820,30 @@
         <option value='0'  $selected{'LOG_VERB'}{'0'}>0</option></select>
     </td>
 </tr><tr>
-    <td colspan='2'><hr /></td>
+    <td colspan='4'><hr /></td>
 </tr><tr>
-    <td class='boldbase' colspan='2'>$Lang::tr{'radius server settings'}</td>
+    <td class='boldbase' colspan='4'>$Lang::tr{'radius server settings'}</td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius enable'}:</td>
-    <td><input type='checkbox' name='RADIUS_ENABLED' 
$checked{'RADIUS_ENABLED'}{'on'} /></td>
+    <td colspan='3'><input type='checkbox' name='RADIUS_ENABLED' 
$checked{'RADIUS_ENABLED'}{'on'} /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius servername'}:</td>
-    <td><input type='text' name='RADIUS_HOST' 
value='$cgiparams{'RADIUS_HOST'}' size='30' /></td>
+    <td colspan='3'><input type='text' name='RADIUS_HOST' 
value='$cgiparams{'RADIUS_HOST'}' size='30' /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius authport'}:</td>
-    <td><input type='text' name='RADIUS_AUTHPORT' 
value='$cgiparams{'RADIUS_AUTHPORT'}' size='10' /></td>
+    <td colspan='3'><input type='text' name='RADIUS_AUTHPORT' 
value='$cgiparams{'RADIUS_AUTHPORT'}' size='10' /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius acctport'}:</td>
-    <td><input type='text' name='RADIUS_ACCTPORT' 
value='$cgiparams{'RADIUS_ACCTPORT'}' size='10' /></td>
+    <td colspan='3'><input type='text' name='RADIUS_ACCTPORT' 
value='$cgiparams{'RADIUS_ACCTPORT'}' size='10' /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'maximum retries'}:</td>
-    <td><input type='text' name='RADIUS_RETRY' 
value='$cgiparams{'RADIUS_RETRY'}' size='10' /></td>
+    <td colspan='3'><input type='text' name='RADIUS_RETRY' 
value='$cgiparams{'RADIUS_RETRY'}' size='10' /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius wait'}:</td>
-    <td><input type='text' name='RADIUS_TIMEOUT' 
value='$cgiparams{'RADIUS_TIMEOUT'}' size='10' /></td>
+    <td colspan='3'><input type='text' name='RADIUS_TIMEOUT' 
value='$cgiparams{'RADIUS_TIMEOUT'}' size='10' /></td>
 </tr><tr>
     <td class='base'>$Lang::tr{'radius sharedsecret'}:</td>
-    <td><input type='password' name='RADIUS_PASS1' 
value='$cgiparams{'RADIUS_PASS1'}' size='32' /></td>
+    <td colspan='3'><input type='password' name='RADIUS_PASS1' 
value='$cgiparams{'RADIUS_PASS1'}' size='32' /></td>
 </tr>
 </table>
 <hr />

Modified: ipcop/trunk/lfs/ipcop
===================================================================
--- ipcop/trunk/lfs/ipcop       2009-05-03 00:37:19 UTC (rev 2773)
+++ ipcop/trunk/lfs/ipcop       2009-05-03 08:05:09 UTC (rev 2774)
@@ -62,7 +62,7 @@
        # Create all directories
        for i in addon-lang alcatelusb auth backup ca certs cnx_pci crls ddns 
dhcp dmzholes \
                eagle-usb eciadsl ethernet firewall firmware isdn key logging 
main modem  \
-               ovpn ovpn/ca ovpn/certs ovpn/crls ovpn/openssl patches \
+               ovpn ovpn/ca ovpn/ccd ovpn/certs ovpn/crls ovpn/openssl patches 
\
                portfw ppp private proxy red remote shaping time traffic vpn  
xtaccess ; do \
                        mkdir -p $(CONFIG_ROOT)/$$i; \
        done


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to