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
64c4e2cb
Commit
64c4e2cb
authored
Feb 05, 2025
by
qiuqunfeng
Browse files
fix
parent
2e951857
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
api/router.go
api/router.go
+11
-12
cmd/app/cmd.go
cmd/app/cmd.go
+14
-3
No files found.
api/router.go
View file @
64c4e2cb
...
...
@@ -10,10 +10,9 @@ import (
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/generated/clientset/versioned"
"gorm.io/gorm"
"k8s.io/client-go/rest"
)
func
SetRouters
(
db
*
gorm
.
DB
)
*
gin
.
Engine
{
func
SetRouters
(
db
*
gorm
.
DB
,
client
*
versioned
.
Clientset
)
*
gin
.
Engine
{
var
engine
*
gin
.
Engine
if
!
config
.
Conf
.
Debug
{
...
...
@@ -53,16 +52,16 @@ func SetRouters(db *gorm.DB) *gin.Engine {
// SetIPInforRouter(engine)
// loadkubeConfig()
// clientcmd.LoadFromFile("kubeconfig.yaml")
client
:=
versioned
.
NewForConfigOrDie
(
&
rest
.
Config
{
Host
:
"https://127.0.0.1:6443"
,
TLSClientConfig
:
rest
.
TLSClientConfig
{
Insecure
:
false
,
CAData
:
[]
byte
(
""
),
CertData
:
[]
byte
(
""
),
KeyData
:
[]
byte
(
""
),
},
// BearerToken: "1234567890",
})
//
client := versioned.NewForConfigOrDie(&rest.Config{
//
Host: "https://127.0.0.1:6443",
//
TLSClientConfig: rest.TLSClientConfig{
//
Insecure: false,
//
CAData: []byte(""),
//
CertData: []byte(""),
//
KeyData: []byte(""),
//
},
//
// BearerToken: "1234567890",
//
})
SetWafRouter
(
engine
,
client
,
db
)
// 统一处理 404
...
...
cmd/app/cmd.go
View file @
64c4e2cb
...
...
@@ -7,10 +7,10 @@ import (
"github.com/spf13/cobra"
"gitlab.com/security-rd/go-pkg/logging"
"gitlab.com/tensorsecurity-rd/waf-console/api"
// "gitlab.com/tensorsecurity-rd/waf-console/internal/config"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/generated/clientset/versioned"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"k8s.io/client-go/rest"
)
func
NewRootCommand
()
*
cobra
.
Command
{
...
...
@@ -39,7 +39,18 @@ func NewRootCommand() *cobra.Command {
panic
(
"dbConfig is nil"
)
}
e
:=
api
.
SetRouters
(
db
)
client
:=
versioned
.
NewForConfigOrDie
(
&
rest
.
Config
{
Host
:
config
.
RegionConfigs
[
0
]
.
ApiServer
,
TLSClientConfig
:
rest
.
TLSClientConfig
{
Insecure
:
false
,
CAData
:
[]
byte
(
config
.
RegionConfigs
[
0
]
.
CAData
),
CertData
:
[]
byte
(
config
.
RegionConfigs
[
0
]
.
ClientCertData
),
KeyData
:
[]
byte
(
config
.
RegionConfigs
[
0
]
.
ClientKeyData
),
},
// BearerToken: "1234567890",
})
e
:=
api
.
SetRouters
(
db
,
client
)
return
e
.
Run
(
":8080"
)
},
}
...
...
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