Skip to content

Commit

Permalink
Merge 71ffc53 into 5a321e1
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Oct 29, 2023
2 parents 5a321e1 + 71ffc53 commit f4cba5c
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 96 deletions.
31 changes: 17 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ SOURCE=$(shell find . -name "*go" -a -not -path "./vendor/*" -not -path "./cmd/t
VERSION=$(shell git describe --tags)
TOXICMD:=docker-compose exec toxiproxy /go/bin/toxiproxy-cli

.PHONY: test-app test-lib build build tags short-test test run-broker clean dist-clean toxiproxy-setup toxiproxy-cmd
.PHONY: phony

build:
cd cmd/rabtap && GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \
"-s -w -X main.version=$(VERSION)" -o ../../bin/rabtap
build: phony
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \
"-s -w -X main.version=$(VERSION)" -o ./bin/rabtap ./cmd/rabtap
wasm-build: phony
CGO_ENABLED=1 GOOS=wasip1 GOARCH=wasm gotip build -o ./bin/rabtap-wasm ./cmd/rabtap

tags: $(SOURCE)
@gotags -f tags $(SOURCE)

lint:
lint: phony
golangci-lint run

short-test:
short-test: phony
go test -v -race github.com/jandelgado/rabtap/cmd/rabtap
go test -v -race github.com/jandelgado/rabtap/pkg

test-app:
test-app: phony
go test -race -v -tags "integration" -cover -coverprofile=coverage_app.out github.com/jandelgado/rabtap/cmd/rabtap

test-lib:
test-lib: phony
go test -race -v -tags "integration" -cover -coverprofile=coverage.out github.com/jandelgado/rabtap/pkg

test: test-app test-lib
Expand All @@ -32,24 +34,25 @@ test: test-app test-lib

# docker-compose up must be first called. Then create a proxy with
# this target and connect to to localhost:55672 (amqp).
toxiproxy-setup:
toxiproxy-setup: phony
$(TOXICMD) c amqp --listen :55672 --upstream rabbitmq:5672 || true

# call with e.g.
# make toxiproxy-cmd -- show help
# make TOXIARGS="toggle amqp" -- toggle amqp proxy
toxiproxy-cmd:
toxiproxy-cmd: phony
$(TOXICMD) $(TOXIARGS)

# run rabbitmq server for integration test using docker container.
run-broker:
run-broker: phony
cd inttest/pki && ./mkcerts.sh
cd inttest/rabbitmq && docker-compose up

dist-clean: clean
rm -rf *.out bin/ dist/

clean:
cd cmd/rabtap && go clean -r
cd cmd/testgen && go clean -r
clean: phony
go clean -r ./cmd/rabtap
go clean -r ./cmd/testgen

phony:
40 changes: 23 additions & 17 deletions cmd/rabtap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,34 @@ import (
"crypto/x509"
"fmt"
"io/ioutil"

// log2 "log"

"net/url"
"os"
"os/signal"
"sort"
"time"

"github.com/fatih/color"
rabtap "github.com/jandelgado/rabtap/pkg"
"github.com/sirupsen/logrus"
)

//var log = slog.Default()

// type Logger struct{}

// func (s Logger) Debug(format string, a ...interface{}) { log2.Printf("FATAL "+format, a...) }
// func (s Logger) Error(err error) { log2.Printf("ERROR %v", err) }
// func (s Logger) Fatal(err error) { log2.Fatalf("FATAL %v", err) }
// func (s Logger) Info(format string, a ...interface{}) { log2.Printf("INFO "+format, a...) }
// func (s Logger) Warnf(format string, a ...interface{}) { log2.Printf("WARN "+format, a...) }
// func (s Logger) Debugf(format string, a ...interface{}) { log2.Printf("DEBUG "+format, a...) }
// func (s Logger) Infof(format string, a ...interface{}) { log2.Printf("INFO "+format, a...) }
// func (s Logger) Errorf(format string, a ...interface{}) { log2.Printf("ERROR "+format, a...) }

// var log = Logger{}

var log = logrus.New()

func initLogging(verbose bool) {
Expand Down Expand Up @@ -57,7 +75,6 @@ func getTLSConfig(insecureTLS bool, certFile string, keyFile string, caFile stri
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
failOnError(err, "invalid client tls cert/key file", os.Exit)
tlsConfig.Certificates = []tls.Certificate{cert}
tlsConfig.BuildNameToCertificate()
}

if caFile != "" {
Expand All @@ -66,7 +83,6 @@ func getTLSConfig(insecureTLS bool, certFile string, keyFile string, caFile stri
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tlsConfig.RootCAs = caCertPool
tlsConfig.BuildNameToCertificate()
}
return tlsConfig
}
Expand Down Expand Up @@ -255,6 +271,9 @@ func dispatchCmd(ctx context.Context, args CommandLineArgs, tlsConfig *tls.Confi
}

func main() {
// Test: force color
color.NoColor = false

args, err := ParseCommandLineArgs(os.Args[1:])
if err != nil {
log.Fatal(err)
Expand All @@ -263,21 +282,8 @@ func main() {
initLogging(args.Verbose)
tlsConfig := getTLSConfig(args.InsecureTLS, args.TLSCertFile, args.TLSKeyFile, args.TLSCaFile)

// translate ^C (Interrput) in ctx.Done()
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
cancel()
}()
go func() {
select {
case <-c:
cancel()
case <-ctx.Done():
}
}()
go SigIntHandler(ctx, cancel)

dispatchCmd(ctx, args, tlsConfig)
}
22 changes: 22 additions & 0 deletions cmd/rabtap/signal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build !wasip1

package main

import (
"context"
"os"
"os/signal"
)

func SigIntHandler(ctx context.Context, cancel func()) {
// translate ^C (Interrput) in ctx.Done()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt) // NOT WITH WASM!
select {
case <-c:
cancel()
case <-ctx.Done():
}

signal.Stop(c)
}
12 changes: 12 additions & 0 deletions cmd/rabtap/signal_wasip1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build wasip1

package main

import (
"context"
)

func SigIntHandler(ctx context.Context, cancel func()) {
// does currently not work with WASM and makes the program hang.
// signal.Notify(c, os.Interrupt)
}
2 changes: 1 addition & 1 deletion cmd/rabtap/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type MessageReceiveLoopPred func(rabtap.TapMessage) bool

// createCountingMessageReceivePred returns a (stateful) predicate that will
// return false after it is called num times, thus limiting the number of
// messages received. If num is 0, a predicate always returning true is
// mssages received. If num is 0, a predicate always returning true is
// returned.
func createCountingMessageReceivePred(num int64) MessageReceiveLoopPred {

Expand Down
18 changes: 10 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ go 1.18
require (
github.com/Knetic/govaluate v0.0.0-20171022003610-9aa49832a739 //v0.0.0-20171022003610-9aa49832a739
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/fatih/color v1.14.1
github.com/fatih/color v1.15.0
github.com/google/uuid v1.3.0
github.com/mattn/go-colorable v0.1.13
github.com/rabbitmq/amqp091-go v1.7.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
golang.org/x/net v0.7.0
golang.org/x/sync v0.1.0
github.com/rabbitmq/amqp091-go v1.8.1
github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af
github.com/stretchr/testify v1.8.4
golang.org/x/net v0.11.0
golang.org/x/sync v0.3.0
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
)

require github.com/stealthrocket/net v0.1.4

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/sys v0.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
26 changes: 26 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand All @@ -25,14 +27,24 @@ github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peK
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rabbitmq/amqp091-go v1.5.0 h1:VouyHPBu1CrKyJVfteGknGOGCzmOz0zcv/tONLkb7rg=
github.com/rabbitmq/amqp091-go v1.5.0/go.mod h1:JsV0ofX5f1nwOGafb8L5rBItt9GyhfQfcJj+oyz0dGg=
github.com/rabbitmq/amqp091-go v1.7.0 h1:V5CF5qPem5OGSnEo8BoSbsDGwejg6VUJsKEdneaoTUo=
github.com/rabbitmq/amqp091-go v1.7.0/go.mod h1:wfClAtY0C7bOHxd3GjmF26jEHn+rR/0B3+YV+Vn9/NI=
github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA=
github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af h1:Sp5TG9f7K39yfB+If0vjp97vuT74F72r8hfRpP8jLU0=
github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stealthrocket/net v0.1.4 h1:Wy0bAeu5Y3iiQM1fgsjZOES9AsB0nsXuDK21A3JfPIk=
github.com/stealthrocket/net v0.1.4/go.mod h1:VvoFod9pYC9mo+bEg2NQB/D+KVOjxfhZjZ5zyvozq7M=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand All @@ -42,11 +54,15 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand All @@ -57,12 +73,18 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -75,6 +97,10 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
2 changes: 1 addition & 1 deletion inttest/pki/mkcerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -eou pipefail

CA_CN=${CA_CN:-rabtap testing CA}
SERVER_CN=${SERVER_CN:-localhost}
CLIENTS=${CLIENTS:-testuser unknown}
CLIENTS=${CLIENTS:-testuser unknown guest}

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

Expand Down
2 changes: 1 addition & 1 deletion inttest/rabbitmq/rabbitmq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ ssl_options.cacertfile = /certs/ca.crt
ssl_options.certfile = /certs/server.crt
ssl_options.keyfile = /certs/server.key
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false
ssl_options.fail_if_no_peer_cert = true

38 changes: 4 additions & 34 deletions pkg/dial.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
//go:build !wasip1

package rabtap

import (
"crypto/tls"
"net/url"
"time"

amqp "github.com/rabbitmq/amqp091-go"
)

const (
defaultHeartbeat = 10 * time.Second
defaultLocale = "en_US"
"net"
)

// DialTLS is a Wrapper for amqp.DialTLS that supports EXTERNAL auth for mtls
// can be removed when https://github.com/streadway/amqp/pull/121 gets some day
// merged.
func DialTLS(uri string, tlsConfig *tls.Config) (*amqp.Connection, error) {

u, err := url.Parse(uri)
if err != nil {
return nil, err
}

// if client certificates are specified and no explicit credentials in the
// amqp connect url are given, then request EXTERNAL auth.
var sasl []amqp.Authentication
if tlsConfig.Certificates != nil && u.User == nil {
sasl = []amqp.Authentication{&amqp.ExternalAuth{}}
}

return amqp.DialConfig(uri, amqp.Config{
Heartbeat: defaultHeartbeat,
TLSClientConfig: tlsConfig,
Locale: defaultLocale,
SASL: sasl,
})
}
var Dialer = net.Dial
5 changes: 5 additions & 0 deletions pkg/dial_func.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package rabtap

import "net"

type DialFunc func(network, addr string) (net.Conn, error)

0 comments on commit f4cba5c

Please sign in to comment.