Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Golang Http Tcp Bridge #36667

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
01813c1
support golang tcp extension for http2tcp
Oct 17, 2024
ed300bb
Merge pull request #8 from duxin40/main-merge
duxin40 Oct 17, 2024
1386488
merge code of opensource main
Oct 17, 2024
6946c93
rollback go package version to follow opensource code
Oct 17, 2024
7ae6768
fix error for tests
Oct 17, 2024
a60f4fa
fix error for tests
Oct 17, 2024
e8234db
add example for http2dubbo by golang extension on envoy
Oct 21, 2024
17bc4a4
delete unused code
Oct 21, 2024
4b5880c
add new blank line
Oct 21, 2024
4abfe0a
Optimize http2dubbo example
Oct 21, 2024
da41130
format example code
Oct 21, 2024
1c35411
format example code
Oct 21, 2024
98e1589
support EncodeHeaders for goalng tcp upstream extension
Oct 22, 2024
9bb967c
1.support set buffer for writing upstream data 2.support specify cust…
Oct 30, 2024
0b7fde5
1. add example for http2dubbo by golang-tcp-upstream-extension. 2. op…
Oct 31, 2024
5898f45
optimize http2dubbo example
Nov 1, 2024
7c21160
optimize annotation for http2dubbo example
Nov 1, 2024
de5d85d
delete ununsed file
Nov 1, 2024
1d2d0ac
optimize annotation for http2dubbo example
Nov 1, 2024
152118b
support unique ptr for tcp_upstream and tcp_conn_pool
Nov 11, 2024
08bb49e
optimize code
Nov 11, 2024
c92c078
1.add destructor func for tcp upstream and filter. 2.optimize code
Nov 12, 2024
0cc11de
optimize logic for upstream config
Nov 12, 2024
8187006
optimize and delete unuse code
Nov 12, 2024
c056752
1. remove weak_filter of async, and use sync clearly bteween go and c++.
Nov 20, 2024
28b8111
delete unused code
Nov 20, 2024
2d1abdd
simplify & optimize status and state
Nov 21, 2024
185818c
support full-duplex
Nov 21, 2024
9dd2d0c
add notes for status and fix bug
Nov 22, 2024
65e4796
add docks for golang tcp upstream filter
Nov 28, 2024
1260dd7
optimize envoyGoTcpUpstreamDestroyPluginConfig and envoyGoOnTcpUpstre…
Dec 2, 2024
bc83d9b
delete state.doDataList in encodeHeaders and encodeData
Dec 2, 2024
8cf3668
optimize annotation
Dec 2, 2024
be318e2
delete unused go code
Dec 2, 2024
75a9c41
delete unused code
Dec 2, 2024
d3a44cf
optimize code
Dec 2, 2024
58d24c3
update doc and example
Dec 5, 2024
24480de
delete processState
Dec 9, 2024
663afc8
Revert "delete processState"
Dec 11, 2024
a8fa562
optimize code
Dec 13, 2024
2c47930
Merge branch 'main' into main
duxin40 Dec 13, 2024
6872fc5
optimize code
Dec 13, 2024
e7eb50b
delete unused log
Dec 13, 2024
143875b
optimize about mutex and panic
Dec 14, 2024
0714aa7
simplfy logic about panic
Dec 15, 2024
6541f8d
optimize code
Dec 17, 2024
79401ba
optimize code
Dec 18, 2024
613a192
fix memory leaking
Dec 20, 2024
6d54120
optimize annoation
Dec 20, 2024
fd60445
format code
Dec 23, 2024
b32eabe
format code
Dec 23, 2024
7eaef90
fix ci problem
Dec 24, 2024
ac75587
remove lock since the plugin is sync-data-flow between c and go
Dec 31, 2024
4595abd
optimize code about panic
Jan 4, 2025
ad43324
terminate the stream when get panic
Jan 4, 2025
e314824
add integration test for golang-http-tcp-bridge
Jan 8, 2025
0dc67d0
fix ci problem
Jan 9, 2025
3869b18
optimize doc
Jan 9, 2025
1fbe401
format code
Jan 9, 2025
248045f
optimize annotation and merge multiple test go mods into a single one
Jan 13, 2025
c8942ba
add go.mod for test_data
Jan 13, 2025
e12539d
add a test for add_data
Jan 13, 2025
a4ef3f6
format code
Jan 13, 2025
914297e
Merge branch 'main' into main
duxin40 Jan 19, 2025
8adb4d8
format code and doc
Jan 19, 2025
eb33333
optimize doc
Jan 19, 2025
8baaee6
update doc and ci
Jan 20, 2025
74e0dc3
touch ci
Jan 20, 2025
1b09fd5
update doc
Jan 21, 2025
adae974
format doc
Jan 21, 2025
048e44f
optimize doc
Jan 22, 2025
b918a08
Merge branch 'main' into main
duxin40 Jan 22, 2025
2eec96e
optimize doc
Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,73 @@ updates:
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow this #37962, merge gomods into a single one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it this still required? afaict this uses the same deps that have been merged, surely we can use an existing go.mod?

Copy link
Contributor Author

@duxin40 duxin40 Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review~ At present, I have merged multiple go.mo into one go.mod, but I understand that this PR should at least add a go mod configuration to the file, because the go mod directory(/contrib/golang/upstreams/http/tcp/test/test_data) involved in this PR and the existing directory is different. I don’t know if I understand it correctly. I hope you can correct me if I am wrong. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure - @doujiang24 can this be avoided?

directory: "/contrib/golang/upstreams/http/tcp/test/test_data/buffered"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/header_op"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/local_reply"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/panic"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/property"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/self_half_close"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"

- package-ecosystem: "gomod"
directory: "/contrib/golang/upstreams/http/tcp/test/test_data/streaming"
groups:
contrib-golang:
patterns:
- "*"
schedule:
interval: daily
time: "06:00"
1 change: 1 addition & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ proto_library(
"//contrib/envoy/extensions/private_key_providers/qat/v3alpha:pkg",
"//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg",
"//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg",
"//contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha:pkg",
"//contrib/envoy/extensions/vcl/v3alpha:pkg",
"//envoy/admin/v3:pkg",
"//envoy/config/accesslog/v3:pkg",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"@com_github_cncf_xds//udpa/annotations:pkg",
"@com_github_cncf_xds//xds/annotations/v3:pkg",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
syntax = "proto3";

package envoy.extensions.upstreams.http.tcp.golang.v3alpha;

import "google/protobuf/any.proto";

import "xds/annotations/v3/status.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.upstreams.http.tcp.golang.v3alpha";
option java_outer_classname = "GolangProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha";
option (udpa.annotations.file_status).package_version_status = ACTIVE;
option (xds.annotations.v3.file_status).work_in_progress = true;

// [#protodoc-title: Golang Http Tcp Bridge]
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
//
// This bridge enables an Http client to connect to a TCP server via a Golang plugin, facilitating Protocol Convert from HTTP to any RPC protocol in Envoy.
//
// For an overview of the Golang Http bridge please see the :ref:`configuration reference documentation <config_http_tcp_bridge_golang>`.
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
// [#extension: envoy.upstreams.http.tcp.golang]
message Config {
// Globally unique ID for a dynamic library file.
string library_id = 1 [(validate.rules).string = {min_len: 1}];

// Path to a dynamic library implementing the
// :repo:`HttpTcpBridge API <contrib/golang/common/go/api.HttpTcpBridge>`
// interface.
string library_path = 2 [(validate.rules).string = {min_len: 1}];

// Globally unique name of the Go plugin.
//
// This name **must** be consistent with the name registered in ``tcp::RegisterHttpTcpBridgeFactoryAndConfigParser``
//
string plugin_name = 3 [(validate.rules).string = {min_len: 1}];
duxin40 marked this conversation as resolved.
Show resolved Hide resolved

// Configuration for the Go plugin.
//
// .. note::
// This configuration is only parsed in the go plugin, and is therefore not validated
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
// by Envoy.
//
// See the :repo:`HttpTcpBridge API <contrib/golang/common/go/api/filter.go>`
// for more information about how the plugin's configuration data can be accessed.
//
google.protobuf.Any plugin_config = 4;
}
1 change: 1 addition & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ proto_library(
"//contrib/envoy/extensions/private_key_providers/qat/v3alpha:pkg",
"//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg",
"//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg",
"//contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha:pkg",
"//contrib/envoy/extensions/vcl/v3alpha:pkg",
"//envoy/admin/v3:pkg",
"//envoy/config/accesslog/v3:pkg",
Expand Down
6 changes: 6 additions & 0 deletions contrib/contrib_build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ CONTRIB_EXTENSIONS = {
#

"envoy.router.cluster_specifier_plugin.golang": "//contrib/golang/router/cluster_specifier/source:config",

#
# http tcp upstream plugin
#

"envoy.upstreams.http.tcp.golang": "//contrib/golang/upstreams/http/tcp/source:config",
}
5 changes: 5 additions & 0 deletions contrib/extensions_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ envoy.router.cluster_specifier_plugin.golang:
- envoy.router.cluster_specifier_plugin
security_posture: requires_trusted_downstream_and_upstream
status: alpha
envoy.upstreams.http.tcp.golang:
categories:
- envoy.upstreams
security_posture: requires_trusted_downstream_and_upstream
status: alpha
61 changes: 61 additions & 0 deletions contrib/golang/common/dso/dso.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,66 @@ void NetworkFilterDsoImpl::envoyGoFilterOnSemaDec(void* w) {
envoy_go_filter_on_sema_dec_(w);
}

HttpTcpBridgeDsoImpl::HttpTcpBridgeDsoImpl(const std::string dso_name)
: HttpTcpBridgeDso(dso_name) {
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_on_config_)>(
envoy_go_http_tcp_bridge_on_config_, handler_, dso_name, "envoyGoHttpTcpBridgeOnConfig");
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_destroy_plugin_config_)>(
envoy_go_http_tcp_bridge_destroy_plugin_config_, handler_, dso_name,
"envoyGoHttpTcpBridgeDestroyPluginConfig");
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_on_encode_header_)>(
envoy_go_http_tcp_bridge_on_encode_header_, handler_, dso_name,
"envoyGoHttpTcpBridgeOnEncodeHeader");
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_on_encode_data_)>(
envoy_go_http_tcp_bridge_on_encode_data_, handler_, dso_name,
"envoyGoHttpTcpBridgeOnEncodeData");
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_on_upstream_data_)>(
envoy_go_http_tcp_bridge_on_upstream_data_, handler_, dso_name,
"envoyGoHttpTcpBridgeOnUpstreamData");
loaded_ &= dlsymInternal<decltype(envoy_go_http_tcp_bridge_on_destroy_)>(
envoy_go_http_tcp_bridge_on_destroy_, handler_, dso_name, "envoyGoHttpTcpBridgeOnDestroy");
}

GoUint64 HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeOnConfig(httpConfig* p0) {
ASSERT(envoy_go_http_tcp_bridge_on_config_ != nullptr);
return envoy_go_http_tcp_bridge_on_config_(p0);
}

void HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeDestroyPluginConfig(GoUint64 p0) {
ASSERT(envoy_go_http_tcp_bridge_destroy_plugin_config_ != nullptr);
return envoy_go_http_tcp_bridge_destroy_plugin_config_(p0);
}

GoUint64
HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeOnEncodeHeader(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) {
ASSERT(envoy_go_http_tcp_bridge_on_encode_header_ != nullptr);
return envoy_go_http_tcp_bridge_on_encode_header_(state, end_stream, header_num, header_bytes,
buf_ptr, buf_len);
}

GoUint64 HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeOnEncodeData(processState* state,
GoUint64 end_stream,
GoUint64 buf_ptr,
GoUint64 buf_len) {
ASSERT(envoy_go_http_tcp_bridge_on_encode_data_ != nullptr);
return envoy_go_http_tcp_bridge_on_encode_data_(state, end_stream, buf_ptr, buf_len);
}

GoUint64
HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeOnUpstreamData(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) {
ASSERT(envoy_go_http_tcp_bridge_on_upstream_data_ != nullptr);
return envoy_go_http_tcp_bridge_on_upstream_data_(state, end_stream, header_num, header_bytes,
buf_ptr, buf_len);
}

