Example #1
0
function server_settings()
{
    $vpn = new openvpn();
    $nic = new networking();
    $restart = button("{APP_OPENVPN_APPLY}", "YahooWin3(500,\"index.openvpn.php?restart-server=yes\",\"windows:{APP_OPENVPN_APPLY}\");");
    $sock = new sockets();
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
    }
    while (list($num, $ligne) = each($nic->array_TCP)) {
        if ($ligne == null) {
            continue;
        }
        $ips[$ligne] = "{$ligne} ({$num})";
        $arr[$num] = $num;
        $ipeth[$num] = "{$num} ({$ligne})";
    }
    $ips[null] = "{all}";
    $ipeth[null] = "{none}";
    $nics = Field_array_Hash($arr, 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"], 'OpenVPNChangeNIC()');
    $ips = Field_array_Hash($ips, 'LOCAL_BIND', $vpn->main_array["GLOBAL"]["LOCAL_BIND"]);
    $IPTABLES_ETH = Field_array_Hash($ipeth, 'IPTABLES_ETH', $vpn->main_array["GLOBAL"]["IPTABLES_ETH"], null, null, 0, 'font-size:13px;padding:3px');
    //openvpn_access_interface
    $DEV_TYPE = $vpn->main_array["GLOBAL"]["DEV_TYPE"];
    $dev = Field_array_Hash(array("tun" => "{routed_IP_tunnel}", "tap0" => "{ethernet_tunnel}"), "DEV_TYPE", $vpn->main_array["GLOBAL"]["DEV_TYPE"], "OpenVPNChangeServerMode()", null, 0, 'font-size:13px;padding:3px');
    $dev = "{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";
    $protocol = Field_array_Hash(array("tcp" => "TCP", "udp" => "UDP"), "LISTEN_PROTO", $vpn->main_array["GLOBAL"]["LISTEN_PROTO"], null, null, 0, 'font-size:13px;padding:3px');
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $vpn->main_array["GLOBAL"]["IP_START"] = "10.8.0.0";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = "255.255.255.0";
    }
    $old = "\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'>\n\t\t\t\t\t<input type='button' OnClick=\"javascript:WizardFindMyNetworksMask()\" value='{newtork_help_me}'>\n\t\t\t\t</td>\n\t\t\t</tr>";
    $entete = "\n<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{enable_openvpn_server_mode}:</td>\n\t\t\t\t<td style='font-size:13px' width=1%>" . Field_checkbox('ENABLE_SERVER', '1', $vpn->main_array["GLOBAL"]["ENABLE_SERVER"]) . "</td>\n\t\t\t\t<td class=legend style='font-size:13px'>{tunnel_type}:</td>\n\t\t\t\t<td style='font-size:13px' nowrap>{$dev}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class=legend style='font-size:13px'>{ethernet_tunnel}</td>\n\t\t\t\t<td style='font-size:13px' width=1%>" . Field_checkbox('ENABLE_BRIDGE', '1', $vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"], "OpenVPNChangeServerMode()") . "</td>\n\t\t\t\t\n\t\t\t</tr>\n</table>";
    $openvpn_local = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{openvpn_local}:</td>\n\t\t\t\t<td>{$ips}&nbsp;</td>\n\t\t\t\t<td>" . help_icon("{openvpn_local_text}") . "</td>\n\t\t\t</tr>";
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $openvpn_local = null;
    }
    $mandatories = "<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{listen_port}:</td>\n\t\t\t\t<td>" . Field_text('LISTEN_PORT', $vpn->main_array["GLOBAL"]["LISTEN_PORT"], 'width:90px;font-size:13px;padding:3px') . "&nbsp;{$protocol}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t{$openvpn_local}\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{public_ip_addr}:</td>\n\t\t\t\t<td>" . Field_text('PUBLIC_IP', $vpn->main_array["GLOBAL"]["PUBLIC_IP"], 'width:210px;;font-size:13px;padding:3px') . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t<tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{password}:</td>\n\t\t\t\t<td>" . Field_password('OpenVpnPasswordCert', $OpenVpnPasswordCert, 'width:210px;;font-size:13px;padding:3px') . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t<tr>\n\t\t\n\n\t\t\t\n\t\t\t\n</table>";
    $mode_tun = "<table style='width:100%'>\n\t<tr>\n\t\t<td colspan=2 ><br>\n\t\t\t<p class=caption style='font-size:13px'>{LOCAL_NETWORK} {SERVER_MODE_TUNE}</p>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{from_ip_address}:</td>\n\t\t<td>" . Field_text('IP_START', $vpn->main_array["GLOBAL"]["IP_START"], 'width:210px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{netmask}:</td>\n\t\t<td>" . Field_text('NETMASK', $vpn->main_array["GLOBAL"]["NETMASK"], 'width:210px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{openvpn_access_interface}:</td>\n\t\t<td>{$IPTABLES_ETH}</td>\n\t\t<td>" . help_icon("{openvpn_access_interface_text}") . "</td>\n\t</tr>\n\t\n\t\n\t\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'>\n\t\t\t\t\t<hr>" . button("{apply}", "SaveServerSettings()") . "\n\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\t\n</table>";
    $VPN_SERVER_IP = $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
    $VPN_DHCP_FROM = $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
    $VPN_DHCP_TO = $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
    $tcp = new networking();
    if ($vpn->main_array["GLOBAL"]["BRIDGE_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["BRIDGE_ETH"] = "eth0";
    }
    $array_ip = $tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    if ($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] == null) {
        $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] = $array_ip["IPADDR"];
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = $array_ip["NETMASK"];
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $nics = Field_array_Hash($vpn->virtual_ip_lists(), 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    }
    $mode_tap = "\n<div style='width:100%;margin-bottom:5px'><div id='nicvpninfo' style='float:right;margin:5px;'>" . ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]) . "</div>\n\t\t\t<p class=caption>{SERVER_MODE_TAP}</p>\n\t\t</div>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{BRIDGE_ETH}:</td>\n\t\t<td width=1% nowrap>{$nics}</td>\n\t\t<td align='left' width=1% nowrap>" . texttooltip("{add_virtual_ip_address}", "{add_virtual_ip_address}", "Loadjs('system.nic.config.php?js-add-nic=yes')", null, 0, "font-size:13px;padding:3px") . "</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{BRIDGE_ADDR}:</td>\n\t\t<td width=1% nowrap>" . Field_text('BRIDGE_ADDR', $vpn->main_array["GLOBAL"]["BRIDGE_ADDR"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_FROM}:</td>\n\t\t<td width=1% nowrap>" . Field_text('VPN_DHCP_FROM', $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_TO}:</td>\n\t\t<td width=1% nowrap>" . Field_text('VPN_DHCP_TO', $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td colspan=3 align='right'><hr>" . button("{apply}", "SaveServerSettings()") . "\n\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\t\t\n</table>\n";
    $mode = $mode_tun;
    if ($vpn->main_array["GLOBAL"]["DEV_TYPE"] == "tap0") {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $mode = $mode_tap;
    }
    $html = "\n<div style='text-align:right;padding-bottom:4px'>{$restart}</div>\n<table style='width:100%'>\n<tr>\n<td valign='top'>\n<div id='OPENVPN_SERVER_SETTINGS'>\n\t\t{$entete}\n\t\t<hr>\n\t\t{$mandatories}\n\t\t<hr>\n\t\t{$mode}\n\t\t\n\t</div>\n</td>\n</tr>\n</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
    // openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull
}
Example #2
0
function server_settings()
{
    $vpn = new openvpn();
    $nic = new networking();
    $sock = new sockets();
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
    }
    //openvpn_access_interface
    $DEV_TYPE = $vpn->main_array["GLOBAL"]["DEV_TYPE"];
    $dev = Field_array_Hash(array("tun" => "{routed_IP_tunnel}", "tap0" => "{ethernet_tunnel}"), "DEV_TYPE", $vpn->main_array["GLOBAL"]["DEV_TYPE"], "OpenVPNChangeServerMode()", null, 0, 'font-size:16px;padding:3px');
    $dev = "{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $vpn->main_array["GLOBAL"]["IP_START"] = "10.8.0.0";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = "255.255.255.0";
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $openvpn_local = null;
    }
    $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    if ($CLIENT_NAT_PORT == null) {
        $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    }
    $vpn->main_array["GLOBAL"]["PUBLIC_IP"];
    $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PROTO"];
    $vpn->main_array["GLOBAL"]["ENABLE_SERVER"];
    $vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"];
    $vpn->main_array["GLOBAL"]["IP_START"];
    $vpn->main_array["GLOBAL"]["IPTABLES_ETH"];
    if ($vpn->main_array["GLOBAL"]["PUBLIC_IP"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}:{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PROTO"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{protocol}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    $LDAP_AUTH = "{no}";
    $EnableOpenVPNEndUserPage = "{no}";
    if ($vpn->main_array["GLOBAL"]["LDAP_AUTH"] == 1) {
        $LDAP_AUTH = "{yes}";
    }
    if ($sock->GET_INFO("EnableOpenVPNEndUserPage") == 1) {
        $EnableOpenVPNEndUserPage = "{yes}";
    }
    $wake_up_ip = $vpn->main_array["GLOBAL"]["WAKEUP_IP"];
    $tcp_ip = new ip();
    if (!$tcp_ip->isValid($wake_up_ip)) {
        $wake_up_ip = "{disabled}";
    }
    if (!$tcp_ip->isValid($vpn->main_array["GLOBAL"]["PUBLIC_IP"])) {
        $vpn->main_array["GLOBAL"]["PUBLIC_IP"] = "0.0.0.0";
    }
    $ahref_edit = "<a href=\"javascript:blur();\" OnClick=\"Loadjs('index.openvpn.server.php');\" style='font-size:16px;text-decoration:underline'>";
    $button_edit = button("{change_settings}", "Loadjs('index.openvpn.server.php')", 34);
    if ($vpn->main_array["GLOBAL"]["LOCAL_BIND"] == null) {
        $vpn->main_array["GLOBAL"]["LOCAL_BIND"] = "{none}";
    }
    $openvpn_local = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{openvpn_local}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["LOCAL_BIND"]}</a></td>\n\t\t\t</tr>";
    $mandatories = "<table style='width:99%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{listen_port}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;width:850px'>{$vpn->main_array["GLOBAL"]["LISTEN_PORT"]}&nbsp;{$vpn->main_array["GLOBAL"]["LISTEN_PROTO"]}</a></td>\n\t\t\t</tr>\n\t\t\t{$openvpn_local}\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{public_ip_addr}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;'>{$vpn->main_array["GLOBAL"]["PUBLIC_IP"]}:{$CLIENT_NAT_PORT}</a></td>\n\t\t\t<tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{password}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>*****</a></td>\n\t\t\t<tr>\n\t\t\t</table>";
    $proxy = "{no}";
    if ($vpn->main_array["GLOBAL"]["USE_RPROXY"] == 1) {
        $proxy = "{$vpn->main_array["GLOBAL"]["PROXYADDR"]}:{$vpn->main_array["GLOBAL"]["PROXYPORT"]}";
    }
    if ($vpn->main_array["GLOBAL"]["IPTABLES_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["IPTABLES_ETH"] = "{no}";
    }
    $mode_tun = "<table style='width:99%'>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{enable_authentication}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px;;width:850px'>{$LDAP_AUTH}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{EnableOpenVPNEndUserPage}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$EnableOpenVPNEndUserPage}</td>\n\t\t<td>&nbsp;</td>\n\t<tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{reverse_proxy}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$proxy}</td>\n\t<tr>\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{from_ip_address}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IP_START"]}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{netmask}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["NETMASK"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{openvpn_access_interface}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{wake_up_ip}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$wake_up_ip}</a></td>\n\t</tr>\t\n\t\n</table>";
    $VPN_SERVER_IP = $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
    $VPN_DHCP_FROM = $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
    $VPN_DHCP_TO = $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
    $tcp = new networking();
    if ($vpn->main_array["GLOBAL"]["BRIDGE_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["BRIDGE_ETH"] = "eth0";
    }
    $array_ip = $tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    if ($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] == null) {
        $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] = $array_ip["IPADDR"];
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = $array_ip["NETMASK"];
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $nics = Field_array_Hash($vpn->virtual_ip_lists(), 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    }
    $mode_tap = "\n\t<div style='width:100%;margin-bottom:5px'>\n\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div id='nicvpninfo' style='float:right;margin:5px;'>" . ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]) . "</div>\n\t\t\t\t</td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div class=explain>{SERVER_MODE_TAP}</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ETH}:</td>\n\t\t<td width=1% nowrap>{$nics}</td>\n\t\t<td align='left' style='font-weight:bold;font-size:20px' width=1% nowrap>" . texttooltip("{add_virtual_ip_address}", "{add_virtual_ip_address}", "Loadjs('system.nic.config.php?js-add-nic=yes')", null, 0, "font-size:16px;padding:3px") . "</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ADDR}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap >" . Field_text('BRIDGE_ADDR', $vpn->main_array["GLOBAL"]["BRIDGE_ADDR"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_FROM}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_FROM', $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_TO}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_TO', $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td colspan=3 align='right'><hr>" . button("{apply}", "SaveServerSettings()") . "</td>\n\t</tr>\t\t\t\t\n</table>\n";
    $mode = $mode_tun;
    if ($vpn->main_array["GLOBAL"]["DEV_TYPE"] == "tap0") {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_SERVER"] != 1) {
        $status = FATAL_ERROR_SHOW_128("<strong style='font-size:22px'>{OPENVPN_NOT_ENABLED}</strong><hr>\n\t\t\t{OPENVPN_NOT_ENABLED_TEXT}\n\t\t\t") . "<center style='margin:30px'>" . button("{enable_service}", "Loadjs('index.openvpn.enable.progress.php')", 42) . "</center>";
    }
    if ($status == null) {
        $button_apply = button("{OPENVPN_APPLY_CONFIG}", "Loadjs('index.openvpn.enable.progress.php')", 34) . "&nbsp;|&nbsp;";
    }
    $html = "\n<div style='font-size:28px;margin-bottom:30px'>{OPENVPN_SERVER_SETTINGS}</div>\n{$status}\n<div style='width:98%' class=form>\n\n\n<div id='OPENVPN_SERVER_SETTINGS'>\n<div style='text-align:right'>{$button_script}</div>\n{$mandatories}\n{$mode}\n<div style='margin-top:15px;text-align:right;font-size:34px'><hr>{$button_apply}{$button_edit}</div>\t\n</div>\n";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
    // openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull
}
Example #3
0
function server_settings(){
	
$vpn=new openvpn();
$nic=new networking();
$sock=new sockets();
$OpenVpnPasswordCert=$sock->GET_INFO("OpenVpnPasswordCert");
if($OpenVpnPasswordCert==null){$OpenVpnPasswordCert="MyKey";}




//openvpn_access_interface

$DEV_TYPE=$vpn->main_array["GLOBAL"]["DEV_TYPE"];
	

$dev=Field_array_Hash(
	array("tun"=>"{routed_IP_tunnel}","tap0"=>"{ethernet_tunnel}"),
	"DEV_TYPE",$vpn->main_array["GLOBAL"]["DEV_TYPE"],
	"OpenVPNChangeServerMode()",null,0,'font-size:13px;padding:3px'
	);
	
	
$dev="{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";	
	

if($vpn->main_array["GLOBAL"]["IP_START"]==null){$vpn->main_array["GLOBAL"]["IP_START"]="10.8.0.0";}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){$vpn->main_array["GLOBAL"]["NETMASK"]="255.255.255.0";} 

			
				

