-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from lafirest/feat/udp_proxy
feat: add content-sensitive proxy behaviour for UDP
- Loading branch information
Showing
8 changed files
with
606 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
%%-------------------------------------------------------------------- | ||
%% Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved. | ||
%% | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%%-------------------------------------------------------------------- | ||
|
||
-ifndef(ESOCKD_PROXY_HRL). | ||
-define(ESOCKD_PROXY_HRL, true). | ||
|
||
-define(SSL_TRANSPORT, esockd_transport). | ||
-define(PROXY_TRANSPORT, esockd_udp_proxy). | ||
|
||
-type proxy_id() :: pid(). | ||
-type socket_packet() :: binary(). | ||
-type socket() :: inet:socket() | ssl:sslsocket(). | ||
|
||
-type transport() :: {udp, pid(), socket()} | ?SSL_TRANSPORT. | ||
-type proxy_transport() :: {?PROXY_TRANSPORT, pid(), socket()}. | ||
-type address() :: {inet:ip_address(), inet:port_number()}. | ||
-type peer() :: socket() | address(). | ||
|
||
-type connection_module() :: atom(). | ||
-type connection_state() :: term(). | ||
-type connection_packet() :: term(). | ||
|
||
-type connection_id() :: | ||
peer() | ||
| integer() | ||
| string() | ||
| binary(). | ||
|
||
-type proxy_packet() :: | ||
{?PROXY_TRANSPORT, proxy_id(), binary(), connection_packet()}. | ||
|
||
%% Routing information search results | ||
|
||
%% send raw socket packet | ||
-type get_connection_id_result() :: | ||
%% send decoded packet | ||
{ok, connection_id(), connection_packet(), connection_state()} | ||
| invalid. | ||
|
||
-type connection_options() :: #{ | ||
esockd_proxy_opts := proxy_options(), | ||
atom() => term() | ||
}. | ||
|
||
-type proxy_options() :: #{ | ||
connection_mod := connection_module(), | ||
heartbeat => non_neg_integer() | ||
}. | ||
|
||
-endif. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@startuml | ||
skinparam dpi 300 | ||
left to right direction | ||
|
||
frame client { | ||
card clinet1 | ||
card client2 | ||
card client3 | ||
} | ||
|
||
frame proxy { | ||
label "proxy converts the udp connection\nto long connection in the application" | ||
agent proxy1 | ||
agent proxy2 | ||
agent proxy3 | ||
} | ||
|
||
frame connection { | ||
card connection1 | ||
card connection2 | ||
card connection3 | ||
} | ||
|
||
clinet1 .[#red].> proxy1 | ||
client2 .[#blue].> proxy1 | ||
client3 ..> proxy2 | ||
client3 ..> proxy3 | ||
|
||
proxy1 -[#red]-> connection1 : client1 | ||
proxy1 -[#blue]-> connection2 : client2 | ||
proxy2 --> connection3 : client3 | ||
proxy3 --> connection3 : client3 | ||
|
||
note bottom of proxy1 | ||
different clients use the same UDP channel,e.g NAT, the proxy will first disconnect the existing connection and then connect to the new one | ||
endnote | ||
|
||
|
||
note right of proxy | ||
proxy2 and proxy3 are multiple channels used by a client,e.g LB | ||
endnote | ||
|
||
@enduml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.