Skip to content

Commit

Permalink
chore: code format with make format (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
luohoufu authored Jan 12, 2025
1 parent 402d209 commit cdac72c
Show file tree
Hide file tree
Showing 87 changed files with 803 additions and 835 deletions.
4 changes: 2 additions & 2 deletions api/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ func (h *GatewayAPI) searchEntry(w http.ResponseWriter, req *http.Request, ps ht
var (
name = h.GetParameterOrDefault(req, "name", "")
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
size = h.GetIntOrDefault(req, "size", 20)
from = h.GetIntOrDefault(req, "from", 0)
size = h.GetIntOrDefault(req, "size", 20)
from = h.GetIntOrDefault(req, "from", 0)
mustBuilder = &strings.Builder{}
)
if name != "" {
Expand Down
4 changes: 2 additions & 2 deletions api/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (h *GatewayAPI) searchFlow(w http.ResponseWriter, req *http.Request, ps htt

func (h *GatewayAPI) getFlowFilters(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {

meta:=pipeline.GetFilterMetadata()
meta := pipeline.GetFilterMetadata()

h.WriteJSON(w, meta,200)
h.WriteJSON(w, meta, 200)
}
11 changes: 6 additions & 5 deletions cmd/echo_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import (

var port = flag.Int("port", 8080, "listening port")
var debug = flag.Bool("debug", false, "dump request")
var name =util.PickRandomName()
var name = util.PickRandomName()

func main() {
runtime.GOMAXPROCS(1)
flag.Parse()
Expand All @@ -50,7 +51,7 @@ func main() {
}

func requestHandler(ctx *fasthttp.RequestCtx) {
if *debug{
if *debug {
fmt.Println(string(ctx.Request.PhantomURI().Scheme()))
fmt.Println(string(ctx.Request.PhantomURI().Host()))
fmt.Println(string(ctx.Request.PhantomURI().FullURI()))
Expand All @@ -59,10 +60,10 @@ func requestHandler(ctx *fasthttp.RequestCtx) {
fmt.Println(string(ctx.Request.PhantomURI().Hash()))
fmt.Println(string(ctx.Request.PhantomURI().Username()))
fmt.Println(string(ctx.Request.PhantomURI().Password()))
fmt.Println(ctx.Request.Header.String(),true)
fmt.Println(ctx.Request.GetRawBody(),true)
fmt.Println(ctx.Request.Header.String(), true)
fmt.Println(ctx.Request.GetRawBody(), true)
}
ctx.Response.Header.Set("SERVER",name)
ctx.Response.Header.Set("SERVER", name)
ctx.Response.SetStatusCode(200)
fmt.Fprintf(ctx, ".")
}
18 changes: 9 additions & 9 deletions cmd/kafka_consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
* Email: hello#infini.ltd */

package main

import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"strings"

"github.com/twmb/franz-go/pkg/kgo"
"context"
"flag"
"fmt"
"os"
"os/signal"
"strings"

"github.com/twmb/franz-go/pkg/kgo"
)

var (
Expand Down Expand Up @@ -143,4 +144,3 @@ func consume(cl *kgo.Client, style int) {
}
}
}

5 changes: 2 additions & 3 deletions cmd/s3download/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func main() {

// Upload the zip file
filePath := "/Users/medcl/Downloads/coraza-waf-master.zip"
folder:="myfolder"
objectName := path.Join(folder,filepath.Base(filePath))
folder := "myfolder"
objectName := path.Join(folder, filepath.Base(filePath))

contentType := "application/zip"

Expand All @@ -90,4 +90,3 @@ func main() {
log.Printf("Successfully uploaded %s of size %d\n", objectName, info.Size)

}

22 changes: 11 additions & 11 deletions common/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ type DataFlow struct {
}

type HttpRequest struct {
ID uint64 `json:"id,omitempty"`
LoggingTime string `json:"timestamp,omitempty"`
LocalIP string `json:"local_ip,omitempty"`
RemoteIP string `json:"remote_ip,omitempty"`
IsTLS bool `json:"tls"`
TLSDidResume bool `json:"tls_reuse,omitempty"`
Request *Request `json:"request,omitempty"`
Response *Response `json:"response,omitempty"`
DataFlow *DataFlow `json:"flow,omitempty"`
Elastic map[string]interface{} `json:"elastic,omitempty"`
}
ID uint64 `json:"id,omitempty"`
LoggingTime string `json:"timestamp,omitempty"`
LocalIP string `json:"local_ip,omitempty"`
RemoteIP string `json:"remote_ip,omitempty"`
IsTLS bool `json:"tls"`
TLSDidResume bool `json:"tls_reuse,omitempty"`
Request *Request `json:"request,omitempty"`
Response *Response `json:"response,omitempty"`
DataFlow *DataFlow `json:"flow,omitempty"`
Elastic map[string]interface{} `json:"elastic,omitempty"`
}
16 changes: 7 additions & 9 deletions common/role_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@

package common


func GetLDAPGroupsMappingRoles(str []string)[]string {
func GetLDAPGroupsMappingRoles(str []string) []string {
var roles []string
roles=append(roles,"admin")
roles = append(roles, "admin")
return roles
}


type Roles struct {
ClusterAllowedRoles map[string][]Role
ClusterDeniedRoles map[string][]Role
}

type Role struct {
Cluster []ClusterPermission //A list of cluster privileges.
Indices []IndexPermission //A list of indices permissions entries.
Indices []IndexPermission //A list of indices permissions entries.
}

type ClusterPermission struct {
Expand All @@ -50,10 +48,10 @@ type ClusterPermission struct {
}

type IndexPermission struct {
Name []string
Privileges []string
FieldSecurity []string
Query string
Name []string
Privileges []string
FieldSecurity []string
Query string
AllowRestrictedIndices string
}

Expand Down
1 change: 0 additions & 1 deletion common/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ const CACHEABLE = "request_cacheable"
const CACHEHASH = "request_cache_hash"

var FaviconPath = []byte("/favicon.ico")

2 changes: 1 addition & 1 deletion config/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

type UIConfig struct {
Enabled bool `config:"enabled"`
Enabled bool `config:"enabled"`
LocalPath string `config:"path"`
LocalEnabled bool `config:"local"`
VFSEnabled bool `config:"vfs"`
Expand Down
11 changes: 5 additions & 6 deletions lib/procspy/lsof.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ var (
//
// For example, this is one process with two listens and one connection:
//
// p13100
// cmpd
// n[::1]:6600
// n127.0.0.1:6600
// n[::1]:6600->[::1]:50992
//
// p13100
// cmpd
// n[::1]:6600
// n127.0.0.1:6600
// n[::1]:6600->[::1]:50992
func parseLSOF(out string) (map[string]Proc, error) {
var (
res = map[string]Proc{} // Local addr -> Proc
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func setup() {
module.RegisterSystemModule(&queue.Module{})
module.RegisterSystemModule(&task.TaskModule{})
module.RegisterSystemModule(&api.APIModule{})
module.RegisterModuleWithPriority(&pipeline.PipeModule{},100)
module.RegisterModuleWithPriority(&pipeline.PipeModule{}, 100)

module.RegisterUserPlugin(forcemerge.ForceMergeModule{})
module.RegisterUserPlugin(floating_ip.FloatingIPPlugin{})
module.RegisterUserPlugin(&metrics.MetricsModule{})
module.RegisterPluginWithPriority(&proxy.GatewayModule{},200)
module.RegisterPluginWithPriority(&proxy.GatewayModule{}, 200)
}

func start() {
Expand Down
20 changes: 10 additions & 10 deletions pipeline/fast_bulk_indexing/bulk_indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ func New(c *config.Config) (pipeline.Processor, error) {
Queues: map[string]interface{}{},

Consumer: queue.ConsumerConfig{
Group: "group-001",
Name: "consumer-001",
FetchMinBytes: 1,
FetchMaxBytes: 20 * 1024 * 1024,
FetchMaxMessages: 500,
EOFRetryDelayInMs: 500,
FetchMaxWaitMs: 10000,
ConsumeTimeoutInSeconds: 60,
EOFMaxRetryTimes: 10,
ClientExpiredInSeconds: 60,
Group: "group-001",
Name: "consumer-001",
FetchMinBytes: 1,
FetchMaxBytes: 20 * 1024 * 1024,
FetchMaxMessages: 500,
EOFRetryDelayInMs: 500,
FetchMaxWaitMs: 10000,
ConsumeTimeoutInSeconds: 60,
EOFMaxRetryTimes: 10,
ClientExpiredInSeconds: 60,
},

DetectActiveQueue: true,
Expand Down
20 changes: 10 additions & 10 deletions pipeline/fast_flow_runner/flow_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ func New(c *config.Config) (pipeline.Processor, error) {
cfg := Config{
NumOfWorkers: 1,
Consumer: queue.ConsumerConfig{
Group: "group-001",
Name: "consumer-001",
FetchMinBytes: 1,
FetchMaxBytes: 20 * 1024 * 1024,
FetchMaxMessages: 500,
EOFRetryDelayInMs: 500,
FetchMaxWaitMs: 10000,
ConsumeTimeoutInSeconds: 60,
EOFMaxRetryTimes: 10,
ClientExpiredInSeconds: 60,
Group: "group-001",
Name: "consumer-001",
FetchMinBytes: 1,
FetchMaxBytes: 20 * 1024 * 1024,
FetchMaxMessages: 500,
EOFRetryDelayInMs: 500,
FetchMaxWaitMs: 10000,
ConsumeTimeoutInSeconds: 60,
EOFMaxRetryTimes: 10,
ClientExpiredInSeconds: 60,
},
FlowMaxRunningTimeoutInSeconds: 60,
}
Expand Down
9 changes: 4 additions & 5 deletions pipeline/flow_replay/flow_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ func (processor *FlowRunnerProcessor) Process(ctx *pipeline.Context) error {

if processor.config.KeepTags {
tags, ok := filterCtx.GetTags()
if ok{
ts:=[]string{}
for _,v:=range tags{
ts=append(ts,v)
if ok {
ts := []string{}
for _, v := range tags {
ts = append(ts, v)
}
ctx.AddTags(ts)
}
Expand Down Expand Up @@ -207,7 +207,6 @@ func (processor *FlowRunnerProcessor) Process(ctx *pipeline.Context) error {
releaseCtx(filterCtx)
}


log.Debugf("replay %v messages flow:[%v], elapsed:%v", len(messages), processor.config.FlowName, time.Since(start1))

}
Expand Down
Loading

0 comments on commit cdac72c

Please sign in to comment.