Skip to content

Commit

Permalink
Refactor and prep for Debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
britannic committed Jan 15, 2018
1 parent 131825c commit be3e72d
Show file tree
Hide file tree
Showing 37 changed files with 296 additions and 71 deletions.
11 changes: 11 additions & 0 deletions .payload/blacklist/disabled/node.def
@@ -0,0 +1,11 @@
type: bool
default: false

syntax:expression: $VAR(@) in true, false; "Must be true or false!"

help: Option to disable blacklisting

val_help: true; Schedules blacklist with system task scheduler
val_help: false; Removes blacklist from system task scheduler

commit:expression: $VAR(@) in true, false; "Must be true or false!"
8 changes: 8 additions & 0 deletions .payload/blacklist/dns-redirect-ip/node.def
@@ -0,0 +1,8 @@
type: ipv4, ipv6
help: Global redirect IP address for hosts and domains (zones)

val_help: ipv4net; IP address
val_help: ipv6net; IPv6 address

default: 0.0.0.0

6 changes: 6 additions & 0 deletions .payload/blacklist/domains/dns-redirect-ip/node.def
@@ -0,0 +1,6 @@
type: ipv4, ipv6
help: Blackhole IP address for domains

val_help: ipv4net; IP address
val_help: ipv6net; IPv6 address

7 changes: 7 additions & 0 deletions .payload/blacklist/domains/exclude/node.def
@@ -0,0 +1,7 @@
multi:
type: txt
help: Domains to EXCLUDE from DNS forwarding blacklist

syntax:expression: pattern $VAR(@) "^[[:alnum:]][-.[:alnum:]]*[[:alnum:]]$"
; "invalid host name $VAR(@)"

7 changes: 7 additions & 0 deletions .payload/blacklist/domains/include/node.def
@@ -0,0 +1,7 @@
multi:
type: txt
help: Domains to INCLUDE in the DNS forwarding blacklist

syntax:expression: pattern $VAR(@) "^[[:alnum:]][-.[:alnum:]]*[[:alnum:]]$"
; "invalid host name $VAR(@)"

1 change: 1 addition & 0 deletions .payload/blacklist/domains/node.def
@@ -0,0 +1 @@
help: Configure DNS forwarding blacklist DOMAINS
4 changes: 4 additions & 0 deletions .payload/blacklist/domains/source/node.def
@@ -0,0 +1,4 @@
tag:
type: txt
help: Blacklisted domains source name
comp_help: Type any unique name, use quotes if spaces or special characters are used
@@ -0,0 +1,2 @@
type: txt
help: Blacklist domain source description
@@ -0,0 +1,7 @@
type: ipv4, ipv6
help: Blackhole IP address for a domain source - overrides global blackhole IP

val_help: ipv4net; IP address
val_help: ipv6net; IPv6 address


9 changes: 9 additions & 0 deletions .payload/blacklist/domains/source/node.tag/file/node.def
@@ -0,0 +1,9 @@
type: txt
syntax:expression: exec
"if [ ! -f $VAR(@) ]; then \
echo \"File $VAR(@) does not exist or is not readable\"; \
exit 1; \
fi; "
syntax:expression: exec "/opt/vyatta/sbin/check_file_in_config_dir $VAR(@) '/config/scripts'"
commit:expression: $VAR(../url) == ""; "file and url are mutually exclusive, only set one or the other as a source."
help: A path and filename that provides a list of domains to blacklist, e.g. /config/user-data/hacked_domains.txt
6 changes: 6 additions & 0 deletions .payload/blacklist/domains/source/node.tag/prefix/node.def
@@ -0,0 +1,6 @@
type: txt
help: Prefix string must include all text before the domain name
comp_help: prefix; Example: "zone" - will remove 'zone ' from a line with: 'zones animp.org'

commit:expression: ($VAR(../url) == "" && $VAR(../file) != "") || ($VAR(../url) != "" && $VAR(../file) == ""); \
"Either a source url or file must be set"
11 changes: 11 additions & 0 deletions .payload/blacklist/domains/source/node.tag/url/node.def
@@ -0,0 +1,11 @@
type: txt
help: A blacklist source url that provides a list of domain names to block

# need to prohibit '!' in url (sed delimiter)
syntax:expression: pattern $VAR(@) "^[^!]+$" ; "URL must not be null and must not contain '!'"

