"Fossies" - the Fresh Open Source Software Archive

Member "aif-2.1.1/share/arno-iptables-firewall/plugins/50pptp-vpn-passthrough.plugin" (16 Sep 2020, 4195 Bytes) of package /linux/privat/aif-2.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "50pptp-vpn-passthrough.plugin": 2.1.0_vs_2.1.1.

    1 # ------------------------------------------------------------------------------
    2 #       -= Arno's Iptables Firewall(AIF) - PPTP VPN Passthrough plugin =-
    3 #
    4 PLUGIN_NAME="PPTP VPN Passthrough plugin"
    5 PLUGIN_VERSION="1.01"
    6 PLUGIN_CONF_FILE="pptp-vpn-passthrough.conf"
    7 #
    8 # Last changed          : June 15, 2017
    9 # Requirements          : AIF 2.0.0+ and ip_nat_pptp
   10 # Comments              : This plugin loads the required kernel modules for PPTP VPN Clients
   11 #                         to access remote PPTP VPN Server(s) when NAT is enabled.
   12 #
   13 # Author                : (C) Copyright 2016-2017 by Lonnie Abelbeck & Arno van Amersfoort
   14 # Homepage              : https://rocky.eld.leidenuniv.nl/
   15 # Email                 : a r n o v a AT r o c k y DOT e l d DOT l e i d e n u n i v DOT n l
   16 #                         (note: you must remove all spaces and substitute the @ and the .
   17 #                         at the proper locations!)
   18 # ------------------------------------------------------------------------------
   19 # This program is free software; you can redistribute it and/or
   20 # modify it under the terms of the GNU General Public License
   21 # version 2 as published by the Free Software Foundation.
   22 #
   23 # This program is distributed in the hope that it will be useful,
   24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26 # GNU General Public License for more details.
   27 #
   28 # You should have received a copy of the GNU General Public License
   29 # along with this program; if not, write to the Free Software
   30 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   31 # ------------------------------------------------------------------------------
   32 
   33 # Plugin start function
   34 plugin_start()
   35 {
   36 
   37   if [ "$NAT" = "1" ]; then
   38     echo "${INDENT}Enable PPTP NAT helper module"
   39     modprobe_multi nf_nat_pptp ip_nat_pptp
   40 
   41     if ip4tables -nL CONNTRACK_HELPER >/dev/null 2>&1; then
   42       ip4tables -A CONNTRACK_HELPER -m conntrack --ctstate RELATED -m helper --helper pptp -j ACCEPT
   43       ip4tables -t raw -A PREROUTING -p tcp --dport 1723 -j CT --helper pptp
   44     fi
   45   else
   46     echo "${INDENT}ERROR: NAT is not enabled, this plugin will be ignored."
   47   fi
   48 
   49   return 0
   50 }
   51 
   52 
   53 # Plugin restart function
   54 plugin_restart()
   55 {
   56 
   57   # Skip plugin_stop on a restart
   58   plugin_start
   59 
   60   return 0
   61 }
   62 
   63 
   64 # Plugin stop function
   65 plugin_stop()
   66 {
   67 
   68   if [ "$NAT" = "1" ]; then
   69     if [ -e /proc/modules -a -x "$MODPROBE" ]; then
   70       if ! $MODPROBE -r nf_nat_pptp >/dev/null 2>&1; then
   71         $MODPROBE -r ip_nat_pptp >/dev/null 2>&1
   72       fi
   73       if [ $? -eq 0 ]; then
   74         echo "${INDENT}Disabled PPTP NAT helper module"
   75       fi
   76     fi
   77   fi
   78 
   79   return 0
   80 }
   81 
   82 
   83 # Plugin status function
   84 plugin_status()
   85 {
   86   return 0
   87 }
   88 
   89 
   90 # Check sanity of eg. environment
   91 plugin_sanity_check()
   92 {
   93   return 0
   94 }
   95 
   96 
   97 ############
   98 # Mainline #
   99 ############
  100 
  101 # Check where to find the config file
  102 CONF_FILE=""
  103 if [ -n "$PLUGIN_CONF_PATH" ]; then
  104   CONF_FILE="$PLUGIN_CONF_PATH/$PLUGIN_CONF_FILE"
  105 fi
  106 
  107 # Preinit to success:
  108 PLUGIN_RET_VAL=0
  109 
  110 # Check if the config file exists
  111 if [ ! -f "$CONF_FILE" ]; then
  112   printf "NOTE: Config file \"$CONF_FILE\" not found!\n        Plugin \"$PLUGIN_NAME v$PLUGIN_VERSION\" ignored!\n" >&2
  113 else
  114   # Source the plugin config file
  115   . "$CONF_FILE"
  116 
  117   if [ "$ENABLED" = "1" -a "$PLUGIN_CMD" != "stop-restart" ] ||
  118      [ "$ENABLED" = "0" -a "$PLUGIN_CMD" = "stop-restart" ] ||
  119      [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "stop" ] ||
  120      [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "status" ]; then
  121     # Show who we are:
  122     echo "${INDENT}$PLUGIN_NAME v$PLUGIN_VERSION"
  123 
  124     # Increment indention
  125     INDENT="$INDENT "
  126     
  127     # Only proceed if environment ok
  128     if ! plugin_sanity_check; then
  129       PLUGIN_RET_VAL=1
  130     else
  131       case $PLUGIN_CMD in
  132         start|'') plugin_start; PLUGIN_RET_VAL=$? ;;
  133         restart ) plugin_restart; PLUGIN_RET_VAL=$? ;;
  134         stop|stop-restart) plugin_stop; PLUGIN_RET_VAL=$? ;;
  135         status  ) plugin_status; PLUGIN_RET_VAL=$? ;;
  136         *       ) PLUGIN_RET_VAL=1; printf "\033[40m\033[1;31m${INDENT}ERROR: Invalid plugin option \"$PLUGIN_CMD\"!\033[0m\n" >&2 ;;
  137       esac
  138     fi
  139   fi
  140 fi