Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
qiuqunfeng
waf-console
Commits
64b675ef
Commit
64b675ef
authored
Feb 17, 2025
by
qiuqunfeng
Browse files
commit
parent
3ce3ff4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
internal/service/waf.go
internal/service/waf.go
+18
-2
No files found.
internal/service/waf.go
View file @
64b675ef
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"github.com/rs/zerolog/log"
"gitlab.com/tensorsecurity-rd/waf-console/internal/model"
"gitlab.com/tensorsecurity-rd/waf-console/internal/model"
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/apis/waf.security.io/v1alpha1"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/apis/waf.security.io/v1alpha1"
...
@@ -405,11 +406,25 @@ func (s *wafService) EnableListenerWaf(ctx context.Context, req *EnableListenerW
...
@@ -405,11 +406,25 @@ func (s *wafService) EnableListenerWaf(ctx context.Context, req *EnableListenerW
wafService
:=
&
model
.
WafService
{}
wafService
:=
&
model
.
WafService
{}
err
=
s
.
db
.
Model
(
&
model
.
WafService
{})
.
Where
(
"gateway_name = ? AND namespace = ? AND region_code = ?"
,
req
.
GatewayName
,
req
.
Namespace
,
req
.
RegionCode
)
.
First
(
wafService
)
.
Error
err
=
s
.
db
.
Model
(
&
model
.
WafService
{})
.
Where
(
"gateway_name = ? AND namespace = ? AND region_code = ?"
,
req
.
GatewayName
,
req
.
Namespace
,
req
.
RegionCode
)
.
First
(
wafService
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
if
err
!=
nil
{
return
err
if
err
==
gorm
.
ErrRecordNotFound
{
wafService
=
&
model
.
WafService
{
GatewayName
:
req
.
GatewayName
,
Namespace
:
req
.
Namespace
,
RegionCode
:
req
.
RegionCode
,
Mode
:
string
(
WafModeAlert
),
Host
:
model
.
HostList
([]
string
{
"*"
}),
}
if
err
:=
s
.
db
.
Create
(
wafService
)
.
Error
;
err
!=
nil
{
return
err
}
}
else
{
return
err
}
}
}
if
listener
.
Enable
{
if
listener
.
Enable
{
log
.
Info
()
.
Msgf
(
"Create WAF for listener %s"
,
listener
.
GatewayName
)
_
,
err
:=
s
.
CreateWaf
(
ctx
,
&
CreateWafReq
{
_
,
err
:=
s
.
CreateWaf
(
ctx
,
&
CreateWafReq
{
GatewateInfo
:
GatewateInfo
{
GatewateInfo
:
GatewateInfo
{
GatewayName
:
req
.
GatewayName
,
GatewayName
:
req
.
GatewayName
,
...
@@ -423,6 +438,7 @@ func (s *wafService) EnableListenerWaf(ctx context.Context, req *EnableListenerW
...
@@ -423,6 +438,7 @@ func (s *wafService) EnableListenerWaf(ctx context.Context, req *EnableListenerW
return
err
return
err
}
}
}
else
{
}
else
{
log
.
Info
()
.
Msgf
(
"Delete WAF for listener %s"
,
listener
.
GatewayName
)
err
=
s
.
DeleteListenerWaf
(
ctx
,
&
DeleteListenerReq
{
err
=
s
.
DeleteListenerWaf
(
ctx
,
&
DeleteListenerReq
{
GatewateInfo
:
GatewateInfo
{
GatewateInfo
:
GatewateInfo
{
GatewayName
:
req
.
GatewayName
,
GatewayName
:
req
.
GatewayName
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment