Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
change project name to templr
Browse files Browse the repository at this point in the history
  • Loading branch information
gesquive committed May 22, 2018
1 parent ea1df34 commit 916babc
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ testData/
!.travis.yml
!_config.yml

shield
templr
Vagrantfile
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ GOCC := go
VERSION := $(shell git describe --always --tags)

# Binary name for bintray
BIN_NAME=shield
BIN_NAME=templr

# Project owner for bintray
OWNER=gesquive

# Project name for bintray
PROJECT_NAME=shield
PROJECT_NAME=templr

# Project url used for builds
# examples: github.com, bitbucket.org
Expand Down Expand Up @@ -54,7 +54,7 @@ build: gox ## Compile the project
-ldflags "-X main.version=${VERSION} -X main.dirty=${GIT_DIRTY}" \
-os="linux" \
-arch="amd64" \
-output="shield" .
-output="${BIN_NAME}" .

.PHONY: install
install: build ## Install the binary
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# shield
[![Travis CI](https://img.shields.io/travis/gesquive/shield/master.svg?style=flat-square)](https://travis-ci.org/gesquive/shield)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/gesquive/shield/blob/master/LICENSE)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/gesquive/shield)
# templr
[![Travis CI](https://img.templrs.io/travis/gesquive/templr/master.svg?style=flat-square)](https://travis-ci.org/gesquive/templr)
[![Software License](https://img.templrs.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/gesquive/templr/blob/master/LICENSE)
[![GoDoc](https://img.templrs.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/gesquive/templr)

An iptables firewall manager.

Expand All @@ -10,15 +10,15 @@ This program was created to help account for some of the shortcomings of iptable
## Installing

### Compile
This project has been tested with go1.9+ on Ubuntu 16.04. Just run `go get -u github.com/gesquive/shield` and the executable should be built for you automatically in your `$GOPATH`.
This project has been tested with go1.9+ on Ubuntu 16.04. Just run `go get -u github.com/gesquive/templr` and the executable should be built for you automatically in your `$GOPATH`.

Optionally you can clone the repo and run `make install` to build and copy the executable to `/usr/local/bin/` with correct permissions.

### Download
Alternately, you can download the latest release for your platform from [github](https://github.com/gesquive/shield/releases/latest).
Alternately, you can download the latest release for your platform from [github](https://github.com/gesquive/templr/releases/latest).

Once you have an executable, make sure to copy it somewhere on your path like `/usr/local/bin`.
If on a \*nix system, make sure to run `chmod +x /path/to/shield`.
If on a \*nix system, make sure to run `chmod +x /path/to/templr`.

## Configuration

Expand All @@ -34,16 +34,16 @@ So any variable specified on the command line would override values set in the e
### Config File
The application looks for a configuration file at the following locations in order:
- `config.yml`
- `~/.config/shield/config.yml`
- `/etc/shield/config.yml`
- `~/.config/templr/config.yml`
- `/etc/templr/config.yml`

If you are planning to run this app as a cron job, it is recommended that you place the config in `/etc/shield/config.yml`.
If you are planning to run this app as a cron job, it is recommended that you place the config in `/etc/templr/config.yml`.

### Environment Variables
Optionally, instead of using a config file you can specify config entries as environment variables. Use the prefix "SHIELD_" in front of the uppercased variable name. For example, the config variable `ipv4-only` would be the environment variable `SHIELD_IPV4_ONLY`.
Optionally, instead of using a config file you can specify config entries as environment variables. Use the prefix "templr_" in front of the uppercased variable name. For example, the config variable `ipv4-only` would be the environment variable `templr_IPV4_ONLY`.

### Firewall Rules
`shield` uses the golang [text template engine](https://golang.org/pkg/text/template/) to generate the final ruleset. In addition to the standard [functions](https://golang.org/pkg/text/template/#hdr-Functions), `shield` has a number of helper functions designed to ease the creation of iptable rules. Please refer to the [helper documentation](https://gesquive.github.io/shield/) for a list of helper functions available.
`templr` uses the golang [text template engine](https://golang.org/pkg/text/template/) to generate the final ruleset. In addition to the standard [functions](https://golang.org/pkg/text/template/#hdr-Functions), `templr` has a number of helper functions designed to ease the creation of iptable rules. Please refer to the [helper documentation](https://gesquive.github.io/templr/) for a list of helper functions available.

## Imports
Other rulesets can be imported by using the `{@ path @}` brackets, where the `path` can be either a full path or relative to the current ruleset path. A single path can be imported per set of brackets. For example:
Expand All @@ -66,20 +66,20 @@ will print out:
# Allow DNS lookups from google-public-dns-a.google.com, google-public-dns-b.google.com
```

An example rule template can be found at [`pkg/rules.example.yml`](https://github.com/gesquive/shield/blob/master/pkg/rules.example.yml).
An example rule template can be found at [`pkg/rules.example.yml`](https://github.com/gesquive/templr/blob/master/pkg/rules.example.yml).

### Cron Job
This application was developed to run from a scheduler such as cron.

You can use any scheduler that can run the `shield` with sufficient privledges. An example cron script can be found in the `pkg/services` directory. A logrotate script can also be found in the `pkg/services` directory. All of the configs assume the user to run as is named `shield`, make sure to change this if needed.
You can use any scheduler that can run the `templr` with sufficient privledges. An example cron script can be found in the `pkg/services` directory. A logrotate script can also be found in the `pkg/services` directory. All of the configs assume the user to run as is named `templr`, make sure to change this if needed.

## Usage

```console
Manage and update your iptables firewall rules

Usage:
shield [command]
templr [command]

Available Commands:
help Help about any command
Expand All @@ -90,8 +90,8 @@ Available Commands:
up Bring up the firewall(s)

Flags:
-c, --config string config file (default is $HOME/.config/shield.yml)
-h, --help help for shield
-c, --config string config file (default is $HOME/.config/templr.yml)
-h, --help help for templr
-4, --ipv4-only Apply command to IPv4 rules only.
-6, --ipv6-only Apply command to IPv6 rules only.
-l, --log-file string Path to log file
Expand All @@ -108,7 +108,7 @@ Hidden Flags:

## Documentation

This documentation can be found at github.com/gesquive/shield
This documentation can be found at github.com/gesquive/templr

## License

Expand Down
16 changes: 8 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/gesquive/cli"
"github.com/gesquive/shield/engine"
"github.com/gesquive/shield/iptables"
"github.com/gesquive/templr/engine"
"github.com/gesquive/templr/iptables"
homedir "github.com/mitchellh/go-homedir"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -30,7 +30,7 @@ var persist bool

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "shield",
Use: "templr",
Short: "iptables firewall manager",
Long: `Manage and update your iptables firewall rules`,
PersistentPreRun: preRun,
Expand All @@ -53,7 +53,7 @@ func init() {
cobra.OnInitialize(initConfig)

RootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "",
"config file (default is $HOME/.config/shield.yml)")
"config file (default is $HOME/.config/templr.yml)")
RootCmd.PersistentFlags().StringP("log-file", "l", "",
"Path to log file")

Expand All @@ -76,7 +76,7 @@ func init() {

RootCmd.PersistentFlags().MarkHidden("debug")

viper.SetEnvPrefix("shield")
viper.SetEnvPrefix("templr")
viper.AutomaticEnv()

viper.BindEnv("ipv4-only")
Expand All @@ -102,12 +102,12 @@ func initConfig() {
fmt.Println(err)
os.Exit(1)
}
homeConfig := path.Join(home, ".config/shield")
homeConfig := path.Join(home, ".config/templr")

viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath(".") // adding current directory as first search path
viper.AddConfigPath(homeConfig) // adding home directory as next search path
viper.AddConfigPath("/etc/shield")
viper.AddConfigPath("/etc/templr")

}

Expand Down Expand Up @@ -189,7 +189,7 @@ func preRun(cmd *cobra.Command, args []string) {
func getLogFilePath(defaultPath string) (logPath string) {
fi, err := os.Stat(defaultPath)
if err == nil && fi.IsDir() {
logPath = path.Join(defaultPath, "shield.log")
logPath = path.Join(defaultPath, "templr.log")
} else {
logPath = defaultPath
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/gesquive/cli"
"github.com/gesquive/shield/engine"
"github.com/gesquive/templr/engine"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/gesquive/cli"
"github.com/gesquive/shield/iptables"
"github.com/gesquive/templr/iptables"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rule Template Helper Functions

`shield` has a number of string and networking helper functions that can be used in the rule templates. An example config can be found [here](https://github.com/gesquive/shield/blob/master/pkg/rules.example.yml).
`templr` has a number of string and networking helper functions that can be used in the rule templates. An example config can be found [here](https://github.com/gesquive/templr/blob/master/pkg/rules.example.yml).

## slice
`slice` returns the given arguments as an iterable list:
Expand Down Expand Up @@ -32,7 +32,7 @@ ipfmt "8.8.8.8"
The above produces "`8.8.8.8`        "

## lookupHosts
`lookupHosts` returns a list of [HostInfo](https://godoc.org/github.com/gesquive/shield/engine#HostInfo) objects
`lookupHosts` returns a list of [HostInfo](https://godoc.org/github.com/gesquive/templr/engine#HostInfo) objects
```
lookupHosts $hostList
```
Expand Down
2 changes: 1 addition & 1 deletion engine/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestRelativePath(t *testing.T) {
}

func writeTempFile(contents []byte) (name string, err error) {
fileObj, err := ioutil.TempFile(os.TempDir(), "shield-test")
fileObj, err := ioutil.TempFile(os.TempDir(), "templr-test")
if err != nil {
return "", errors.Wrapf(err, "could not open file to write")
}
Expand Down
2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package: github.com/gesquive/shield
package: github.com/gesquive/templr
import:
- package: github.com/codeskyblue/go-sh
version: ~0.2.0
Expand Down
2 changes: 1 addition & 1 deletion iptables/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func writeFile(filePath string, contents []byte) error {
}

func getTempFile() (*os.File, error) {
file, err := ioutil.TempFile(os.TempDir(), "shield")
file, err := ioutil.TempFile(os.TempDir(), "templr")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
import (
"fmt"

"github.com/gesquive/shield/cmd"
"github.com/gesquive/templr/cmd"
)

var version = "v0.8.1-git"
var dirty = ""

func main() {
displayVersion := fmt.Sprintf("shield %s%s",
displayVersion := fmt.Sprintf("templr %s%s",
version,
dirty)
cmd.Execute(displayVersion)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/shield.cron
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 * * * * /usr/local/bin/shield
0 * * * * /usr/local/bin/templr
6 changes: 3 additions & 3 deletions pkg/services/shield.logrotate
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# place at /etc/logrotate.d/shield
# place at /etc/logrotate.d/templr

/var/log/shield.log {
/var/log/templr.log {
size 100k
missingok
rotate 10
notifempty
create 0640 shield shield
create 0640 templr templr
}
2 changes: 1 addition & 1 deletion pkg/shield.example.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rules: /etc/shield/rules.yml
rules: /etc/templr/rules.yml

0 comments on commit 916babc

Please sign in to comment.