cleanup: remove UnderlyingNetworkLibrary and TProxy (#874)
* cleanup: remove UnderlyingNetworkLibrary and TProxy While there, replace mixture of mocking and real connections inside quicping with pure mocking of network connections. Closes https://github.com/ooni/probe/issues/2224 * cleanup: we don't need a SimpleResolver now This type was only used by UnderlyingNetworkLibrary and all the rest of the code uses Resolver. So, let's avoid complexity by zapping the SimpleResolver type and merging it inside Resolver.
This commit is contained in:
parent
2301a30630
commit
da1c13e312
8 changed files with 75 additions and 164 deletions
|
|
@ -18,7 +18,6 @@ import (
|
|||
_ "crypto/sha256"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/tracex"
|
||||
)
|
||||
|
||||
|
|
@ -44,8 +43,8 @@ type Config struct {
|
|||
// Port is the port to test.
|
||||
Port int64 `ooni:"port is the port to test"`
|
||||
|
||||
// networkLibrary is the underlying network library. Can be used for testing.
|
||||
networkLib model.UnderlyingNetworkLibrary
|
||||
// netListenUDP allows mocking the real net.ListenUDP call
|
||||
netListenUDP func(network string, laddr *net.UDPAddr) (model.UDPLikeConn, error)
|
||||
}
|
||||
|
||||
func (c *Config) repetitions() int64 {
|
||||
|
|
@ -62,11 +61,11 @@ func (c *Config) port() string {
|
|||
return "443"
|
||||
}
|
||||
|
||||
func (c *Config) networkLibrary() model.UnderlyingNetworkLibrary {
|
||||
if c.networkLib != nil {
|
||||
return c.networkLib
|
||||
func (c *Config) doListenUDP(network string, laddr *net.UDPAddr) (model.UDPLikeConn, error) {
|
||||
if c.netListenUDP != nil {
|
||||
return c.netListenUDP(network, laddr)
|
||||
}
|
||||
return &netxlite.TProxyStdlib{}
|
||||
return net.ListenUDP(network, laddr)
|
||||
}
|
||||
|
||||
// TestKeys contains the experiment results.
|
||||
|
|
@ -246,7 +245,7 @@ func (m *Measurer) Run(
|
|||
measurement.TestKeys = tk
|
||||
|
||||
// create UDP socket
|
||||
pconn, err := m.config.networkLibrary().ListenUDP("udp", &net.UDPAddr{})
|
||||
pconn, err := m.config.doListenUDP("udp", &net.UDPAddr{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue