Commit e5885d9b authored by qiuqunfeng's avatar qiuqunfeng
Browse files

commit

parent c963038c
...@@ -29,14 +29,27 @@ LICENSE_SECRET?=sit ...@@ -29,14 +29,27 @@ LICENSE_SECRET?=sit
## 指定bin目录 ## 指定bin目录
BIN_DIR = $(shell pwd)/bin/ BIN_DIR = $(shell pwd)/bin/
GOBIN ?= go
.PHONY: help .PHONY: help
help: help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
download:
$(GOBIN) mod tidy
.PHONY: build
build: download
@echo "build waf-console"
$(GOBIN) build -v \
-tags=jsoniter -o dist/waf-console gitlab.com/tensorsecurity-rd/waf-console/cmd
#upx --lzma --best dist/waf-console
.PHONY: waf-console .PHONY: waf-console
waf-console: waf-console:
@echo "build waf-console" @echo "build waf-console"
go build -v \ $(GOBIN) build -v \
-tags=jsoniter -o dist/waf-console gitlab.com/tensorsecurity-rd/waf-console/cmd -tags=jsoniter -o dist/waf-console gitlab.com/tensorsecurity-rd/waf-console/cmd
#upx --lzma --best dist/waf-console #upx --lzma --best dist/waf-console
docker build -t $(REPOPREFIX)/waf-console:$(IMAGETAG) -f ./build/Dockerfile . docker build -t $(REPOPREFIX)/waf-console:$(IMAGETAG) -f ./build/Dockerfile .
...@@ -42,7 +42,7 @@ require ( ...@@ -42,7 +42,7 @@ require (
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.27.2 // indirect k8s.io/api v0.27.2 // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/klog/v2 v2.90.1 // indirect k8s.io/klog/v2 v2.90.1 // indirect
......
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
"net/http" "net/http"
"os" "os"
"slices" "slices"
"strconv"
"strings"
"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"
...@@ -461,3 +463,42 @@ func (s *wafService) UpdateRule(ctx context.Context, req *RuleRequest) error { ...@@ -461,3 +463,42 @@ func (s *wafService) UpdateRule(ctx context.Context, req *RuleRequest) error {
} }
return nil return nil
} }
func (s *wafService) ListListenerWafStatus(ctx context.Context, req *GatewateInfo) ([]*GatewayListener, error) {
client := s.clusterClientManager.GetClient(req.RegionCode)
if client == nil {
return nil, fmt.Errorf("failed to get cluster client")
}
listenerList, err := client.WafV1alpha1().Services(req.Namespace).List(ctx, metav1.ListOptions{LabelSelector: fmt.Sprintf("apigateway_name=%s", req.GatewayName)})
if err != nil {
return nil, fmt.Errorf("failed to get listener list: %v", err)
}
listenerStatusList := []*GatewayListener{}
portList := []int{}
for _, listener := range listenerList.Items {
n := strings.LastIndex(listener.Name, "-")
if n == -1 {
return nil, fmt.Errorf("failed to get listener name: %v", listener.Name)
}
listenerPort := listener.Name[n+1:]
listenerPortInt, err := strconv.Atoi(listenerPort)
if err != nil {
return nil, fmt.Errorf("failed to get listener port: %v", err)
}
portList = append(portList, listenerPortInt)
}
for _, port := range portList {
listenerStatusList = append(listenerStatusList, &GatewayListener{
GatewayName: req.GatewayName,
Namespace: req.Namespace,
RegionCode: req.RegionCode,
Port: port,
Enable: true,
})
}
return listenerStatusList, nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment