mirror of https://github.com/0xERR0R/blocky.git
Update to gingko v2 (#447)
This commit is contained in:
parent
1253913e63
commit
27c8cbf2b7
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/helpertest"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package expirationcache
|
|||
import (
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package stringcache
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/0xERR0R/blocky/api"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/sirupsen/logrus/hooks/test"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
@ -40,7 +40,9 @@ var _ = Describe("Lists command", func() {
|
|||
}
|
||||
})
|
||||
It("should end with error", func() {
|
||||
_ = newRefreshCommand().Execute()
|
||||
c := newRefreshCommand()
|
||||
c.SetArgs(make([]string, 0))
|
||||
_ = c.Execute()
|
||||
Expect(fatal).Should(BeTrue())
|
||||
Expect(loggerHook.LastEntry().Message).Should(ContainSubstring("NOK: 500 Internal Server Error"))
|
||||
})
|
||||
|
@ -48,7 +50,9 @@ var _ = Describe("Lists command", func() {
|
|||
When("Url is wrong", func() {
|
||||
It("should end with error", func() {
|
||||
apiPort = 0
|
||||
_ = newRefreshCommand().Execute()
|
||||
c := newRefreshCommand()
|
||||
c.SetArgs(make([]string, 0))
|
||||
_ = c.Execute()
|
||||
Expect(fatal).Should(BeTrue())
|
||||
Expect(loggerHook.LastEntry().Message).Should(ContainSubstring("connection refused"))
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/0xERR0R/blocky/api"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package cmd
|
|||
import (
|
||||
"github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/0xERR0R/blocky/config"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
var _ = Describe("Serve command", func() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
@ -9,6 +9,7 @@ var _ = Describe("Version command", func() {
|
|||
When("Version command is called", func() {
|
||||
It("should execute without error", func() {
|
||||
c := NewVersionCommand()
|
||||
c.SetArgs(make([]string, 0))
|
||||
err := c.Execute()
|
||||
Expect(err).Should(Succeed())
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ import (
|
|||
"github.com/0xERR0R/blocky/helpertest"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/extensions/table"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
29
go.mod
29
go.mod
|
@ -5,18 +5,17 @@ go 1.17
|
|||
require (
|
||||
github.com/alicebob/miniredis/v2 v2.18.0
|
||||
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
|
||||
github.com/avast/retry-go/v4 v4.0.3
|
||||
github.com/creasty/defaults v1.5.2
|
||||
github.com/go-chi/chi/v5 v5.0.7
|
||||
github.com/go-chi/cors v1.2.0
|
||||
github.com/go-redis/redis/v8 v8.11.4
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/miekg/dns v1.1.46
|
||||
github.com/mroth/weightedrand v0.4.1
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
github.com/onsi/gomega v1.18.1
|
||||
github.com/prometheus/client_golang v1.12.1
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
|
@ -25,10 +24,17 @@ require (
|
|||
github.com/x-cray/logrus-prefixed-formatter v0.5.2
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gorm.io/driver/mysql v1.2.3
|
||||
gorm.io/driver/postgres v1.2.3
|
||||
gorm.io/driver/mysql v1.3.2
|
||||
gorm.io/driver/sqlite v1.2.6
|
||||
gorm.io/gorm v1.22.5
|
||||
gorm.io/gorm v1.23.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/avast/retry-go/v4 v4.0.3
|
||||
github.com/go-chi/chi/v5 v5.0.7
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/onsi/ginkgo/v2 v2.1.3
|
||||
gorm.io/driver/postgres v1.3.1
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -37,7 +43,6 @@ require (
|
|||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
|
@ -48,17 +53,14 @@ require (
|
|||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgtype v1.9.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.14.0 // indirect
|
||||
github.com/jackc/pgtype v1.9.1 // indirect
|
||||
github.com/jackc/pgx/v4 v4.14.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.4 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
|
@ -75,6 +77,5 @@ require (
|
|||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
)
|
||||
|
|
25
go.sum
25
go.sum
|
@ -315,14 +315,14 @@ github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01C
|
|||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||
github.com/jackc/pgtype v1.9.0 h1:/SH1RxEtltvJgsDqp3TbiTFApD3mey3iygpuEGeuBXk=
|
||||
github.com/jackc/pgtype v1.9.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||
github.com/jackc/pgtype v1.9.1 h1:MJc2s0MFS8C3ok1wQTdQxWuXQcB6+HwAm5x1CzW7mf0=
|
||||
github.com/jackc/pgtype v1.9.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||
github.com/jackc/pgx/v4 v4.14.0 h1:TgdrmgnM7VY72EuSQzBbBd4JA1RLqJolrw9nQVZABVc=
|
||||
github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8=
|
||||
github.com/jackc/pgx/v4 v4.14.1 h1:71oo1KAGI6mXhLiTMn6iDFcp3e7+zon/capWjl2OEFU=
|
||||
github.com/jackc/pgx/v4 v4.14.1/go.mod h1:RgDuE4Z34o7XE92RpLsvFiOEfrAUT0Xt2KxvX73W06M=
|
||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
|
@ -330,7 +330,6 @@ github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv
|
|||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.3/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
|
||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
|
@ -420,8 +419,9 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108
|
|||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/ginkgo/v2 v2.1.3 h1:e/3Cwtogj0HA+25nMP1jCMDIf8RtRYbGwGGuBIFztkc=
|
||||
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
|
@ -1021,16 +1021,15 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.2.3 h1:cZqzlOfg5Kf1VIdLC1D9hT6Cy9BgxhExLj/2tIgUe7Y=
|
||||
gorm.io/driver/mysql v1.2.3/go.mod h1:qsiz+XcAyMrS6QY+X3M9R6b/lKM1imKmcuK9kac5LTo=
|
||||
gorm.io/driver/postgres v1.2.3 h1:f4t0TmNMy9gh3TU2PX+EppoA6YsgFnyq8Ojtddb42To=
|
||||
gorm.io/driver/postgres v1.2.3/go.mod h1:pJV6RgYQPG47aM1f0QeOzFH9HxQc8JcmAgjRCgS0wjs=
|
||||
gorm.io/driver/mysql v1.3.2 h1:QJryWiqQ91EvZ0jZL48NOpdlPdMjdip1hQ8bTgo4H7I=
|
||||
gorm.io/driver/mysql v1.3.2/go.mod h1:ChK6AHbHgDCFZyJp0F+BmVGb06PSIoh9uVYKAlRbb2U=
|
||||
gorm.io/driver/postgres v1.3.1 h1:Pyv+gg1Gq1IgsLYytj/S2k7ebII3CzEdpqQkPOdH24g=
|
||||
gorm.io/driver/postgres v1.3.1/go.mod h1:WwvWOuR9unCLpGWCL6Y3JOeBWvbKi6JLhayiVclSZZU=
|
||||
gorm.io/driver/sqlite v1.2.6 h1:SStaH/b+280M7C8vXeZLz/zo9cLQmIGwwj3cSj7p6l4=
|
||||
gorm.io/driver/sqlite v1.2.6/go.mod h1:gyoX0vHiiwi0g49tv+x2E7l8ksauLK0U/gShcdUsjWY=
|
||||
gorm.io/gorm v1.22.3/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
|
||||
gorm.io/gorm v1.22.4/go.mod h1:1aeVC+pe9ZmvKZban/gW4QPra7PRoTEssyc922qCAkk=
|
||||
gorm.io/gorm v1.22.5 h1:lYREBgc02Be/5lSCTuysZZDb6ffL2qrat6fg9CFbvXU=
|
||||
gorm.io/gorm v1.22.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.1 h1:aj5IlhDzEPsoIyOPtTRVI+SyaN1u6k613sbt4pwbxG0=
|
||||
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/evt"
|
||||
|
||||
. "github.com/0xERR0R/blocky/helpertest"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ func (d *DatabaseWriter) periodicFlush() {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *DatabaseWriter) Write(entry *Entry) {
|
||||
func (d *DatabaseWriter) Write(entry *LogEntry) {
|
||||
domain := util.ExtractDomain(entry.Request.Req.Question[0])
|
||||
eTLD, _ := publicsuffix.EffectiveTLDPlusOne(domain)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
var _ = Describe("DatabaseWriter", func() {
|
||||
|
@ -34,7 +34,7 @@ var _ = Describe("DatabaseWriter", func() {
|
|||
Reason: "Resolved",
|
||||
RType: model.ResponseTypeRESOLVED,
|
||||
}
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: request,
|
||||
Response: response,
|
||||
Start: time.Now(),
|
||||
|
@ -69,7 +69,7 @@ var _ = Describe("DatabaseWriter", func() {
|
|||
}
|
||||
|
||||
// one entry with now as timestamp
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: request,
|
||||
Response: response,
|
||||
Start: time.Now(),
|
||||
|
@ -77,7 +77,7 @@ var _ = Describe("DatabaseWriter", func() {
|
|||
})
|
||||
|
||||
// one entry before 2 days -> should be deleted
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: request,
|
||||
Response: response,
|
||||
Start: time.Now().AddDate(0, 0, -2),
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewCSVWriter(target string, perClient bool, logRetentionDays uint64) (*File
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (d *FileWriter) Write(entry *Entry) {
|
||||
func (d *FileWriter) Write(entry *LogEntry) {
|
||||
var clientPrefix string
|
||||
|
||||
dateString := entry.Start.Format("2006-01-02")
|
||||
|
@ -101,7 +101,7 @@ func (d *FileWriter) CleanUp() {
|
|||
}
|
||||
}
|
||||
|
||||
func createQueryLogRow(logEntry *Entry) []string {
|
||||
func createQueryLogRow(logEntry *LogEntry) []string {
|
||||
request := logEntry.Request
|
||||
response := logEntry.Response
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/0xERR0R/blocky/model"
|
||||
"github.com/0xERR0R/blocky/util"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
@ -48,7 +48,7 @@ var _ = Describe("FileWriter", func() {
|
|||
Expect(err).Should(Succeed())
|
||||
|
||||
By("entry for client 1", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client1"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
@ -65,7 +65,7 @@ var _ = Describe("FileWriter", func() {
|
|||
})
|
||||
|
||||
By("entry for client 2", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client2"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
@ -95,7 +95,7 @@ var _ = Describe("FileWriter", func() {
|
|||
Expect(err).Should(Succeed())
|
||||
|
||||
By("entry for client 1", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client1"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
@ -112,7 +112,7 @@ var _ = Describe("FileWriter", func() {
|
|||
})
|
||||
|
||||
By("entry for client 2", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client2"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
@ -146,7 +146,7 @@ var _ = Describe("FileWriter", func() {
|
|||
Expect(err).Should(Succeed())
|
||||
|
||||
By("entry today", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client1"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
@ -162,7 +162,7 @@ var _ = Describe("FileWriter", func() {
|
|||
})
|
||||
})
|
||||
By("entry 2 days ago", func() {
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: &model.Request{
|
||||
ClientNames: []string{"client1"},
|
||||
Req: util.NewMsgWithQuestion("google.de.", dns.TypeA),
|
||||
|
|
|
@ -19,7 +19,7 @@ func NewLoggerWriter() *LoggerWriter {
|
|||
return &LoggerWriter{logger: log.PrefixedLog(loggerPrefixLoggerWriter)}
|
||||
}
|
||||
|
||||
func (d *LoggerWriter) Write(entry *Entry) {
|
||||
func (d *LoggerWriter) Write(entry *LogEntry) {
|
||||
d.logger.WithFields(
|
||||
logrus.Fields{
|
||||
"client_ip": entry.Request.ClientIP,
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
var _ = Describe("LoggerWriter", func() {
|
||||
|
@ -34,7 +34,7 @@ var _ = Describe("LoggerWriter", func() {
|
|||
Reason: "Resolved",
|
||||
RType: model.ResponseTypeRESOLVED,
|
||||
}
|
||||
writer.Write(&Entry{
|
||||
writer.Write(&LogEntry{
|
||||
Request: request,
|
||||
Response: response,
|
||||
Start: time.Now(),
|
||||
|
|
|
@ -7,7 +7,7 @@ func NewNoneWriter() *NoneWriter {
|
|||
return &NoneWriter{}
|
||||
}
|
||||
|
||||
func (d *NoneWriter) Write(entry *Entry) {
|
||||
func (d *NoneWriter) Write(entry *LogEntry) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package querylog
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
)
|
||||
|
||||
var _ = Describe("NoneWriter", func() {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/0xERR0R/blocky/model"
|
||||
)
|
||||
|
||||
type Entry struct {
|
||||
type LogEntry struct {
|
||||
Request *model.Request
|
||||
Response *model.Response
|
||||
Start time.Time
|
||||
|
@ -14,6 +14,6 @@ type Entry struct {
|
|||
}
|
||||
|
||||
type Writer interface {
|
||||
Write(entry *Entry)
|
||||
Write(entry *LogEntry)
|
||||
CleanUp()
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,39 +9,40 @@ import (
|
|||
"github.com/creasty/defaults"
|
||||
"github.com/google/uuid"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var (
|
||||
redisServer *miniredis.Miniredis
|
||||
redisClient *Client
|
||||
redisConfig *config.RedisConfig
|
||||
err error
|
||||
)
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
redisServer, err = miniredis.Run()
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
|
||||
var rcfg config.RedisConfig
|
||||
err = defaults.Set(&rcfg)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
|
||||
rcfg.Address = redisServer.Addr()
|
||||
redisConfig = &rcfg
|
||||
redisClient, err = New(redisConfig)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
Expect(redisClient).ShouldNot(BeNil())
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
redisServer.Close()
|
||||
})
|
||||
|
||||
var _ = Describe("Redis client", func() {
|
||||
|
||||
var (
|
||||
redisServer *miniredis.Miniredis
|
||||
redisClient *Client
|
||||
redisConfig *config.RedisConfig
|
||||
err error
|
||||
)
|
||||
|
||||
BeforeSuite(func() {
|
||||
redisServer, err = miniredis.Run()
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
|
||||
var rcfg config.RedisConfig
|
||||
err = defaults.Set(&rcfg)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
|
||||
rcfg.Address = redisServer.Addr()
|
||||
redisConfig = &rcfg
|
||||
redisClient, err = New(redisConfig)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
Expect(redisClient).ShouldNot(BeNil())
|
||||
})
|
||||
AfterSuite(func() {
|
||||
redisServer.Close()
|
||||
})
|
||||
When("created", func() {
|
||||
It("with no address", func() {
|
||||
var rcfg config.RedisConfig
|
||||
|
|
|
@ -16,11 +16,29 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
var group1File, group2File, defaultGroupFile *os.File
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
group1File = TempFile("DOMAIN1.com")
|
||||
group2File = TempFile("blocked2.com")
|
||||
defaultGroupFile = TempFile(
|
||||
`blocked3.com
|
||||
123.145.123.145
|
||||
2001:db8:85a3:08d3::370:7344
|
||||
badcnamedomain.com`)
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
_ = group1File.Close()
|
||||
_ = group2File.Close()
|
||||
_ = defaultGroupFile.Close()
|
||||
})
|
||||
|
||||
var _ = Describe("BlockingResolver", func() {
|
||||
var (
|
||||
sut *BlockingResolver
|
||||
|
@ -31,27 +49,9 @@ var _ = Describe("BlockingResolver", func() {
|
|||
err error
|
||||
resp *Response
|
||||
|
||||
group1File, group2File, defaultGroupFile *os.File
|
||||
|
||||
expectedReturnCode int
|
||||
)
|
||||
|
||||
BeforeSuite(func() {
|
||||
group1File = TempFile("DOMAIN1.com")
|
||||
group2File = TempFile("blocked2.com")
|
||||
defaultGroupFile = TempFile(
|
||||
`blocked3.com
|
||||
123.145.123.145
|
||||
2001:db8:85a3:08d3::370:7344
|
||||
badcnamedomain.com`)
|
||||
})
|
||||
|
||||
AfterSuite(func() {
|
||||
_ = group1File.Close()
|
||||
_ = group2File.Close()
|
||||
_ = defaultGroupFile.Close()
|
||||
})
|
||||
|
||||
BeforeEach(func() {
|
||||
expectedReturnCode = dns.RcodeSuccess
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/creasty/defaults"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
@ -454,7 +454,7 @@ var _ = Describe("CachingResolver", func() {
|
|||
MaxCachingTime: config.Duration(time.Minute * -1),
|
||||
}
|
||||
})
|
||||
It("should return 'disabled''", func() {
|
||||
It("should return 'disabled'", func() {
|
||||
c := sut.Configuration()
|
||||
Expect(c).Should(HaveLen(1))
|
||||
Expect(c).Should(Equal([]string{"deactivated"}))
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/model"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/0xERR0R/blocky/util"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
@ -134,7 +134,7 @@ var _ = Describe("ConditionalUpstreamResolver", func() {
|
|||
BeforeEach(func() {
|
||||
sut = NewConditionalUpstreamResolver(config.ConditionalUpstreamConfig{})
|
||||
})
|
||||
It("should return 'disabled''", func() {
|
||||
It("should return 'disabled'", func() {
|
||||
c := sut.Configuration()
|
||||
Expect(c).Should(HaveLen(1))
|
||||
Expect(c).Should(Equal([]string{"deactivated"}))
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/helpertest"
|
||||
. "github.com/0xERR0R/blocky/model"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
@ -148,7 +148,7 @@ var _ = Describe("CustomDNSResolver", func() {
|
|||
BeforeEach(func() {
|
||||
sut = NewCustomDNSResolver(config.CustomDNSConfig{})
|
||||
})
|
||||
It("should return 'disabled''", func() {
|
||||
It("should return 'disabled'", func() {
|
||||
c := sut.Configuration()
|
||||
Expect(c).Should(HaveLen(1))
|
||||
Expect(c).Should(Equal([]string{"deactivated"}))
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/helpertest"
|
||||
. "github.com/0xERR0R/blocky/model"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/model"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/model"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/testutil"
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/model"
|
||||
"github.com/0xERR0R/blocky/util"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ type QueryLoggingResolver struct {
|
|||
NextResolver
|
||||
target string
|
||||
logRetentionDays uint64
|
||||
logChan chan *querylog.Entry
|
||||
logChan chan *querylog.LogEntry
|
||||
writer querylog.Writer
|
||||
logType config.QueryLogType
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func NewQueryLoggingResolver(cfg config.QueryLogConfig) ChainedResolver {
|
|||
logType = config.QueryLogTypeConsole
|
||||
}
|
||||
|
||||
logChan := make(chan *querylog.Entry, logChanCap)
|
||||
logChan := make(chan *querylog.LogEntry, logChanCap)
|
||||
|
||||
resolver := QueryLoggingResolver{
|
||||
target: cfg.Target,
|
||||
|
@ -110,7 +110,7 @@ func (r *QueryLoggingResolver) Resolve(request *model.Request) (*model.Response,
|
|||
|
||||
if err == nil {
|
||||
select {
|
||||
case r.logChan <- &querylog.Entry{
|
||||
case r.logChan <- &querylog.LogEntry{
|
||||
Request: request,
|
||||
Response: resp,
|
||||
Start: start,
|
||||
|
|
|
@ -18,16 +18,16 @@ import (
|
|||
"github.com/0xERR0R/blocky/util"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
type SlowMockWriter struct {
|
||||
entries []*querylog.Entry
|
||||
entries []*querylog.LogEntry
|
||||
}
|
||||
|
||||
func (m *SlowMockWriter) Write(entry *querylog.Entry) {
|
||||
func (m *SlowMockWriter) Write(entry *querylog.LogEntry) {
|
||||
m.entries = append(m.entries, entry)
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package resolver
|
|||
import (
|
||||
"github.com/0xERR0R/blocky/config"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
. "github.com/0xERR0R/blocky/model"
|
||||
"github.com/0xERR0R/blocky/util"
|
||||
"github.com/miekg/dns"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -19,116 +19,116 @@ import (
|
|||
"github.com/0xERR0R/blocky/util"
|
||||
"github.com/creasty/defaults"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
var _ = Describe("Running DNS server", func() {
|
||||
var (
|
||||
upstreamGoogle, upstreamFritzbox, upstreamClient config.Upstream
|
||||
mockClientName string
|
||||
sut *Server
|
||||
err error
|
||||
resp *dns.Msg
|
||||
)
|
||||
var (
|
||||
upstreamGoogle, upstreamFritzbox, upstreamClient config.Upstream
|
||||
mockClientName string
|
||||
sut *Server
|
||||
err error
|
||||
resp *dns.Msg
|
||||
)
|
||||
|
||||
BeforeSuite(func() {
|
||||
upstreamGoogle = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
if request.Question[0].Name == "error." {
|
||||
return nil
|
||||
}
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 123, dns.TypeA, "123.124.122.122")
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
upstreamFritzbox = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 3600, dns.TypeA, "192.168.178.2")
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
|
||||
upstreamClient = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 3600, dns.TypePTR, mockClientName)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
|
||||
// create server
|
||||
sut, err = NewServer(&config.Config{
|
||||
CustomDNS: config.CustomDNSConfig{
|
||||
CustomTTL: config.Duration(time.Duration(3600) * time.Second),
|
||||
Mapping: config.CustomDNSMapping{
|
||||
HostIPs: map[string][]net.IP{
|
||||
"custom.lan": {net.ParseIP("192.168.178.55")},
|
||||
"lan.home": {net.ParseIP("192.168.178.56")},
|
||||
},
|
||||
},
|
||||
},
|
||||
Conditional: config.ConditionalUpstreamConfig{
|
||||
Mapping: config.ConditionalUpstreamMapping{
|
||||
Upstreams: map[string][]config.Upstream{
|
||||
"net.cn": {upstreamClient},
|
||||
"fritz.box": {upstreamFritzbox},
|
||||
},
|
||||
},
|
||||
},
|
||||
Blocking: config.BlockingConfig{
|
||||
BlackLists: map[string][]string{
|
||||
"ads": {
|
||||
"../testdata/doubleclick.net.txt",
|
||||
"../testdata/www.bild.de.txt",
|
||||
"../testdata/heise.de.txt"},
|
||||
"youtube": {"../testdata/youtube.com.txt"}},
|
||||
WhiteLists: map[string][]string{
|
||||
"ads": {"../testdata/heise.de.txt"},
|
||||
"whitelist": {"../testdata/heise.de.txt"},
|
||||
},
|
||||
ClientGroupsBlock: map[string][]string{
|
||||
"default": {"ads"},
|
||||
"clWhitelistOnly": {"whitelist"},
|
||||
"clAdsAndYoutube": {"ads", "youtube"},
|
||||
"clYoutubeOnly": {"youtube"},
|
||||
},
|
||||
BlockType: "zeroIp",
|
||||
BlockTTL: config.Duration(6 * time.Hour),
|
||||
},
|
||||
Upstream: config.UpstreamConfig{
|
||||
ExternalResolvers: map[string][]config.Upstream{"default": {upstreamGoogle}},
|
||||
},
|
||||
ClientLookup: config.ClientLookupConfig{
|
||||
Upstream: upstreamClient,
|
||||
},
|
||||
|
||||
DNSPorts: config.ListenConfig{"55555"},
|
||||
TLSPorts: config.ListenConfig{"8853"},
|
||||
CertFile: "../testdata/cert.pem",
|
||||
KeyFile: "../testdata/key.pem",
|
||||
HTTPPorts: config.ListenConfig{"4000"},
|
||||
HTTPSPorts: config.ListenConfig{"4443"},
|
||||
Prometheus: config.PrometheusConfig{
|
||||
Enable: true,
|
||||
Path: "/metrics",
|
||||
},
|
||||
})
|
||||
var _ = BeforeSuite(func() {
|
||||
upstreamGoogle = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
if request.Question[0].Name == "error." {
|
||||
return nil
|
||||
}
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 123, dns.TypeA, "123.124.122.122")
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
upstreamFritzbox = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 3600, dns.TypeA, "192.168.178.2")
|
||||
|
||||
// start server
|
||||
go func() {
|
||||
sut.Start()
|
||||
}()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
|
||||
AfterSuite(func() {
|
||||
sut.Stop()
|
||||
upstreamClient = resolver.TestUDPUpstream(func(request *dns.Msg) *dns.Msg {
|
||||
response, err := util.NewMsgWithAnswer(util.ExtractDomain(request.Question[0]), 3600, dns.TypePTR, mockClientName)
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
return response
|
||||
})
|
||||
|
||||
// create server
|
||||
sut, err = NewServer(&config.Config{
|
||||
CustomDNS: config.CustomDNSConfig{
|
||||
CustomTTL: config.Duration(time.Duration(3600) * time.Second),
|
||||
Mapping: config.CustomDNSMapping{
|
||||
HostIPs: map[string][]net.IP{
|
||||
"custom.lan": {net.ParseIP("192.168.178.55")},
|
||||
"lan.home": {net.ParseIP("192.168.178.56")},
|
||||
},
|
||||
},
|
||||
},
|
||||
Conditional: config.ConditionalUpstreamConfig{
|
||||
Mapping: config.ConditionalUpstreamMapping{
|
||||
Upstreams: map[string][]config.Upstream{
|
||||
"net.cn": {upstreamClient},
|
||||
"fritz.box": {upstreamFritzbox},
|
||||
},
|
||||
},
|
||||
},
|
||||
Blocking: config.BlockingConfig{
|
||||
BlackLists: map[string][]string{
|
||||
"ads": {
|
||||
"../testdata/doubleclick.net.txt",
|
||||
"../testdata/www.bild.de.txt",
|
||||
"../testdata/heise.de.txt"},
|
||||
"youtube": {"../testdata/youtube.com.txt"}},
|
||||
WhiteLists: map[string][]string{
|
||||
"ads": {"../testdata/heise.de.txt"},
|
||||
"whitelist": {"../testdata/heise.de.txt"},
|
||||
},
|
||||
ClientGroupsBlock: map[string][]string{
|
||||
"default": {"ads"},
|
||||
"clWhitelistOnly": {"whitelist"},
|
||||
"clAdsAndYoutube": {"ads", "youtube"},
|
||||
"clYoutubeOnly": {"youtube"},
|
||||
},
|
||||
BlockType: "zeroIp",
|
||||
BlockTTL: config.Duration(6 * time.Hour),
|
||||
},
|
||||
Upstream: config.UpstreamConfig{
|
||||
ExternalResolvers: map[string][]config.Upstream{"default": {upstreamGoogle}},
|
||||
},
|
||||
ClientLookup: config.ClientLookupConfig{
|
||||
Upstream: upstreamClient,
|
||||
},
|
||||
|
||||
DNSPorts: config.ListenConfig{"55555"},
|
||||
TLSPorts: config.ListenConfig{"8853"},
|
||||
CertFile: "../testdata/cert.pem",
|
||||
KeyFile: "../testdata/key.pem",
|
||||
HTTPPorts: config.ListenConfig{"4000"},
|
||||
HTTPSPorts: config.ListenConfig{"4443"},
|
||||
Prometheus: config.PrometheusConfig{
|
||||
Enable: true,
|
||||
Path: "/metrics",
|
||||
},
|
||||
})
|
||||
|
||||
Expect(err).Should(Succeed())
|
||||
|
||||
// start server
|
||||
go func() {
|
||||
sut.Start()
|
||||
}()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
sut.Stop()
|
||||
})
|
||||
|
||||
var _ = Describe("Running DNS server", func() {
|
||||
Describe("performing DNS request with running server", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
|
|
|
@ -3,7 +3,7 @@ package util
|
|||
import (
|
||||
"github.com/0xERR0R/blocky/config"
|
||||
"github.com/0xERR0R/blocky/helpertest"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/sirupsen/logrus/hooks/test"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/0xERR0R/blocky/log"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue