mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-17 16:00:26 +03:00
sync code
This commit is contained in:
@@ -10,6 +10,4 @@ ENVOY_ATTACHMENT_DIR="@ENVOY_ATTACHMENT_DIR@"
|
||||
cd $ENVOY_ATTACHMENT_DIR
|
||||
|
||||
# Run the go build command
|
||||
CGO_CFLAGS="-I@ATTACHMENTS_INCLUDE_DIR@ -I@NANO_ATTACHMENT_INCLUDE_DIR@" go build -o ${ENVOY_ATTACHMENT_DIR}/libenvoy_attachment.so -buildmode=c-shared -ldflags="-extldflags '-L${SHMEM_LIBRARY_DIR} -L${NANO_ATTACHMENT_LIBRARY_DIR} -L${NANO_ATTACHMENT_UTIL_LIBRARY_DIR} ${LIBRARIES}'"
|
||||
|
||||
|
||||
CC=gcc-5 CGO_CFLAGS="-I@ATTACHMENTS_INCLUDE_DIR@ -I@NANO_ATTACHMENT_INCLUDE_DIR@" go build -o ${ENVOY_ATTACHMENT_DIR}/libenvoy_attachment.so -buildmode=c-shared -ldflags="-extldflags '-L${SHMEM_LIBRARY_DIR} -L${NANO_ATTACHMENT_LIBRARY_DIR} -L${NANO_ATTACHMENT_UTIL_LIBRARY_DIR} ${LIBRARIES}'"
|
||||
|
||||
@@ -21,6 +21,9 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
unsigned long get_thread_id() {
|
||||
@@ -89,9 +92,9 @@ func getEnvoyConcurrency() int {
|
||||
}
|
||||
|
||||
func configurationServer() {
|
||||
r := chi.NewRouter()
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Get("/load-config", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/load-config", func(w http.ResponseWriter, r *http.Request) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
worker_ids := make([]int, 0)
|
||||
@@ -135,7 +138,7 @@ func configurationServer() {
|
||||
workers_reload_status[strconv.Itoa(worker_id)] = "Reload Configuraiton Succeded"
|
||||
}
|
||||
|
||||
response, err := json.Marshal(workers_reload_status)
|
||||
response, err := json.Marshal(workers_reload_status)
|
||||
if err != nil {
|
||||
api.LogWarnf("Error while sending reponse about reload configuration. Err: %s", err.Error())
|
||||
response = []byte(`{"error": "Internal Error"}`)
|
||||
@@ -145,11 +148,11 @@ func configurationServer() {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(response)
|
||||
})
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(response)
|
||||
})
|
||||
|
||||
http.ListenAndServe(":8119", r)
|
||||
http.ListenAndServe(":8119", r)
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -158,9 +161,9 @@ func init() {
|
||||
go configurationServer()
|
||||
}
|
||||
|
||||
type config struct {}
|
||||
type config struct{}
|
||||
|
||||
type parser struct {}
|
||||
type parser struct{}
|
||||
|
||||
func sendKeepAlive() {
|
||||
for {
|
||||
@@ -175,14 +178,14 @@ func sendKeepAlive() {
|
||||
}
|
||||
|
||||
func (p *parser) initFilterStructs() *filterRequestStructs {
|
||||
return &filterRequestStructs {
|
||||
http_start_data: (*C.HttpRequestFilterData)(C.malloc(C.sizeof_HttpRequestFilterData)),
|
||||
http_meta_data: (*C.HttpMetaData)(C.malloc(C.sizeof_HttpMetaData)),
|
||||
http_headers: (*C.HttpHeaders)(C.malloc(C.sizeof_HttpHeaders)),
|
||||
http_headers_data: (*C.HttpHeaderData)(C.malloc(10000 * C.sizeof_HttpHeaderData)),
|
||||
http_res_headers: (*C.ResHttpHeaders)(C.malloc(C.sizeof_ResHttpHeaders)),
|
||||
http_body_data: (*C.nano_str_t)(C.malloc(10000 * C.sizeof_nano_str_t)),
|
||||
attachment_data: (*C.AttachmentData)(C.malloc(C.sizeof_AttachmentData)),
|
||||
return &filterRequestStructs{
|
||||
http_start_data: (*C.HttpRequestFilterData)(C.malloc(C.sizeof_HttpRequestFilterData)),
|
||||
http_meta_data: (*C.HttpMetaData)(C.malloc(C.sizeof_HttpMetaData)),
|
||||
http_headers: (*C.HttpHeaders)(C.malloc(C.sizeof_HttpHeaders)),
|
||||
http_headers_data: (*C.HttpHeaderData)(C.malloc(10000 * C.sizeof_HttpHeaderData)),
|
||||
http_res_headers: (*C.ResHttpHeaders)(C.malloc(C.sizeof_ResHttpHeaders)),
|
||||
http_body_data: (*C.nano_str_t)(C.malloc(10000 * C.sizeof_nano_str_t)),
|
||||
attachment_data: (*C.AttachmentData)(C.malloc(C.sizeof_AttachmentData)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +226,7 @@ func (p *parser) Parse(any *anypb.Any, callbacks api.ConfigCallbackHandler) (int
|
||||
//mutex.Unlock()
|
||||
}
|
||||
|
||||
go func (){
|
||||
go func() {
|
||||
sendKeepAlive()
|
||||
}()
|
||||
|
||||
@@ -270,13 +273,13 @@ func ConfigFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Strea
|
||||
session_data := C.InitSessionData((*C.NanoAttachment)(attachment_ptr), C.SessionID(session_id))
|
||||
|
||||
return &filter{
|
||||
callbacks: callbacks,
|
||||
config: conf,
|
||||
session_id: session_id,
|
||||
cp_attachment: attachment_ptr,
|
||||
session_data: session_data,
|
||||
callbacks: callbacks,
|
||||
config: conf,
|
||||
session_id: session_id,
|
||||
cp_attachment: attachment_ptr,
|
||||
session_data: session_data,
|
||||
request_structs: attachment_to_filter_request_structs[worker_id],
|
||||
}
|
||||
}
|
||||
|
||||
func main() {}
|
||||
func main() {}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
unsigned long get_thread_id_2() {
|
||||
@@ -257,7 +260,7 @@ func (f *filter) sendBody(buffer api.BufferInstance, is_req bool) C.AttachmentVe
|
||||
|
||||
}
|
||||
|
||||
http_chunks_array := C.HttpBody{
|
||||
http_chunks_array := C.NanoHttpBody{
|
||||
data: f.request_structs.http_body_data,
|
||||
bodies_count: C.size_t(num_of_buffers),
|
||||
}
|
||||
|
||||
@@ -3,20 +3,18 @@ module gitlab.ngen.checkpoint.com/Ngen/agent-core/attachments/envoy
|
||||
// the version should >= 1.18
|
||||
go 1.24
|
||||
|
||||
toolchain go1.24.2
|
||||
|
||||
// NOTICE: these lines could be generated automatically by "go mod tidy"
|
||||
require (
|
||||
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa
|
||||
github.com/envoyproxy/envoy v1.34.4
|
||||
google.golang.org/protobuf v1.36.6
|
||||
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa
|
||||
github.com/envoyproxy/envoy v1.34.5
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
||||
require github.com/go-chi/chi/v5 v5.1.0
|
||||
|
||||
require (
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ=
|
||||
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
|
||||
github.com/envoyproxy/envoy v1.34.4 h1:C7icH8oLgy7Fx4A5AaljRrNBoLO7xeyN4XEJhYSlL1U=
|
||||
github.com/envoyproxy/envoy v1.34.4/go.mod h1:A/vRPuqivdZBAr0NfT3sccV8KtY07B2PyvILAdV0qCU=
|
||||
github.com/envoyproxy/envoy v1.34.5 h1:qG8j0jSapGLJDo63BgRSGGcq/Y2lq6HyM+YymJR9/Kc=
|
||||
github.com/envoyproxy/envoy v1.34.5/go.mod h1:A/vRPuqivdZBAr0NfT3sccV8KtY07B2PyvILAdV0qCU=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
|
||||
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "nano_attachment_common.h"
|
||||
#include "nano_attachment.h"
|
||||
|
||||
Reference in New Issue
Block a user