notifier

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 18 Imported by: 0

README

notifier

Tiny helper for publishing notifications on different platforms:

  • #slack
  • Amazon SNS
  • Microsoft Teams
  • Custom Webhooks
nmap -p80,443 scanme.nmap.org | notifier -b
slack

Installing

You can install the pre-compiled binary in several different ways

homebrew tap:
brew tap hupe1980/notifier
brew install notifier
snapcraft:

Get it from the Snap Store

sudo snap install notifier
scoop:
scoop bucket add notifier https://github.com/hupe1980/notifier-bucket.git
scoop install notifier
deb/rpm/apk:

Download the .deb, .rpm or .apk from the releases page and install them with the appropriate tools.

manually:

Download the pre-compiled binaries from the releases page and copy to the desired location.

Usage

Usage:
  notifier [filename] [flags]

Examples:
nmap -p80,443 scanme.nmap.org | notifier -b

Flags:
  -b, --bulk                   enable bulk processing
  -c, --config string          path to notifier configuration file (default: $HOME/.config/notifier/config.yaml)
  -e, --extra stringArray      additional informations for use in the template (key=value)
  -h, --help                   help for notifier
  -p, --provider stringArray   provider to send the notification to
      --proxy string           proxy url
      --rate-limit int         maximum number of HTTP requests per second
  -v, --version                version for notifier
Config

The default config file must be created at $HOME/.config/notifier/config.yaml and can have the following contents:

proxy: http://proxy.org
rateLimit: 5
providers:
  webhook:
    - id: webhook
      url: https://webhook.org
      method: POST
      template: '{{ .Message }}'
      headers:
        Content-Type: application/json
        X-Api-Key: 4711
  slack:
    - id: slack
      webhookUrl: https://hooks.slack.com/services/xxx
      template: '{{ .Message }}'
  teams:
    - id: teams
      webhookUrl: https://outlook.office.com/webhook/xxx
      template: '{{ .Message }}'
  sns:
    - id: sns
      region: us-east-1
      profile: notifier
      topicArn: arn:aws:sns:us-east-1:123456789012:MyTopic
Template

notifier uses {{ .Message }} as the default template. You can customize the template with the following placeholders:

  • {{ .Message }}
  • {{ .Username }}
  • {{ .Hostname }}

References

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(options *HTTPClientOptions) (*http.Client, error)

Types

type HTTPClientOptions

type HTTPClientOptions struct {
	Proxy     string
	RateLimit int
}

type Input

type Input struct {
	// contains filtered or unexported fields
}

func NewInput

func NewInput(filename string) (*Input, error)

func (*Input) Bulk

func (i *Input) Bulk() (string, error)

func (*Input) Close

func (i *Input) Close() error

func (*Input) Line

func (i *Input) Line() <-chan string

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

func New

func New(client *http.Client, providers []string, options *provider.Options) (*Notifier, error)

func (*Notifier) Send

func (n *Notifier) Send(ctx context.Context, message string, extras map[string]string) error

Directories

Path Synopsis
sns

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL