ooni-probe-cli/internal/netxlite/tproxy_test.go
Simone Basso 86ffd6a0c4
feat: reintroduce the tproxy functionality (#975)
We originally removed the TProxy in https://github.com/ooni/probe/issues/2224. Nevertheless, in https://github.com/ooni/probe-cli/pull/969, we determined that something like the previous TProxy, with small changes, was required to support https://github.com/ooni/probe/issues/2340. So, this pull request reintroduces a slightly-modified TProxy functionality that better adapts to the `--remote=REMOTE` use case.
2022-10-12 17:38:33 +02:00

23 lines
456 B
Go

package netxlite
import (
"context"
"strings"
"testing"
"time"
)
func TestDefaultTProxy(t *testing.T) {
t.Run("DialContext honours the timeout", func(t *testing.T) {
tp := &DefaultTProxy{}
ctx := context.Background()
conn, err := tp.DialContext(ctx, 100*time.Microsecond, "tcp", "1.1.1.1:443")
if err == nil || !strings.HasSuffix(err.Error(), "i/o timeout") {
t.Fatal(err)
}
if conn != nil {
t.Fatal("expected nil conn")
}
})
}