summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-11-10 10:57:15 +0800
committeryangwei <[email protected]>2023-11-10 10:57:15 +0800
commit52b7f5d5c214d5198eae9a815e68b23f5bb16012 (patch)
tree7b2dfb32aee4ec1c774c323a7fe89bb59a013069 /examples
parenteef2cc785653f02abea682cb5dbde3c96b771760 (diff)
🦄 refactor(sapp loader, firewall header): mv sapp loadr to ./src
remove firewall header files,
Diffstat (limited to 'examples')
-rw-r--r--examples/sapp_plugin/CMakeLists.txt5
-rw-r--r--examples/sapp_plugin/defer_loader.inf17
-rw-r--r--examples/sapp_plugin/simple_loader.c163
-rw-r--r--examples/sapp_plugin/simple_loader.inf17
4 files changed, 0 insertions, 202 deletions
diff --git a/examples/sapp_plugin/CMakeLists.txt b/examples/sapp_plugin/CMakeLists.txt
index 8105e24..d6dc162 100644
--- a/examples/sapp_plugin/CMakeLists.txt
+++ b/examples/sapp_plugin/CMakeLists.txt
@@ -5,8 +5,3 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
add_library(publisher_loader SHARED publisher_loader.c)
target_link_libraries(publisher_loader adapter)
set_target_properties(publisher_loader PROPERTIES PREFIX "")
-
-
-add_library(simple_loader SHARED simple_loader.c)
-target_link_libraries(simple_loader adapter)
-set_target_properties(simple_loader PROPERTIES PREFIX "") \ No newline at end of file
diff --git a/examples/sapp_plugin/defer_loader.inf b/examples/sapp_plugin/defer_loader.inf
deleted file mode 100644
index a0c94b9..0000000
--- a/examples/sapp_plugin/defer_loader.inf
+++ /dev/null
@@ -1,17 +0,0 @@
-[PLUGINFO]
-PLUGNAME=defer_loader
-SO_PATH=./plug/platform/simple_loader/simple_loader.so
-INIT_FUNC=DEFER_LOADER_INIT
-DESTROY_FUNC=DEFER_LOADER_EXIT
-
-[TCP_ALL]
-FUNC_FLAG=ALL
-FUNC_NAME=defer_loader_stream_entry
-
-#[TCP]
-#FUNC_FLAG=ALL
-#FUNC_NAME=defer_loader_stream_entry
-
-[UDP]
-FUNC_FLAG=ALL
-FUNC_NAME=defer_loader_stream_entry \ No newline at end of file
diff --git a/examples/sapp_plugin/simple_loader.c b/examples/sapp_plugin/simple_loader.c
deleted file mode 100644
index ff8cf74..0000000
--- a/examples/sapp_plugin/simple_loader.c
+++ /dev/null
@@ -1,163 +0,0 @@
-#include "stellar/utils.h"
-#include "stellar/session_exdata.h"
-
-#include "adapter/adapter.h"
-
-#include <MESA/stream.h>
-#include <stream_inc/stream_base.h>
-
-#include <assert.h>
-
-struct simple_stream_ctx
-{
- uint32_t c2s_pkts;
- uint32_t c2s_bytes;
- uint32_t s2c_pkts;
- uint32_t s2c_bytes;
- struct session *sess;
-};
-
-#define STELLAR_PLUGIN_PATH "./stellar_plugin/spec.toml"
-#define STELLAR_BRIDEGE_NAME "STELLAR_SESSION"
-#define STELLAR_EXDATA_NAME "SAPP_STREAMINFO"
-
-
-struct stellar *g_stellar=NULL;
-int g_session_bridge_id=-1;
-int g_streaminfo_exdata_id=-1;
-
-static int is_l7_type_tunnels(struct streaminfo *a_stream)
-{
- const struct streaminfo *pfather=NULL, *ptmp=a_stream;
- while(ptmp)
- {
- pfather = ptmp->pfather;
- switch(ptmp->type)
- {
- case STREAM_TYPE_SOCKS4:
- case STREAM_TYPE_SOCKS5:
- case STREAM_TYPE_HTTP_PROXY:
- return 1;
- default:
- break;
- }
- ptmp = pfather;
- }
- return 0;
-}
-
-static void simple_loader_bridge_free(const struct streaminfo *stream, int bridge_id, void *data)
-{
- return adapter_session_close((struct streaminfo *)stream, (struct session *)data, NULL);
-}
-
-int SIMPLE_LOADER_INIT()
-{
- g_stellar = stellar_init(STELLAR_PLUGIN_PATH);
- if(g_stellar==NULL)return -1;
- g_session_bridge_id=stream_bridge_build(STELLAR_BRIDEGE_NAME, "w");
- if(g_session_bridge_id < 0)return -1;
- stream_bridge_register_data_free_cb(g_session_bridge_id, simple_loader_bridge_free);
- g_streaminfo_exdata_id=stellar_session_get_ex_new_index(g_stellar, STELLAR_EXDATA_NAME, NULL, NULL);
- if(g_streaminfo_exdata_id < 0)return -1;
- return 0;
-}
-
-void SIMPLE_LOADER_EXIT(void)
-{
- stellar_exit(g_stellar);
- return;
-}
-
-int DEFER_LOADER_INIT()
-{
- return 0;
-}
-
-char defer_loader_stream_entry(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
-{
- if(pstream->pktstate==OP_STATE_PENDING && is_l7_type_tunnels(pstream)==1)
- {
- return APP_STATE_DROPME;
- }
- struct session *sess = (struct session *)stream_bridge_async_data_get(pstream, g_session_bridge_id);
- assert(sess);
- adapter_session_poll(sess);
- return APP_STATE_GIVEME;
-}
-
-void DEFER_LOADER_EXIT(void)
-{
- return;
-}
-
-static char loader_transfer_stream_entry(struct streaminfo *pstream, UCHAR state, void **pme, int thread_seq,void *a_packet)
-{
- struct simple_stream_ctx *ctx=(struct simple_stream_ctx *)*pme;
- struct tcpdetail *pdetail=(struct tcpdetail *)pstream->pdetail;
- int is_ctrl_pkt=0;
- const void *raw_pkt=NULL;
- if(state == OP_STATE_PENDING && (is_l7_type_tunnels(pstream)==1))
- {
- return APP_STATE_DROPME;
- }
-
- if(*pme==NULL)
- {
- *pme=CALLOC(struct simple_stream_ctx,1);
- ctx=(struct simple_stream_ctx *)*pme;
- }
-
- if(a_packet!=NULL)
- {
- if(DIR_C2S == pstream->curdir){
- ctx->c2s_bytes += pdetail->datalen;
- ctx->c2s_pkts++;
- }else{
- ctx->s2c_bytes += pdetail->datalen;
- ctx->s2c_pkts++;
- }
- }
- switch (state)
- {
- case OP_STATE_PENDING:
- ctx->sess = adapter_session_open(g_stellar, pstream, a_packet);
- session_set_ex_data(ctx->sess, g_streaminfo_exdata_id, pstream);
- stream_bridge_async_data_put(pstream, g_session_bridge_id, ctx->sess);
- break;
- case OP_STATE_DATA:
- raw_pkt = get_current_rawpkt_from_streaminfo(pstream);
- get_opt_from_rawpkt(raw_pkt, RAW_PKT_GET_IS_CTRL_PKT, (void *)&is_ctrl_pkt);
- if(is_ctrl_pkt==1)
- {
- adapter_session_control(pstream, ctx->sess, a_packet);
- return APP_STATE_GIVEME|APP_STATE_DROPPKT;
- }
- else
- {
- adapter_session_active(pstream, ctx->sess, a_packet);
- }
- break;
- case OP_STATE_CLOSE:
- FREE(*pme);
- break;
- default:
- break;
- }
- return APP_STATE_GIVEME;
-}
-
-char simple_loader_udp_stream_entry(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
-{
- return loader_transfer_stream_entry(pstream, pstream->opstate, pme, thread_seq, a_packet);
-}
-
-char simple_loader_tcpall_stream_entry(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
-{
- return loader_transfer_stream_entry(pstream, pstream->pktstate, pme, thread_seq, a_packet);
-}
-
-char simple_loader_tcp_stream_entry(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
-{
- return loader_transfer_stream_entry(pstream, pstream->opstate, pme, thread_seq, a_packet);
-}
diff --git a/examples/sapp_plugin/simple_loader.inf b/examples/sapp_plugin/simple_loader.inf
deleted file mode 100644
index ae89d94..0000000
--- a/examples/sapp_plugin/simple_loader.inf
+++ /dev/null
@@ -1,17 +0,0 @@
-[PLUGINFO]
-PLUGNAME=simple_loader
-SO_PATH=./plug/platform/simple_loader/simple_loader.so
-INIT_FUNC=SIMPLE_LOADER_INIT
-DESTROY_FUNC=SIMPLE_LOADER_EXIT
-
-[TCP_ALL]
-FUNC_FLAG=ALL
-FUNC_NAME=simple_loader_tcpall_stream_entry
-
-#[TCP]
-#FUNC_FLAG=ALL
-#FUNC_NAME=simple_loader_tcp_stream_entry
-
-[UDP]
-FUNC_FLAG=ALL
-FUNC_NAME=simple_loader_udp_stream_entry \ No newline at end of file