86ffd6a0c4
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.
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package mocks
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"time"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
)
|
|
|
|
// UnderlyingNetwork allows mocking model.UnderlyingNetwork.
|
|
type UnderlyingNetwork struct {
|
|
MockDialContext func(ctx context.Context, timeout time.Duration, network, address string) (net.Conn, error)
|
|
|
|
MockListenUDP func(network string, addr *net.UDPAddr) (model.UDPLikeConn, error)
|
|
|
|
MockGetaddrinfoLookupANY func(ctx context.Context, domain string) ([]string, string, error)
|
|
|
|
MockGetaddrinfoResolverNetwork func() string
|
|
}
|
|
|
|
var _ model.UnderlyingNetwork = &UnderlyingNetwork{}
|
|
|
|
func (un *UnderlyingNetwork) DialContext(ctx context.Context, timeout time.Duration, network, address string) (net.Conn, error) {
|
|
return un.MockDialContext(ctx, timeout, network, address)
|
|
}
|
|
|
|
func (un *UnderlyingNetwork) ListenUDP(network string, addr *net.UDPAddr) (model.UDPLikeConn, error) {
|
|
return un.MockListenUDP(network, addr)
|
|
}
|
|
|
|
func (un *UnderlyingNetwork) GetaddrinfoLookupANY(ctx context.Context, domain string) ([]string, string, error) {
|
|
return un.MockGetaddrinfoLookupANY(ctx, domain)
|
|
}
|
|
|
|
func (un *UnderlyingNetwork) GetaddrinfoResolverNetwork() string {
|
|
return un.MockGetaddrinfoResolverNetwork()
|
|
}
|