Skip to content

Commit

Permalink
Improvements and filename change
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepWoods committed Jun 20, 2019
1 parent 83259f2 commit 93126bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The project provides an rc script to start and stop the NxFilter service and an
Challenges
----------

Because the NxFilter software is proprietary, it cannot be built from source and cannot be included directly in a package. To work around this, we can download the NxFilter software directly from NxFilter during the installation script process.
Because the NxFilter software is proprietary, it cannot be built from source and cannot be included directly in a package. To work around this, we can download the NxFilter software directly from the NxFilter homepage during the installation script process.

Licensing
---------
Expand All @@ -37,9 +37,9 @@ Usage

To install NxFilter and the rc startup script:

1. Log into the pfSense webConfigurator(System-Advanced-Admin Access) and change the TCP port to something other than port 80 and disable the WebGUI redirect rule. NxFilter GUI and block page will need to use port 80.
2. In the webConfigurator, disable the DNS resolver(Services-DNS Resolver-General Settings). NxFilter provides filtering DNS services on port 53.
3. In the webConfigurator, create firewall rules(Firewall-Rules-LAN) to allow access to LAN address for NxFilter udp ports 53, 1813 and tcp ports 80, 443, 19002:19004
1. Log into the pfSense webConfigurator(System- > Advanced -> Admin Access) and change the TCP port to something other than port 80 and disable the WebGUI redirect rule. NxFilter GUI and block page will need to use port 80.
2. In the webConfigurator, disable the DNS resolver(Services -> DNS Resolver -> General Settings). NxFilter provides filtering DNS services on port 53.
3. In the webConfigurator, create firewall rules(Firewall -> Rules -> LAN) to allow access to LAN address for NxFilter udp ports 53, 1813 and tcp ports 80, 443, 19002:19004
4. Log in to the pfSense command line shell as root.
5. Run these commands, which downloads the install script from this Github repository and then executes it with sh:

Expand All @@ -58,14 +58,14 @@ To start and stop NxFilter, use the `service` command from the command line.
- To start NxFilter:

```
service nxfilter start
service nxfilter.sh start
```
NxFilter takes a minute or two to start the web interface. The 'start' command exits immediately while the startup continues in the background.

- To stop NxFilter:

```
service nxfilter stop
service nxfilter.sh stop
```

Contributing
Expand Down
18 changes: 9 additions & 9 deletions install-nxfilter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ clear
# The latest version of NxFilter:
NXFILTER_VERSION=$1
if [ -z "$NXFILTER_VERSION" ]; then
echo "Version not supplied, fetching latest"
echo "NxFilter version not supplied, checking nxfilter.org for the latest version..."
NXFILTER_VERSION=$(
curl -sL 'https://nxfilter.org/p3/download' -H 'X-Requested-With: XMLHttpRequest' | grep -Eo "(http|https)://pub.nxfilter.org/nxfilter-[a-zA-Z0-9./?=_-]*.zip" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" 2>/dev/null
)

if ! $(echo "$NXFILTER_VERSION" | egrep -q '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'); then
echo "Fetched version \"$NXFILTER_VERSION\" doesn't make sense"
echo "If that's correct, run this again with it as the first argument"
echo "If that's correct, run this script again with \"$NXFILTER_VERSION\" as the first argument: sh install-nxfilter.sh \"$NXFILTER_VERSION\""
exit 1
fi

printf "Is version $NXFILTER_VERSION OK? [y/N] " && read RESPONSE
printf "OK to download and install NxFilter version $NXFILTER_VERSION ? [y/N] " && read RESPONSE
case $RESPONSE in
[Yy] ) ;;
* ) exit 1;;
Expand All @@ -27,7 +27,7 @@ fi
NXFILTER_SOFTWARE_URI="http://pub.nxfilter.org/nxfilter-${NXFILTER_VERSION}.zip"

# service script
SERVICE_SCRIPT_URI="https://raw.githubusercontent.com/DeepWoods/nxfilter-pfsense/master/rc.d/nxfilter"
SERVICE_SCRIPT_URI="https://raw.githubusercontent.com/DeepWoods/nxfilter-pfsense/master/rc.d/nxfilter.sh"


# If pkg-ng is not yet installed, bootstrap it:
Expand All @@ -53,9 +53,9 @@ FREEBSD_PACKAGE_URL="https://pkg.freebsd.org/${ABI}/latest/All/"
FREEBSD_PACKAGE_LIST_URL="https://pkg.freebsd.org/${ABI}/latest/packagesite.txz"

# Stop NxFilter if it's already running
if [ -f /usr/local/etc/rc.d/nxfilter ]; then
if [ -f /usr/local/etc/rc.d/nxfilter.sh ]; then
echo -n "Stopping the NxFilter service..."
/usr/sbin/service nxfilter stop
/usr/sbin/service nxfilter.sh stop
echo " ok"
fi

Expand Down Expand Up @@ -160,11 +160,11 @@ echo " ok"

# Fetch the service script from github:
echo -n "Downloading service script..."
/usr/bin/fetch -o /usr/local/etc/rc.d/nxfilter ${SERVICE_SCRIPT_URI}
/usr/bin/fetch -o /usr/local/etc/rc.d/nxfilter.sh ${SERVICE_SCRIPT_URI}
echo " ok"

# add execute permissions
chmod +x /usr/local/etc/rc.d/nxfilter
chmod +x /usr/local/etc/rc.d/nxfilter.sh
chmod +x /usr/local/nxfilter/bin/*.sh

# Add the startup variable to rc.conf.local.
Expand All @@ -177,5 +177,5 @@ if [ ! -f /etc/rc.conf.local ] || [ $(grep -c nxfilter_enable /etc/rc.conf.local
fi

echo -n "Starting the NxFilter service..."
/usr/sbin/service nxfilter start
/usr/sbin/service nxfilter.sh start
echo "All done!"
13 changes: 6 additions & 7 deletions rc.d/nxfilter → rc.d/nxfilter.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
#!/bin/sh

# REQUIRE: FILESYSTEMS
# REQUIRE: NETWORKING
# PROVIDE: NxFilter
# REQUIRE: FILESYSTEMS NETWORKING
# PROVIDE: nxfilter

. /etc/rc.subr

name="nxfilter"
desc="NxFilter DNS filter."
rcvar="nxfilter_enable"
start_cmd="nxfilter_start"
stop_cmd="nxfilter_stop"

pidfile="/var/run/${name}.pid"

load_rc_config ${name}

nxfilter_start()
{
if checkyesno ${rcvar}; then
echo "Starting NxFilter..."
/usr/local/nxfilter/bin/startup.sh -d
sleep 1
/usr/local/nxfilter/bin/startup.sh -d &
echo `ps | grep 'nxd.jar' | grep -v grep | awk '{ print $1 }'` > $pidfile
fi
}
Expand All @@ -30,7 +28,7 @@ nxfilter_stop()
if [ -f $pidfile ]; then
echo -n "Stopping NxFilter..."

/usr/local/nxfilter/bin/shutdown.sh
/usr/local/nxfilter/bin/shutdown.sh &

while [ `pgrep -F $pidfile` ]; do
echo -n "."
Expand All @@ -45,4 +43,5 @@ nxfilter_stop()
fi
}

load_rc_config ${name}
run_rc_command "$1"

0 comments on commit 93126bc

Please sign in to comment.