void HttpTcpBridgeDsoImpl::envoyGoHttpTcpBridgeOnDestroy(httpRequest* p0) {
ASSERT(envoy_go_http_tcp_bridge_on_destroy_ != nullptr);
envoy_go_http_tcp_bridge_on_destroy_(p0);
}

} // namespace Dso
} // namespace Envoy
70 changes: 70 additions & 0 deletions contrib/golang/common/dso/dso.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,76 @@ class NetworkFilterDsoImpl : public NetworkFilterDso {

using NetworkFilterDsoPtr = std::shared_ptr<NetworkFilterDso>;

class HttpTcpBridgeDso : public Dso {
public:
HttpTcpBridgeDso() = default;
HttpTcpBridgeDso(const std::string dso_name) : Dso(dso_name){};
~HttpTcpBridgeDso() override = default;

virtual GoUint64 envoyGoHttpTcpBridgeOnConfig(httpConfig* p0) PURE;

virtual void envoyGoHttpTcpBridgeDestroyPluginConfig(GoUint64 p0) PURE;

virtual GoUint64 envoyGoHttpTcpBridgeOnEncodeHeader(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) PURE;

virtual GoUint64 envoyGoHttpTcpBridgeOnEncodeData(processState* state, GoUint64 end_stream,
GoUint64 buf_ptr, GoUint64 buf_len) PURE;

virtual GoUint64 envoyGoHttpTcpBridgeOnUpstreamData(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) PURE;

virtual void envoyGoHttpTcpBridgeOnDestroy(httpRequest* p0) PURE;
};

class HttpTcpBridgeDsoImpl : public HttpTcpBridgeDso {
public:
HttpTcpBridgeDsoImpl(const std::string dso_name);
~HttpTcpBridgeDsoImpl() override = default;

GoUint64 envoyGoHttpTcpBridgeOnConfig(httpConfig* p0) override;

void envoyGoHttpTcpBridgeDestroyPluginConfig(GoUint64 p0) override;

GoUint64 envoyGoHttpTcpBridgeOnEncodeHeader(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) override;

GoUint64 envoyGoHttpTcpBridgeOnEncodeData(processState* state, GoUint64 end_stream,
GoUint64 buf_ptr, GoUint64 buf_len) override;

GoUint64 envoyGoHttpTcpBridgeOnUpstreamData(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len) override;

void envoyGoHttpTcpBridgeOnDestroy(httpRequest* p0) override;

private:
GoUint64 (*envoy_go_http_tcp_bridge_on_config_)(httpConfig* p0) = {nullptr};

void (*envoy_go_http_tcp_bridge_destroy_plugin_config_)(GoUint64 p0) = {nullptr};

GoUint64 (*envoy_go_http_tcp_bridge_on_encode_header_)(processState* p0, GoUint64 p1, GoUint64 p2,
GoUint64 p3, GoUint64 buf_ptr,
GoUint64 buf_len) = {nullptr};

GoUint64 (*envoy_go_http_tcp_bridge_on_encode_data_)(processState* state, GoUint64 end_stream,
GoUint64 buf_ptr,
GoUint64 buf_len) = {nullptr};

GoUint64 (*envoy_go_http_tcp_bridge_on_upstream_data_)(processState* state, GoUint64 end_stream,
GoUint64 header_size,
GoUint64 header_byte_size,
GoUint64 buf_ptr,
GoUint64 buf_len) = {nullptr};

void (*envoy_go_http_tcp_bridge_on_destroy_)(httpRequest* p0) = {nullptr};
};

using HttpTcpBridgeDsoPtr = std::shared_ptr<HttpTcpBridgeDso>;

/*
* We do not unload a dynamic library once it is loaded. This is because
* Go shared library could not be unload by dlclose yet, see:
Expand Down
30 changes: 30 additions & 0 deletions contrib/golang/common/dso/libgolang.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,36 @@ extern GoUint64 envoyGoFilterOnUpstreamData(void* f, GoUint64 data_size, GoUint6
// github.com/envoyproxy/envoy/contrib/golang/filters/network/source/go/pkg/network.envoyGoFilterOnUpstreamEvent
extern void envoyGoFilterOnUpstreamEvent(void* f, GoInt event);

// go:linkname envoyGoHttpTcpBridgeOnConfig
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoHttpTcpBridgeOnConfig
extern GoUint64 envoyGoHttpTcpBridgeOnConfig(GoUint64 library_id_ptr, GoUint64 library_id_len,
GoUint64 config_ptr, GoUint64 config_len);

// go:linkname envoyGoHttpTcpBridgeDestroyPluginConfig
// github.com/envoyproxy/envoy/contrib/golang/filters/http/source/go/pkg/http.envoyGoHttpTcpBridgeDestroyPluginConfig
extern void envoyGoHttpTcpBridgeDestroyPluginConfig(GoUint64 id);

// go:linkname envoyGoHttpTcpBridgeOnEncodeHeader
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoHttpTcpBridgeOnEncodeHeader
extern GoUint64 envoyGoHttpTcpBridgeOnEncodeHeader(processState* r, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len);

// go:linkname envoyGoHttpTcpBridgeOnEncodeData
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoHttpTcpBridgeOnEncodeData
extern GoUint64 envoyGoHttpTcpBridgeOnEncodeData(processState* state, GoUint64 end_stream,
GoUint64 buf_ptr, GoUint64 buf_len);

// go:linkname envoyGoHttpTcpBridgeOnUpstreamData
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoHttpTcpBridgeOnUpstreamData
extern GoUint64 envoyGoHttpTcpBridgeOnUpstreamData(processState* state, GoUint64 end_stream,
GoUint64 header_num, GoUint64 header_bytes,
GoUint64 buf_ptr, GoUint64 buf_len);

// go:linkname envoyGoHttpTcpBridgeOnDestroy
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoHttpTcpBridgeOnDestroy
extern void envoyGoHttpTcpBridgeOnDestroy(httpRequest* r);

#ifdef __cplusplus
}
#endif
13 changes: 13 additions & 0 deletions contrib/golang/common/go/api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ CAPIStatus envoyGoFilterSetFilterState(void* wrapper, void* key, void* value, in
int life_span, int stream_sharing);
CAPIStatus envoyGoFilterGetFilterState(void* wrapper, void* key, void* value);

// tcp upstream
CAPIStatus envoyGoHttpTcpBridgeCopyHeaders(void* s, void* strs, void* buf);
CAPIStatus envoyGoHttpTcpBridgeSetRespHeader(void* s, void* key_data, int key_len, void* value_data,
int value_len, headerAction action);
CAPIStatus envoyGoHttpTcpBridgeRemoveRespHeader(void* s, void* key_data, int key_len);
CAPIStatus envoyGoHttpTcpBridgeGetBuffer(void* s, uint64_t buffer, void* value);
CAPIStatus envoyGoHttpTcpBridgeDrainBuffer(void* s, uint64_t buffer, uint64_t length);
CAPIStatus envoyGoHttpTcpBridgeSetBufferHelper(void* s, uint64_t buffer, void* data, int length,
bufferAction action);
CAPIStatus envoyGoHttpTcpBridgeGetStringValue(void* r, int id, uint64_t* value_data,
int* value_len);
CAPIStatus envoyGoHttpTcpBridgeSetSelfHalfCloseForUpstreamConn(void* r, int enabled);

#ifdef __cplusplus
} // extern "C"
#endif
16 changes: 16 additions & 0 deletions contrib/golang/common/go/api/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ type NetworkCAPI interface {
UpstreamInfo(f unsafe.Pointer, infoType int) string
}

type TcpUpstreamCAPI interface {
// Header related
CopyHeaders(s unsafe.Pointer, num uint64, bytes uint64) map[string][]string
SetRespHeader(s unsafe.Pointer, key string, value string, add bool)
RemoveRespHeader(s unsafe.Pointer, key string)
// Buffer related
GetBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64) []byte
DrainBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64)
SetBufferHelper(s unsafe.Pointer, bufferPtr uint64, value string, action BufferAction)
SetBytesBufferHelper(s unsafe.Pointer, bufferPtr uint64, value []byte, action BufferAction)
// Get the specified value by key
GetStringValue(r unsafe.Pointer, id int) (string, bool)

SetSelfHalfCloseForUpstreamConn(r unsafe.Pointer, enabled int)
}

type CommonCAPI interface {
Log(level LogType, message string)
LogLevel() LogType
Expand Down
Loading
Loading