Changeset a35989d for npl


Ignore:
Timestamp:
09/26/17 17:02:09 (8 years ago)
Author:
Edwin Eefting <edwin@datux.nl>
Branches:
master, perl-5.22
Children:
0b780b4
Parents:
07ead96
Message:

libreswan 3.21 fixes. ipsec hostname support. ikev2 and source ip feature added

Location:
npl/syn3/webint/src/vpn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • npl/syn3/webint/src/vpn/autoconf_syn3.php

    r07ead96 ra35989d  
    11<?
    2 /* 
     2/*
    33(C) 2004-2013 DatuX - info@datux.nl
    44
     
    2323?>
    2424
    25 <? 
     25<?
    2626/*
    2727Redirection verhaal met betrekking tot auto configure:
     
    3333testtunnel                                                      instellingen testen
    3434listtunnels.php                                         klaar :D
    35        
     35
    3636*/
    3737        $name=$_REQUEST[name];
     
    3939        $passwd=$_REQUEST[passwd];
    4040
    41         Title(_AutoVPNConfig($name)); 
    42        
     41        Title(_AutoVPNConfig($name));
     42
    4343        //read tunnel
    4444        $tunnel=vpn_ReadTunnel($name);
     
    5252        $remote_par.="&new_right=$tunnel[leftid]";
    5353        $remote_par.="&new_rightsubnet=$tunnel[leftsubnet]";
     54
    5455        if ($tunnel[compress]=='yes')
    5556                $remote_par.="&new_compress=on";
    5657        else
    5758                $remote_par.="&new_compress=off";
     59
     60        if ($tunnel[ikev2]=='insist')
     61                $remote_par.="&new_ikev2=on";
     62        else
     63                $remote_par.="&new_ikev2=off";
     64
     65
     66        if ($tunnel[pfs]=='yes')
     67                $remote_par.="&new_pfs=on";
     68        else
     69                $remote_par.="&new_pfs=off";
     70
    5871        $remote_par.="&new_authby=$tunnel[authby]";
    5972        $remote_par.="&new_rightrsasigkey=".rawurlencode(vpn_ReadPubKey());
    6073        $remote_par.="&new_secret=".rawurlencode($secret);
    61        
     74
    6275        // url aan ONZE kant, waar pubkey andere kant uiteindelijk heen moet
    6376        $remote_par.="&puburi=".rawurlencode("https://$_SERVER[HTTP_HOST]/vpn/edittunnel.php?name=$name&save=1");
    64        
     77
    6578        // jump naar de tunnel config aan de andere kant
    6679        Redirect("https://$ip:10000/vpn/edittunnel.php?$remote_par");
    67 
    68        
    69        
  • npl/syn3/webint/src/vpn/edittunnel.php

    r07ead96 ra35989d  
    2828        Title(_VPNtunnelSettings($name));
    2929
     30        //default settings
    3031        $new_pfs="on";
     32        $new_ikev2="off";
     33        $new_leftsourceip=GetFirstLanIp();
    3134
    3235        //read current configuration
     
    3841                $new_leftid=$tunnel[leftid];
    3942                $new_rightsubnet=$tunnel[rightsubnet];
     43                $new_leftsourceip=$tunnel[leftsourceip];
    4044                $new_authby=$tunnel[authby];
    4145                $new_right=$tunnel[right];
     
    5256                        $new_pfs="off";
    5357
     58                if ($tunnel[ikev2]=='insist')
     59                        $new_ikev2="on";
     60                else
     61                        $new_ikev2="off";
    5462        }
    5563
     
    6068        if (!vpn_ValidName($new_name))
    6169                $errors[new_name]=_EnterValidName();
    62         elseif (!ValidIp($new_leftid))
     70        elseif (!ValidIp($new_leftid) && !ValidHostname($new_leftid))
    6371                $errors[new_leftid]=_EnterValidIp();
    6472        elseif (!ValidSubnet($new_leftsubnet))
    6573                $errors[new_leftsubnet]=_EnterValidSubnet();
    66         elseif (!ValidIp($new_right))
     74        elseif (!ValidIp($new_right) && !ValidHostname($new_right))
    6775                $errors[new_right]=_EnterValidIp();
    6876        elseif (!ValidSubnet($new_rightsubnet))
     
    8997        )
    9098                $errors[new_secret]=_EnterValidPassword();
     99        elseif ($new_leftsourceip && !ValidIp($new_leftsourceip))
     100                $errors[new_leftsourceip]=_EnterValidIp();
    91101
    92102
     
    104114                $tunnel[rightsubnet]=$new_rightsubnet;
    105115                $tunnel[right]=$new_right;
    106                 $tunnel[rightrsasigkey]=vpn_ReadableToPub($new_rightrsasigkey);
     116
     117                $rightrsasigkey=vpn_ReadableToPub($new_rightrsasigkey);
     118                if ($rightrsasigkey)
     119                {
     120                        $tunnel[rightrsasigkey]=$rightrsasigkey;
     121                }
     122                else
     123                {
     124                        unset($tunnel[rightrsasigkey]);
     125                }
     126
    107127                if ($new_compress=="on")
    108128                        $tunnel[compress]='yes';
     
    118138                else
    119139                        $tunnel[pfs]="no";
     140
     141                if ($new_ikev2=='on')
     142                        $tunnel[ikev2]="insist";
     143                else
     144                        $tunnel[ikev2]="never";
     145
     146                if ($new_leftsourceip)
     147                        $tunnel[leftsourceip]=$new_leftsourceip;
     148                else
     149                        unset($tunnel[leftsourceip]);
    120150
    121151                vpn_WriteTunnel($new_name,$tunnel);
     
    208238
    209239<p>
     240IKE v2:
     241<?InputCheckBox("new_ikev2",$errors);?>
     242
     243
     244<p>
     245Source IP:
     246<?InputText("new_leftsourceip",$errors);?>
     247
     248<p>
    210249<table>
    211250        <tr>
  • npl/syn3/webint/src/vpn/listtunnels.php

    r07ead96 ra35989d  
    3030<? Title(_VPNTunnels()); ?>
    3131
    32 <? Head($errors,'',10); ?>
     32<? Head($errors,'',60); ?>
    3333
    3434<h1><?=$TITLE?></h1>
     
    5050    $status=vpn_GetStatus();
    5151
    52     // echo "<pre>";print_r($status);
     52    //  echo "<pre>TEST ";print_r($status);
    5353
    5454    $untested=0;
     
    6565        {
    6666            //status NOT ok?
    67             if ($status[$name][state] != "STATE_QUICK_I2" && $status[$name][state] != "STATE_QUICK_R2" )
     67            if ($status[$name][state] != "STATE_QUICK_I2" && $status[$name][state] != "STATE_QUICK_R2" && $status[$name][state] != "STATE_V2_IPSEC_R" && $status[$name][state] != "STATE_V2_IPSEC_I")
    6868                LinkDefault("testtunnel.php?name=$name&mode=down", _Started(), "<img src='../img/CAUTION.gif'>",_ConfirmDisable($name));
    6969            else
  • npl/syn3/webint/src/vpn/openswan.php

    r07ead96 ra35989d  
    4343                        return false; //return ok-code
    4444
    45                 // global $VPN_STARTERRORS;
    4645                vpn_Stop();
    47                 // LogInfo(_LogVPNStarting());
    4846                SvcUp("ipsec");
    49                 // FileWriteRaw("/etc/sysconfig/pluto_updown", "DEFAULTSOURCE=".GetFirstLanIp()."\n");
    50                 // Cmd("pgrphack closefd /usr/sbin/ipsec setup start |grep 'FATAL:' 1>&2",'',$out,$err);
    51 
    52                 // if ($err)
    53                 // {
    54                 //      FileWrite($VPN_STARTERRORS,$err);
    55                 //      LogError(_LogVPNstartErrors(implode(" ",$err)));
    56                 //      return ($err);
    57                 // }
    58                 // else
    59                 // {
    60                 //      FileWrite($VPN_STARTERRORS,'');
    61                 //      sleep(2); //wacht zodat VPN subsysteem up is
    62                 //      //kijk of er tunnels up moeten
    63                 //      $tunnels=vpn_ReadTunnels();
    64                 //      foreach ($tunnels as $name=>$conf)
    65                 //      {
    66                 //              //hij moet up zijn, EN hij is reeds getest
    67                 //              if ((!vpn_TunnelIsDownOnBoot($name)) && vpn_TunnelIsTested($name))
    68                 //                      vpn_TunnelUp($name);
    69                 //      }
    70                 //      return false;
    71                 // }
    7247        }
    7348
     
    307282                foreach ($raw as $line)
    308283                {
    309                         if (preg_match("/^[^a-z]*([a-z]*)=(.*)$/",$line,$matches))
     284                        if (preg_match("/^[^a-z-0-9]*([a-z0-9]*)=(.*)$/",$line,$matches))
    310285                                $ret[$matches[1]]=$matches[2];
    311286                }
     
    435410                global $VPN_PRIO;
    436411
    437                 if (Cmd("ipsec whack --status",'',$output)!=0)
     412                if (Cmd("ipsec whack --status",'',$output)<0)
    438413                {
    439414                        LogError("Error reading ipsec status. Please check if ipsec-service is running");
     
    444419                        foreach ($output as $line)
    445420                        {
    446                                 if (preg_match('/^.*#([0-9])*:.*"(.*?)"[:0-9]* ([A-Z0-9_]+) /',$line,$matches))
     421                                if (preg_match('/^.*#([0-9])*:.*"(.*?)"[:0-9]* ([A-Z0-9_]+) /',$line,$matches))
    447422                                {
    448423                                        $nr=$matches[1];
Note: See TracChangeset for help on using the changeset viewer.