if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){$openvpn_local=null;}
$CLIENT_NAT_PORT=$vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];

if($CLIENT_NAT_PORT==null){$CLIENT_NAT_PORT=$vpn->main_array["GLOBAL"]["LISTEN_PORT"];}
$vpn->main_array["GLOBAL"]["PUBLIC_IP"];
$vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
$vpn->main_array["GLOBAL"]["LISTEN_PORT"];
$vpn->main_array["GLOBAL"]["LISTEN_PROTO"];
$vpn->main_array["GLOBAL"]["ENABLE_SERVER"];
$vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"];
$vpn->main_array["GLOBAL"]["IP_START"];
$vpn->main_array["GLOBAL"]["IPTABLES_ETH"];

if($vpn->main_array["GLOBAL"]["PUBLIC_IP"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{public_ip_addr}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["LISTEN_PORT"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}:{public_ip_addr}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["IP_START"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["LISTEN_PROTO"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{protocol}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["IP_START"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
$LDAP_AUTH="{no}";
$EnableOpenVPNEndUserPage="{no}";
if($vpn->main_array["GLOBAL"]["LDAP_AUTH"]==1){$LDAP_AUTH="{yes}";}
if($sock->GET_INFO("EnableOpenVPNEndUserPage")==1){$EnableOpenVPNEndUserPage="{yes}";}

$wake_up_ip=$vpn->main_array["GLOBAL"]["WAKEUP_IP"];
$tcp_ip=new ip();
if(!$tcp_ip->isValid($wake_up_ip)){$wake_up_ip="{disabled}";}


$ahref_edit="<a href=\"javascript:blur();\" OnClick=\"Loadjs('index.openvpn.server.php');\" style='font-size:13px;text-decoration:underline'>";

$openvpn_local="
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{openvpn_local}</a>:</td>
				<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["LOCAL_BIND"]}</a></td>
				<td>&nbsp;</td>
			</tr>";	



$mandatories="<table style='width:100%' class=form>
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{listen_port}:</a></td>
				<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["LISTEN_PORT"]}&nbsp;{$vpn->main_array["GLOBAL"]["LISTEN_PROTO"]}</a></td>
				<td>&nbsp;</td>
			</tr>
			$openvpn_local
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{public_ip_addr}</a>:</td>
				<td style='font-size:13px;'>$ahref_edit{$vpn->main_array["GLOBAL"]["PUBLIC_IP"]}:$CLIENT_NAT_PORT</a></td>
				<td>&nbsp;</td>
			<tr>	
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{password}:</a></td>
				<td style='font-size:13px'>$ahref_edit*****</a></td>
				<td>&nbsp;</td>
			<tr>
			</table>";
$proxy="{no}";
if($vpn->main_array["GLOBAL"]["USE_RPROXY"]==1){
	$proxy="{$vpn->main_array["GLOBAL"]["PROXYADDR"]}:{$vpn->main_array["GLOBAL"]["PROXYPORT"]}";
}	

if($vpn->main_array["GLOBAL"]["IPTABLES_ETH"]==null){$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]="{no}";}
				
$mode_tun="<table style='width:100%' class=form>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{enable_authentication}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$LDAP_AUTH}</td>
		<td>&nbsp;</td>
	<tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{EnableOpenVPNEndUserPage}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$EnableOpenVPNEndUserPage}</td>
		<td>&nbsp;</td>
	<tr>	
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{reverse_proxy}</a>:</td>
		<td style='font-size:13px'>$ahref_edit$proxy</td>
		<td>&nbsp;</td>
	<tr>	
	
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{from_ip_address}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["IP_START"]}</td>
		<td>&nbsp;</td>
	<tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{netmask}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["NETMASK"]}</a></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{openvpn_access_interface}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]}</a></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{wake_up_ip}</a>:</td>
		<td style='font-size:13px'>$ahref_edit$wake_up_ip</a></td>
		<td>&nbsp;</td>
	</tr>	
	
