Skip to content

Commit

Permalink
Add --insecure flag (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkroh authored Feb 2, 2021
1 parent 41f27a4 commit 158e02a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.2.0]

- Added `--insecure` to disable TLS verification for the TLS and webhook outputs.

## [0.1.0]

### Added
Expand All @@ -18,6 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added pcap and log file inputs.
- Added udp, tcp, and tls outputs.

[Unreleased]: https://github.com/andrewkroh/stream/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/andrewkroh/stream/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/andrewkroh/stream/releases/tag/v0.2.0
[0.1.0]: https://github.com/andrewkroh/stream/releases/tag/v0.1.0
[0.0.1]: https://github.com/andrewkroh/stream/releases/tag/v0.0.1
1 change: 1 addition & 0 deletions command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func ExecuteContext(ctx context.Context) error {
rootCmd.PersistentFlags().StringVarP(&opts.Protocol, "protocol", "p", "tcp", "protocol ("+strings.Join(output.Available(), "/")+")")
rootCmd.PersistentFlags().IntVar(&opts.Retries, "retry", 10, "connection retry attempts for tcp based protocols")
rootCmd.PersistentFlags().StringVarP(&opts.StartSignal, "start-signal", "s", "", "wait for start signal")
rootCmd.PersistentFlags().BoolVar(&opts.InsecureTLS, "insecure", false, "disable tls verification")

// Webhook output flags.
rootCmd.PersistentFlags().StringVar(&opts.WebhookOptions.ContentType, "webhook-content-type", "application/json", "webhook Content-Type")
Expand Down
1 change: 1 addition & 0 deletions pkg/output/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Options struct {
Protocol string // Protocol (udp/tcp/tls).
Retries int // Number of connection retries for tcp based protocols.
StartSignal string // OS signal to wait on before starting.
InsecureTLS bool // Disable TLS verification checks.

WebhookOptions
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/output/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func New(opts *output.Options) (output.Output, error) {
func (o *Output) DialContext(ctx context.Context) error {
d := tls.Dialer{
Config: &tls.Config{
InsecureSkipVerify: true,
InsecureSkipVerify: o.opts.InsecureTLS,
},
NetDialer: &net.Dialer{Timeout: time.Second},
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/output/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package webhook
import (
"bytes"
"context"
"crypto/tls"
"fmt"
"net/http"
"net/url"
Expand All @@ -32,6 +33,11 @@ func New(opts *output.Options) (output.Output, error) {

client := &http.Client{
Timeout: time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: opts.InsecureTLS,
},
},
}

return &Output{opts: opts, client: client}, nil
Expand Down

0 comments on commit 158e02a

Please sign in to comment.