cleanup(netx): remove redundant config options (#791)

Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso
2022-06-02 18:18:49 +02:00
committed by GitHub
parent e9ed733f07
commit 76b65893a1
8 changed files with 54 additions and 162 deletions
+1 -1
View File
@@ -263,7 +263,7 @@ func (m Measurer) Run(
// See https://github.com/ooni/probe/issues/2112
Dialer: netxlite.NewMaybeShapingDialer(netx.NewDialer(netx.Config{
ContextByteCounting: true,
DialSaver: saver,
Saver: saver,
Logger: sess.Logger(),
})),
Logger: sess.Logger(),
@@ -171,7 +171,7 @@ func (m *Measurer) Run(
resolver := netx.NewResolver(netx.Config{
BogonIsError: true,
Logger: sess.Logger(),
ResolveSaver: evsaver,
Saver: evsaver,
})
addrs, err := m.lookupHost(ctx, URL.Hostname(), resolver)
queries := tracex.NewDNSQueriesList(begin, evsaver.Read())
@@ -116,10 +116,9 @@ func (tk *TestKeys) run(
begin := time.Now()
err := tk.do(ctx, config, netx.NewDialer(netx.Config{
ContextByteCounting: true,
DialSaver: saver,
Logger: sess.Logger(),
ReadWriteSaver: saver,
ResolveSaver: saver,
Saver: saver,
}), endpoint)
events := saver.Read()
tk.NetworkEvents = append(
@@ -41,15 +41,11 @@ func (c Configurer) NewConfiguration() (Configuration, error) {
HTTPConfig: netx.Config{
BogonIsError: c.Config.RejectDNSBogons,
CacheResolutions: true,
CertPool: c.Config.CertPool,
ContextByteCounting: true,
DialSaver: c.Saver,
HTTP3Enabled: c.Config.HTTP3Enabled,
HTTPSaver: c.Saver,
Logger: c.Logger,
ReadWriteSaver: c.Saver,
ResolveSaver: c.Saver,
TLSSaver: c.Saver,
Saver: c.Saver,
},
}
// fill DNS cache
@@ -96,7 +92,8 @@ func (c Configurer) NewConfiguration() (Configuration, error) {
if err != nil {
return configuration, err
}
configuration.HTTPConfig.NoTLSVerify = c.Config.NoTLSVerify
configuration.HTTPConfig.TLSConfig.InsecureSkipVerify = c.Config.NoTLSVerify
configuration.HTTPConfig.TLSConfig.RootCAs = c.Config.CertPool
// configure proxy
configuration.HTTPConfig.ProxyURL = c.ProxyURL
return configuration, nil
@@ -33,23 +33,14 @@ func TestConfigurerNewConfigurationVanilla(t *testing.T) {
if configuration.HTTPConfig.ContextByteCounting != true {
t.Fatal("not the ContextByteCounting we expected")
}
if configuration.HTTPConfig.DialSaver != saver {
t.Fatal("not the DialSaver we expected")
}
if configuration.HTTPConfig.HTTPSaver != saver {
t.Fatal("not the HTTPSaver we expected")
}
if configuration.HTTPConfig.Logger != log.Log {
t.Fatal("not the Logger we expected")
}
if configuration.HTTPConfig.ReadWriteSaver != saver {
t.Fatal("not the ReadWriteSaver we expected")
}
if configuration.HTTPConfig.ResolveSaver != saver {
t.Fatal("not the ResolveSaver we expected")
}
if configuration.HTTPConfig.TLSSaver != saver {
t.Fatal("not the TLSSaver we expected")
if configuration.HTTPConfig.Saver != saver {
t.Fatal("not the Saver we expected")
}
if configuration.HTTPConfig.BaseResolver == nil {
t.Fatal("not the BaseResolver we expected")
@@ -63,7 +54,7 @@ func TestConfigurerNewConfigurationVanilla(t *testing.T) {
if configuration.HTTPConfig.TLSConfig.NextProtos[1] != "http/1.1" {
t.Fatal("not the TLSConfig we expected")
}
if configuration.HTTPConfig.NoTLSVerify == true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify == true {
t.Fatal("not the NoTLSVerify we expected")
}
if configuration.HTTPConfig.ProxyURL != nil {
@@ -94,23 +85,14 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSPowerdns(t *testing.T) {
if configuration.HTTPConfig.ContextByteCounting != true {
t.Fatal("not the ContextByteCounting we expected")
}
if configuration.HTTPConfig.DialSaver != saver {
t.Fatal("not the DialSaver we expected")
}
if configuration.HTTPConfig.HTTPSaver != saver {
t.Fatal("not the HTTPSaver we expected")
}
if configuration.HTTPConfig.Logger != log.Log {
t.Fatal("not the Logger we expected")
}
if configuration.HTTPConfig.ReadWriteSaver != saver {
t.Fatal("not the ReadWriteSaver we expected")
}
if configuration.HTTPConfig.ResolveSaver != saver {
t.Fatal("not the ResolveSaver we expected")
}
if configuration.HTTPConfig.TLSSaver != saver {
t.Fatal("not the TLSSaver we expected")
if configuration.HTTPConfig.Saver != saver {
t.Fatal("not the Saver we expected")
}
if configuration.HTTPConfig.BaseResolver == nil {
t.Fatal("not the BaseResolver we expected")
@@ -139,7 +121,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSPowerdns(t *testing.T) {
if configuration.HTTPConfig.TLSConfig.NextProtos[1] != "http/1.1" {
t.Fatal("not the TLSConfig we expected")
}
if configuration.HTTPConfig.NoTLSVerify == true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify == true {
t.Fatal("not the NoTLSVerify we expected")
}
if configuration.HTTPConfig.ProxyURL != nil {
@@ -170,23 +152,14 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSGoogle(t *testing.T) {
if configuration.HTTPConfig.ContextByteCounting != true {
t.Fatal("not the ContextByteCounting we expected")
}
if configuration.HTTPConfig.DialSaver != saver {
t.Fatal("not the DialSaver we expected")
}
if configuration.HTTPConfig.HTTPSaver != saver {
t.Fatal("not the HTTPSaver we expected")
}
if configuration.HTTPConfig.Logger != log.Log {
t.Fatal("not the Logger we expected")
}
if configuration.HTTPConfig.ReadWriteSaver != saver {
t.Fatal("not the ReadWriteSaver we expected")
}
if configuration.HTTPConfig.ResolveSaver != saver {
t.Fatal("not the ResolveSaver we expected")
}
if configuration.HTTPConfig.TLSSaver != saver {
t.Fatal("not the TLSSaver we expected")
if configuration.HTTPConfig.Saver != saver {
t.Fatal("not the Saver we expected")
}
if configuration.HTTPConfig.BaseResolver == nil {
t.Fatal("not the BaseResolver we expected")
@@ -215,7 +188,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSGoogle(t *testing.T) {
if configuration.HTTPConfig.TLSConfig.NextProtos[1] != "http/1.1" {
t.Fatal("not the TLSConfig we expected")
}
if configuration.HTTPConfig.NoTLSVerify == true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify == true {
t.Fatal("not the NoTLSVerify we expected")
}
if configuration.HTTPConfig.ProxyURL != nil {
@@ -246,23 +219,14 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSCloudflare(t *testing.T)
if configuration.HTTPConfig.ContextByteCounting != true {
t.Fatal("not the ContextByteCounting we expected")
}
if configuration.HTTPConfig.DialSaver != saver {
t.Fatal("not the DialSaver we expected")
}
if configuration.HTTPConfig.HTTPSaver != saver {
t.Fatal("not the HTTPSaver we expected")
}
if configuration.HTTPConfig.Logger != log.Log {
t.Fatal("not the Logger we expected")
}
if configuration.HTTPConfig.ReadWriteSaver != saver {
t.Fatal("not the ReadWriteSaver we expected")
}
if configuration.HTTPConfig.ResolveSaver != saver {
t.Fatal("not the ResolveSaver we expected")
}
if configuration.HTTPConfig.TLSSaver != saver {
t.Fatal("not the TLSSaver we expected")
if configuration.HTTPConfig.Saver != saver {
t.Fatal("not the Saver we expected")
}
if configuration.HTTPConfig.BaseResolver == nil {
t.Fatal("not the BaseResolver we expected")
@@ -291,7 +255,7 @@ func TestConfigurerNewConfigurationResolverDNSOverHTTPSCloudflare(t *testing.T)
if configuration.HTTPConfig.TLSConfig.NextProtos[1] != "http/1.1" {
t.Fatal("not the TLSConfig we expected")
}
if configuration.HTTPConfig.NoTLSVerify == true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify == true {
t.Fatal("not the NoTLSVerify we expected")
}
if configuration.HTTPConfig.ProxyURL != nil {
@@ -322,23 +286,14 @@ func TestConfigurerNewConfigurationResolverUDP(t *testing.T) {
if configuration.HTTPConfig.ContextByteCounting != true {
t.Fatal("not the ContextByteCounting we expected")
}
if configuration.HTTPConfig.DialSaver != saver {
t.Fatal("not the DialSaver we expected")
}
if configuration.HTTPConfig.HTTPSaver != saver {
t.Fatal("not the HTTPSaver we expected")
}
if configuration.HTTPConfig.Logger != log.Log {
t.Fatal("not the Logger we expected")
}
if configuration.HTTPConfig.ReadWriteSaver != saver {
t.Fatal("not the ReadWriteSaver we expected")
}
if configuration.HTTPConfig.ResolveSaver != saver {
t.Fatal("not the ResolveSaver we expected")
}
if configuration.HTTPConfig.TLSSaver != saver {
t.Fatal("not the TLSSaver we expected")
if configuration.HTTPConfig.Saver != saver {
t.Fatal("not the Saver we expected")
}
if configuration.HTTPConfig.BaseResolver == nil {
t.Fatal("not the BaseResolver we expected")
@@ -367,7 +322,7 @@ func TestConfigurerNewConfigurationResolverUDP(t *testing.T) {
if configuration.HTTPConfig.TLSConfig.NextProtos[1] != "http/1.1" {
t.Fatal("not the TLSConfig we expected")
}
if configuration.HTTPConfig.NoTLSVerify == true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify == true {
t.Fatal("not the NoTLSVerify we expected")
}
if configuration.HTTPConfig.ProxyURL != nil {
@@ -517,7 +472,7 @@ func TestConfigurerNewConfigurationNoTLSVerify(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if configuration.HTTPConfig.NoTLSVerify != true {
if configuration.HTTPConfig.TLSConfig.InsecureSkipVerify != true {
t.Fatal("not the NoTLSVerify we expected")
}
}