@@ -32,11 +32,11 @@ import (
32
32
"sync"
33
33
"time"
34
34
35
- tk "github.com/loxilb-io/loxilib"
36
- probing "github.com/prometheus-community/pro-bing"
37
-
38
35
"github.com/loxilb-io/loxilb/api/loxinlp"
39
36
cmn "github.com/loxilb-io/loxilb/common"
37
+ utils "github.com/loxilb-io/loxilb/pkg/utils"
38
+ tk "github.com/loxilb-io/loxilib"
39
+ probing "github.com/prometheus-community/pro-bing"
40
40
)
41
41
42
42
// error codes
@@ -360,7 +360,7 @@ func RulesInit(zone *Zone) *RuleH {
360
360
rootCACertile := cmn .CertPath + cmn .CACertFileName
361
361
362
362
// Check if there exist a common CA certificate
363
- if exists := FileExists (rootCACertile ); exists {
363
+ if exists := utils . FileExists (rootCACertile ); exists {
364
364
365
365
rootCA , err := os .ReadFile (rootCACertile )
366
366
if err != nil {
@@ -374,8 +374,8 @@ func RulesInit(zone *Zone) *RuleH {
374
374
certFile := cmn .CertPath + cmn .PrivateCertName
375
375
keyFile := cmn .CertPath + cmn .PrivateKeyName
376
376
377
- certExists := FileExists (certFile )
378
- keyExists := FileExists (keyFile )
377
+ certExists := utils . FileExists (certFile )
378
+ keyExists := utils . FileExists (keyFile )
379
379
380
380
if certExists == true && keyExists == true {
381
381
cert , err := tls .LoadX509KeyPair (certFile , keyFile )
@@ -993,7 +993,7 @@ func (R *RuleH) electEPSrc(r *ruleEnt) bool {
993
993
sip = r .tuples .l3Dst .addr .IP .Mask (r .tuples .l3Dst .addr .Mask )
994
994
if np .xIP .Equal (sip ) {
995
995
sip = net .IPv4 (0 , 0 , 0 , 0 )
996
- } else if IsIPHostAddr (np .xIP .String ()) {
996
+ } else if utils . IsIPHostAddr (np .xIP .String ()) {
997
997
sip = net .IPv4 (0 , 0 , 0 , 0 )
998
998
}
999
999
} else {
@@ -1528,7 +1528,7 @@ func (R *RuleH) DeleteNatLbRule(serv cmn.LbServiceArg) (int, error) {
1528
1528
R .vipMap [sNetAddr .IP .String ()]--
1529
1529
1530
1530
if R .vipMap [sNetAddr .IP .String ()] == 0 {
1531
- if IsIPHostAddr (sNetAddr .IP .String ()) {
1531
+ if utils . IsIPHostAddr (sNetAddr .IP .String ()) {
1532
1532
loxinlp .DelAddrNoHook (sNetAddr .IP .String ()+ "/32" , "lo" )
1533
1533
}
1534
1534
dev := fmt .Sprintf ("llb-rule-%s" , sNetAddr .IP .String ())
@@ -1866,7 +1866,7 @@ func (R *RuleH) AddEPHost(apiCall bool, hostName string, name string, args epHos
1866
1866
if args .probeType == HostProbeHTTPS {
1867
1867
// Check if there exist a CA certificate particularly for this EP
1868
1868
rootCACertile := cmn .CertPath + hostName + "/" + cmn .CACertFileName
1869
- if exists := FileExists (rootCACertile ); exists {
1869
+ if exists := utils . FileExists (rootCACertile ); exists {
1870
1870
rootCA , err := os .ReadFile (rootCACertile )
1871
1871
if err != nil {
1872
1872
tk .LogIt (tk .LogError , "RootCA cert load failed : %v" , err )
@@ -2084,7 +2084,7 @@ func (R *RuleH) epCheckNow(ep *epHost) {
2084
2084
}
2085
2085
2086
2086
urlStr := fmt .Sprintf ("https://%s:%d/%s" , addr .String (), ep .opts .probePort , ep .opts .probeReq )
2087
- sOk := HTTPSProber (urlStr , R .tlsCert , R .rootCAPool , ep .opts .probeResp )
2087
+ sOk := utils . HTTPSProber (urlStr , R .tlsCert , R .rootCAPool , ep .opts .probeResp )
2088
2088
//tk.LogIt(tk.LogDebug, "[PROBE] https ep - URL[%s:%s] Resp[%s] %v\n", ep.hostName, urlStr, ep.opts.probeResp, sOk)
2089
2089
ep .transitionEPState (sOk , inActTryThr )
2090
2090
} else {
@@ -2624,7 +2624,7 @@ func (R *RuleH) AdvRuleVIPIfL2(IP net.IP) error {
2624
2624
}
2625
2625
ev , _ , iface := R .zone .L3 .IfaSelectAny (IP , false )
2626
2626
if ev == 0 {
2627
- if ! IsIPHostAddr (IP .String ()) {
2627
+ if ! utils . IsIPHostAddr (IP .String ()) {
2628
2628
if loxinlp .AddAddrNoHook (IP .String ()+ "/32" , "lo" ) != 0 {
2629
2629
tk .LogIt (tk .LogError , "nat lb-rule vip %s:%s add failed\n " , IP .String (), "lo" )
2630
2630
} else {
@@ -2635,7 +2635,7 @@ func (R *RuleH) AdvRuleVIPIfL2(IP net.IP) error {
2635
2635
ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
2636
2636
defer cancel ()
2637
2637
rCh := make (chan int )
2638
- go GratArpReqWithCtx (ctx , rCh , IP , iface )
2638
+ go utils . GratArpReqWithCtx (ctx , rCh , IP , iface )
2639
2639
select {
2640
2640
case <- rCh :
2641
2641
break
@@ -2645,7 +2645,7 @@ func (R *RuleH) AdvRuleVIPIfL2(IP net.IP) error {
2645
2645
}
2646
2646
2647
2647
} else if ciState != "NOT_DEFINED" {
2648
- if IsIPHostAddr (IP .String ()) {
2648
+ if utils . IsIPHostAddr (IP .String ()) {
2649
2649
if loxinlp .DelAddrNoHook (IP .String ()+ "/32" , "lo" ) != 0 {
2650
2650
tk .LogIt (tk .LogError , "nat lb-rule vip %s:%s delete failed\n " , IP .String (), "lo" )
2651
2651
} else {
0 commit comments