feat: port-filtering experiment (#891)
Part of https://github.com/ooni/probe/issues/2005
This commit is contained in:
parent
cb632ea0f3
commit
d6a362d96f
15 changed files with 452 additions and 0 deletions
31
internal/cmd/ooporthelper/main_test.go
Normal file
31
internal/cmd/ooporthelper/main_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestMainWorkingAsIntended(t *testing.T) {
|
||||
srvTest = true // toggle to imply that we are running in test mode
|
||||
go main()
|
||||
dialer := netxlite.NewDialerWithoutResolver(model.DiscardLogger)
|
||||
for _, port := range TestPorts {
|
||||
<-srvTestChan
|
||||
addr := net.JoinHostPort("127.0.0.1", port)
|
||||
ctx := context.Background()
|
||||
conn, err := dialer.DialContext(ctx, "tcp", addr)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if conn == nil {
|
||||
t.Fatal("expected non-nil conn")
|
||||
}
|
||||
conn.Close()
|
||||
}
|
||||
srvCancel() // shutdown server
|
||||
srvWg.Wait() // wait for listeners on all ports to close
|
||||
}
|
||||
Loading…
Reference in a new issue