mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 12:00:26 +08:00
优化代码
This commit is contained in:
@@ -17,7 +17,7 @@ func TestHTTPClientPool_Client(t *testing.T) {
|
|||||||
Version: 2,
|
Version: 2,
|
||||||
Addr: &serverconfigs.NetworkAddressConfig{Host: "127.0.0.1", PortRange: "1234"},
|
Addr: &serverconfigs.NetworkAddressConfig{Host: "127.0.0.1", PortRange: "1234"},
|
||||||
}
|
}
|
||||||
err := origin.Init(nil)
|
err := origin.Init(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package nodes
|
package nodes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
@@ -23,7 +24,7 @@ func TestBaseListener_FindServer(t *testing.T) {
|
|||||||
{Name: types.String(i) + ".hello.com"},
|
{Name: types.String(i) + ".hello.com"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_ = server.Init(nil)
|
_ = server.Init(context.Background())
|
||||||
listener.Group.Add(server)
|
listener.Group.Add(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ func BenchmarkBytePool_Get_Sync(b *testing.B) {
|
|||||||
return make([]byte, 1024)
|
return make([]byte, 1024)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
b.RunParallel(func(pb *testing.PB) {
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
|||||||
@@ -553,11 +553,11 @@ func (this *Rule) Test(value interface{}) bool {
|
|||||||
return stringutil.VersionCompare(types.String(value), this.Value) >= 0
|
return stringutil.VersionCompare(types.String(value), this.Value) >= 0
|
||||||
}
|
}
|
||||||
case RuleOperatorEqIP:
|
case RuleOperatorEqIP:
|
||||||
ip := net.ParseIP(types.String(value))
|
var ip = net.ParseIP(types.String(value))
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return this.isIP && bytes.Equal(this.ipValue, ip)
|
return this.isIP && ip.Equal(this.ipValue)
|
||||||
case RuleOperatorGtIP:
|
case RuleOperatorGtIP:
|
||||||
ip := net.ParseIP(types.String(value))
|
ip := net.ParseIP(types.String(value))
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user