</table>";	

	$VPN_SERVER_IP=$vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
	$VPN_DHCP_FROM=$vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
	$VPN_DHCP_TO=$vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
	

	$tcp=new networking();
	if($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]==null){$vpn->main_array["GLOBAL"]["BRIDGE_ETH"]="eth0";}
	$array_ip=$tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
	if($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"]==null){$vpn->main_array["GLOBAL"]["VPN_SERVER_IP"]=$array_ip["IPADDR"];}
	if($vpn->main_array["GLOBAL"]["NETMASK"]==null){$vpn->main_array["GLOBAL"]["NETMASK"]=$array_ip["NETMASK"];}
	
if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
	
	$nics=Field_array_Hash($vpn->virtual_ip_lists(),'BRIDGE_ETH',$vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
}

$mode_tap="
	<div style='width:100%;margin-bottom:5px'>
		<table style='width:100%'>
			<tr>
				<td valign='top'>
					<div id='nicvpninfo' style='float:right;margin:5px;'>".ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"])."</div>
				</td>
				<td valign='top'>
					<div class=explain>{SERVER_MODE_TAP}</div>
				</td>
			</tr>
		</table>
	</div>
<table style='width:100%'>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{BRIDGE_ETH}:</td>
		<td width=1% nowrap>$nics</td>
		<td align='left' width=1% nowrap>". texttooltip("{add_virtual_ip_address}","{add_virtual_ip_address}","Loadjs('system.nic.config.php?js-add-nic=yes')",null,0,"font-size:13px;padding:3px")."</td>
	<tr>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{BRIDGE_ADDR}:</td>
		<td width=1% nowrap>" . Field_text('BRIDGE_ADDR',$vpn->main_array["GLOBAL"]["BRIDGE_ADDR"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_FROM}:</td>
		<td width=1% nowrap>" . Field_text('VPN_DHCP_FROM',$vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_TO}:</td>
		<td width=1% nowrap>" . Field_text('VPN_DHCP_TO',$vpn->main_array["GLOBAL"]["VPN_DHCP_TO"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>			
	<tr>
		<td colspan=3 align='right'><hr>". button("{apply}","SaveServerSettings()")."</td>
	</tr>				
