Add traffic plugin

This allows for advanced loadbalancing and maybe geoIP loadbalancing.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2019-10-05 11:45:45 +01:00
parent d6669dee80
commit d5c5ba010c
7 changed files with 462 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package traffic
import (
"testing"
"github.com/caddyserver/caddy"
)
func TestSetup(t *testing.T) {
tests := []struct {
input string
shouldErr bool
}{
// positive
{`traffic`, false},
// negative
{`traffic fleeb`, true},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.input)
err := parse(c)
if test.shouldErr && err == nil {
t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input)
}
if err != nil {
if !test.shouldErr {
t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err)
}
}
}
}