优化代码

This commit is contained in:
GoEdgeLab
2023-08-08 11:36:54 +08:00
parent 069635ddbf
commit 1ab328bb02
4 changed files with 7 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ func TestHTTPClientPool_Client(t *testing.T) {
Version: 2,
Addr: &serverconfigs.NetworkAddressConfig{Host: "127.0.0.1", PortRange: "1234"},
}
err := origin.Init(nil)
err := origin.Init(context.Background())
if err != nil {
t.Fatal(err)
}

View File

@@ -3,6 +3,7 @@
package nodes
import (
"context"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/types"
@@ -23,7 +24,7 @@ func TestBaseListener_FindServer(t *testing.T) {
{Name: types.String(i) + ".hello.com"},
},
}
_ = server.Init(nil)
_ = server.Init(context.Background())
listener.Group.Add(server)
}

View File

@@ -61,6 +61,8 @@ func BenchmarkBytePool_Get_Sync(b *testing.B) {
return make([]byte, 1024)
},
}
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {

View File

@@ -553,11 +553,11 @@ func (this *Rule) Test(value interface{}) bool {
return stringutil.VersionCompare(types.String(value), this.Value) >= 0
}
case RuleOperatorEqIP:
ip := net.ParseIP(types.String(value))
var ip = net.ParseIP(types.String(value))
if ip == nil {
return false
}
return this.isIP && bytes.Equal(this.ipValue, ip)
return this.isIP && ip.Equal(this.ipValue)
case RuleOperatorGtIP:
ip := net.ParseIP(types.String(value))
if ip == nil {