val_help: http; Example: http://malc0de.com/bl/ZONES
comp_help: Check that the url works in a browser and is plain text only, use CTRL-V before typing a question mark

commit:expression: $VAR(../file) == ""; "file and url are mutually exclusive, only set one or the other as a source."

7 changes: 7 additions & 0 deletions .payload/blacklist/exclude/node.def
@@ -0,0 +1,7 @@
multi:
type: txt
help: domains to GLOBALLY EXCLUDE from DNS forwarding domains and hosts blacklist

syntax:expression: pattern $VAR(@) "^[[:alnum:]][-.[:alnum:]]*[[:alnum:]]$"
; "invalid domain name $VAR(@)"

7 changes: 7 additions & 0 deletions .payload/blacklist/hosts/dns-redirect-ip/node.def
@@ -0,0 +1,7 @@
type: ipv4, ipv6
help: Blackhole IP address for hosts - overrides global blackhole IP

val_help: ipv4net; IP address
val_help: ipv6net; IPv6 address


7 changes: 7 additions & 0 deletions .payload/blacklist/hosts/exclude/node.def
@@ -0,0 +1,7 @@
multi:
type: txt
help: Hosts to EXCLUDE from DNS forwarding blacklist

syntax:expression: pattern $VAR(@) "^[[:alnum:]][-.[:alnum:]]*[[:alnum:]]$"
; "invalid host name $VAR(@)"

8 changes: 8 additions & 0 deletions .payload/blacklist/hosts/include/node.def
@@ -0,0 +1,8 @@
multi:
type: txt
help: Hosts to INCLUDE in the DNS forwarding blacklist
comp_help: Wildcard all hosts for a domain by using a "." in place of the host name, i.e.: .domain.tld

syntax:expression: pattern $VAR(@) "^[.[:alnum:]][-.[:alnum:]]*[[:alnum:]]$"
; "invalid host name $VAR(@)"

2 changes: 2 additions & 0 deletions .payload/blacklist/hosts/node.def
@@ -0,0 +1,2 @@
help: Configure DNS forwarding blacklist hosts (must be fully qualified domain names)

5 changes: 5 additions & 0 deletions .payload/blacklist/hosts/source/node.def
@@ -0,0 +1,5 @@
tag:
type: txt
help: Blacklisted hosts source name

comp_help: Type any unique name, use quotes if spaces or special characters are used
2 changes: 2 additions & 0 deletions .payload/blacklist/hosts/source/node.tag/description/node.def
@@ -0,0 +1,2 @@
type: txt
help: Blacklisted hosts source description
@@ -0,0 +1,7 @@
type: ipv4, ipv6
help: Blackhole IP address for a host source - overrides global blackhole IP

val_help: ipv4net; IP address
val_help: ipv6net; IPv6 address


9 changes: 9 additions & 0 deletions .payload/blacklist/hosts/source/node.tag/file/node.def
@@ -0,0 +1,9 @@
type: txt
syntax:expression: exec
"if [ ! -f $VAR(@) ]; then \
echo \"File $VAR(@) does not exist or is not readable\"; \
exit 1; \
fi; "
syntax:expression: exec "/opt/vyatta/sbin/check_file_in_config_dir $VAR(@) '/config/scripts'"
commit:expression: $VAR(../url) == ""; "file and url are mutually exclusive, only set one or the other as a source."
help: A path and filename that provides a list of fully qualified hostnames to blacklist, e.g. /config/user-data/internal_servers_hosts.txt
6 changes: 6 additions & 0 deletions .payload/blacklist/hosts/source/node.tag/prefix/node.def
@@ -0,0 +1,6 @@
type: txt
help: Prefix string must include all text before the fully qualified domain name
val_help: prefix; Example: "0.0.0.0" - will remove '0.0.0.0 ' from a line with: '0.0.0.0 animp.org'

commit:expression: ($VAR(../url) == "" && $VAR(../file) != "") || ($VAR(../url) != "" && $VAR(../file) == ""); \
"Either a source url or file must be set"
9 changes: 9 additions & 0 deletions .payload/blacklist/hosts/source/node.tag/url/node.def
@@ -0,0 +1,9 @@
type: txt
help: A blacklist source url that provides a list of hostnames

# need to prohibit '!' in url (sed delimiter)
syntax:expression: pattern $VAR(@) "^[^!]+$" ; "URL must not be null and must not contain '!'"