</table>
";

$mode=$mode_tun;
if($vpn->main_array["GLOBAL"]["DEV_TYPE"]=="tap0"){
	$mode=$mode_tap;
}

if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
	$mode=$mode_tap;
}

$schedule=LocalParagraphe("OPENVPN_SCHEDULE_RUN","OPENVPN_SCHEDULE_RUN_TEXT","Loadjs('index.openvpn.schedule.php')",
"ScheduleSettings-48.png");

if($vpn->main_array["GLOBAL"]["ENABLE_SERVER"]<>1){$status=LocalParagraphe("OPENVPN_NOT_ENABLED","OPENVPN_NOT_ENABLED_TEXT","Loadjs('index.openvpn.server.php')","warning42.png");}

if($status==null){
	$status=LocalParagraphe("OPENVPN_APPLY_CONFIG","OPENVPN_APPLY_CONFIG_TEXT","YahooWin3(500,'index.openvpn.php?restart-server=yes','{APP_OPENVPN_APPLY}')","reconfigure-42.png");
	$script=LocalParagraphe("BUILD_OPENVPN_CLIENT_CONFIG","BUILD_OPENVPN_CLIENT_CONFIG_TEXT","Loadjs('index.openvpn.build.client.php')","script-42.png");
	
}

$html="
<table style='width:100%'>
<tr>
<td valign='top'>
<div id='OPENVPN_SERVER_SETTINGS'>
<table style='width:100%'>
		<tr>
			<td valign='top' style='padding-right:5px;border-right:5px solid #CCCCCC'>$script$status$schedule</td>
			<td valign='top'>
			<div style='font-size:16px'>{service_parameters}</div>
			$mandatories$mode</td>
		</tr>
		</table>
		
	</div>
</td>
</tr>
</table>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);		
// openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull	
}