val_help: http; Example: http://someonewhocares.org/hosts/zero/
comp_help: Check that the url works in a browser and is plain text only, use CTRL-V before typing a question mark
commit:expression: $VAR(../file) == ""; "file and url are mutually exclusive, only set one or the other as a source."
10 changes: 10 additions & 0 deletions .payload/blacklist/node.def
@@ -0,0 +1,10 @@
priority: 1999 # Run after DNS forwarding is configured
help: Add and delete blacklist blackhole IP, exclusions and URL sources

end: if [[ "$COMMIT_ACTION" != "DELETE" ]]; then
arg='-v'
[[ -f /etc/nologin ]] && arg=''
sudo /config/scripts/update-dnsmasq.pl ${arg};
else
sudo /config/scripts/update-dnsmasq.pl -v
fi
85 changes: 85 additions & 0 deletions .payload/ubnt-cln-cfg-orphans.sh
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
#
# **** License ****
#
# Copyright (C) 2018 by Helm Rock Consulting
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# **** End License ****
#
# Author: Neil Beadle
# Description: This script cleans up orphaned configure sessions and releases
# disk space

VERSION='0.7'
ME=$(basename ${0})

# Comment/uncomment line below for debug
# DEBUG="echo Dry run, this command would be executed: "

# Make sure script runs as root
if [[ ${EUID} != 0 ]]
then
echo "${ME} version ${VERSION} must be run as root, use: [sudo $(pwd)/${ME}]"
exit 1
fi

if [[ $(ps -a | grep -e 'newgrp$') ]]
then
echo "Configure session running - exit 'configure' before running this script!"
exit 1
else
for i in /opt/vyatta/config/tmp/new*
do
if [[ -d "${i}" ]]
then
echo "Unmounting ${i}..."
${DEBUG} umount "${i}"
if [[ ${?} == 0 ]]
then
echo "${i} unmounted."
else
echo "Error: Couldn't unmount ${i}!"
fi
if [[ -d "${i}" ]]
then
echo "Removing directory ${i}..."
${DEBUG} rm -rf "${i}"
fi
fi
done
for i in /opt/vyatta/config/tmp/*
do
if [[ -d "${i}" ]]
then
echo "Removing directory ${i}..."
${DEBUG} rm -rf "${i}"
fi
done
for i in /tmp/changes_only_*
do
if [[ -d "${i}" ]]
then
echo "Removing directory ${i}..."
${DEBUG} rm -rf "${i}"
fi
done
for i in /tmp/config.new.boot.*
do
if [[ ! -s "${i}" ]]
then
echo "Removing file ${i}..."
${DEBUG} rm -rf "${i}"
fi
done
fi
26 changes: 0 additions & 26 deletions LICENSE.txt

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.6a1
0.0.6
10 changes: 10 additions & 0 deletions ignore.goconvey
@@ -0,0 +1,10 @@
// Uncomment the next line to disable the package when running the GoConvey UI:
//IGNORE

// Uncomment the next line to limit testing to the specified test function name pattern:
//-run=TestAssertionsAreAvailableFromConveyPackage

// Uncomment the next line to limit testing to those tests that don't bail when testing.Short() is true:
//-short

// include any additional `go test` flags or application-specific flags below:
22 changes: 11 additions & 11 deletions internal/edgeos/config.go
Expand Up @@ -41,17 +41,17 @@ const (
agent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7`
all = "all"
blackhole = "dns-redirect-ip"
dbg = false
disabled = "disabled"
domains = "domains"
files = "file"
hosts = "hosts"
notknown = "unknown"
preNoun = "pre-configured"
rootNode = "blacklist"
src = "source"
urls = "url"
zones = "zones"
// dbg = false
disabled = "disabled"
domains = "domains"
files = "file"
hosts = "hosts"
notknown = "unknown"
preNoun = "pre-configured"
rootNode = "blacklist"
src = "source"
urls = "url"
zones = "zones"

// ExcDomns labels domain exclusions
ExcDomns = "domn-excludes"
Expand Down
2 changes: 1 addition & 1 deletion internal/edgeos/config_test.go
Expand Up @@ -164,7 +164,7 @@ func TestExcludes(t *testing.T) {
tests := []struct {
get list
list list
raw []string
// raw []string
name string
node string
}{
Expand Down

0 comments on commit be3e72d

Please sign in to comment.