TSG-11849 tfe增加从环境变量中读入处理机ip
TSG-11742 IP Libraries统一使用.分隔地理层级 TSG-10722 日志中开始时间从解析层获取
This commit is contained in:
24
plugin/business/tsg-http/include/edit_element.h
Normal file
24
plugin/business/tsg-http/include/edit_element.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
|
||||
enum search_scope
|
||||
{
|
||||
kScopeInside = 0,
|
||||
kScopeWhole,
|
||||
KScopeMax
|
||||
};
|
||||
|
||||
struct edit_element_rule
|
||||
{
|
||||
enum search_scope scope;
|
||||
int distane_from_matching;
|
||||
char * start_indicator;
|
||||
char *element_treatment;
|
||||
char * contained_keyword;
|
||||
};
|
||||
|
||||
size_t execute_edit_element_rule(const char * in, size_t in_sz, const struct edit_element_rule *rules, size_t n_rule, char** out, int options);
|
||||
enum search_scope scope_name_to_id(const char * name);
|
||||
|
||||
void simple_edit_element(const char *user_region, const char* input, size_t in_sz, char** output, size_t *output_sz, int options);
|
||||
|
||||
40
plugin/business/tsg-http/include/http_lua.h
Normal file
40
plugin/business/tsg-http/include/http_lua.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
|
||||
#include <event2/buffer.h>
|
||||
|
||||
#include "pattern_replace.h"
|
||||
#include <tfe_http.h>
|
||||
#include <MESA/elua.h>
|
||||
|
||||
struct tsg_lua_script
|
||||
{
|
||||
int lua_is_cache;
|
||||
struct elua_vm **http_lua_handle;
|
||||
int (*http_lua_profile)(int profile_id, struct elua_script ***elua_ctx);
|
||||
};
|
||||
|
||||
struct tsg_script_ctx
|
||||
{
|
||||
int config_id;
|
||||
int profile_id;
|
||||
int http_req_uri;
|
||||
char *rewrite_uri;
|
||||
int execut_lua_sucess;
|
||||
struct elua_context *elua_ctx;
|
||||
enum tfe_http_event events;
|
||||
void * local_logger;
|
||||
const struct tfe_http_session *session;
|
||||
struct tfe_http_half *replacing;
|
||||
struct evbuffer *http_body;
|
||||
struct evbuffer *http_lua_body;
|
||||
int actually_executed;
|
||||
};
|
||||
|
||||
struct elua_context * http_lua_ctx_new(struct tsg_lua_script *lua_script, unsigned int thread_id);
|
||||
void http_lua_ctx_free(struct tsg_lua_script *lua_script, unsigned int thread_id, struct elua_context * lua_ctx);
|
||||
struct elua_script *http_lua_map_cache_script(struct elua_vm *vm, const char *script, size_t script_len, size_t timeout_ms);
|
||||
|
||||
size_t execute_lua_script_rule(struct tsg_lua_script *lua_script, int profile_id, struct elua_context * lua_ctx, unsigned int thread_id, void *user_data);
|
||||
int http_lua_handle_create(struct tsg_lua_script *lua_script, int thread_num, const char *name_space);
|
||||
|
||||
42
plugin/business/tsg-http/include/pattern_replace.h
Normal file
42
plugin/business/tsg-http/include/pattern_replace.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
enum replace_zone
|
||||
{
|
||||
kZoneRequestUri = 0,
|
||||
kZoneRequestHeaders,
|
||||
kZoneRequestBody,
|
||||
kZoneResponseHeader,
|
||||
kZoneResponseBody,
|
||||
kZoneMax
|
||||
};
|
||||
|
||||
/**
|
||||
rule type: replace
|
||||
rule type: insert(find: insert on, replace_with: insert content)
|
||||
*/
|
||||
struct replace_rule
|
||||
{
|
||||
enum replace_zone zone;
|
||||
char * find;
|
||||
char * replace_with;
|
||||
};
|
||||
|
||||
struct insert_rule
|
||||
{
|
||||
int inject_sz;
|
||||
char * script;
|
||||
char * type;
|
||||
char * position;
|
||||
};
|
||||
|
||||
//@parm exec_para example input:
|
||||
//zone=http_req_body; substitute=/中華民國/中华人民共和国;zone=http_resp_header; substitute=/Content-Type:\btext\/html/Content-Type:\bvideo\/mp4
|
||||
//@return formated rule number.
|
||||
size_t execute_replace_rule(const char * in, size_t in_sz, enum replace_zone zone, const struct replace_rule * rules, size_t n_rule, char** out, int options);
|
||||
size_t execute_insert_rule(char * in, size_t in_sz, const struct insert_rule * rules, char** out);
|
||||
size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char *stype, const char *type, char** out);
|
||||
void simple_replace(const char* find, const char* replacement, const char* input, size_t in_sz, char** output, size_t *output_sz, int options);
|
||||
|
||||
enum replace_zone zone_name_to_id(const char * name);
|
||||
|
||||
|
||||
28
plugin/business/tsg-http/include/tsg_proxy_logger.h
Normal file
28
plugin/business/tsg-http/include/tsg_proxy_logger.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <tfe_stream.h>
|
||||
#include <tfe_http.h>
|
||||
#include <MESA/Maat_rule.h>
|
||||
|
||||
struct proxy_log
|
||||
{
|
||||
const struct tfe_stream *stream;
|
||||
const struct tfe_http_session* http;
|
||||
const Maat_rule_t*result;
|
||||
size_t result_num;
|
||||
struct evbuffer* req_body, *resp_body;
|
||||
unsigned char action;
|
||||
size_t inject_sz;
|
||||
char *asn_client;
|
||||
char *asn_server;
|
||||
char *location_client;
|
||||
char *location_server;
|
||||
};
|
||||
struct proxy_logger;
|
||||
struct proxy_logger* proxy_log_handle_create(const char* profile, const char* section, void* local_logger);
|
||||
|
||||
//return 0 if SUCCESS, otherwise return -1
|
||||
int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg);
|
||||
|
||||
|
||||
|
||||
69
plugin/business/tsg-http/include/tsg_proxy_web_cache.h
Normal file
69
plugin/business/tsg-http/include/tsg_proxy_web_cache.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
#include <event2/event.h>
|
||||
#include <event2/buffer.h>
|
||||
#include <tfe_future.h>
|
||||
#include <MESA/Maat_rule.h>
|
||||
|
||||
|
||||
struct cache_handle;
|
||||
struct cache_handle* create_web_cache_handle(const char* profile_path, const char* section,
|
||||
struct event_base* gc_evbase, Maat_feather_t feather, void *logger);
|
||||
|
||||
struct cached_meta
|
||||
{
|
||||
size_t content_length;
|
||||
char* content_type;
|
||||
char* last_modified;
|
||||
char* etag;
|
||||
};
|
||||
const struct cached_meta* cache_query_result_read_meta(future_result_t * result);
|
||||
size_t cache_query_result_get_data(future_result_t * result, const unsigned char** pp_data);
|
||||
|
||||
int web_cache_async_read(struct cache_handle* handle, unsigned int thread_id,
|
||||
const struct tfe_http_half * request, struct cache_mid** mid, struct future* f);
|
||||
|
||||
|
||||
|
||||
enum cache_query_result_type
|
||||
{
|
||||
CACHE_QUERY_RESULT_MISS,
|
||||
CACHE_QUERY_RESULT_META,
|
||||
CACHE_QUERY_RESULT_DATA,
|
||||
CACHE_QUERY_RESULT_END,
|
||||
CACHE_QUERY_RESULT_IRRELEVANT,
|
||||
__CACHE_QUERY_RESULT_MAX
|
||||
};
|
||||
enum cache_query_result_type cache_query_result_get_type(future_result_t * result);
|
||||
|
||||
enum cache_pending_result
|
||||
{
|
||||
PENDING_RESULT_NONE=0,
|
||||
PENDING_RESULT_FOBIDDEN,
|
||||
PENDING_RESULT_REVALIDATE,
|
||||
PENDING_RESULT_ALLOWED,
|
||||
PENDING_RESULT_HIT,
|
||||
PENDING_RESULT_MISS
|
||||
};
|
||||
const char* cache_pending_result_string(enum cache_pending_result);
|
||||
struct cache_mid;
|
||||
void cache_mid_clear(struct cache_mid **mid);
|
||||
|
||||
const struct cached_meta* cache_pending_result_read_meta(future_result_t * result, struct cache_mid* mid);
|
||||
enum cache_pending_result web_cache_async_pending(struct cache_handle* handle, unsigned int thread_id,
|
||||
const struct tfe_http_half * request, struct cache_mid **mid, struct future* f_revalidate);
|
||||
|
||||
|
||||
|
||||
|
||||
struct cache_write_context;
|
||||
struct cache_write_context* web_cache_write_start(struct cache_handle* handle, unsigned int thread_id,
|
||||
const struct tfe_http_session * session, struct cache_mid **mid);
|
||||
void web_cache_write(struct cache_write_context* ctx, const unsigned char * body_frag, size_t frag_size);
|
||||
//return 1 on success
|
||||
//return -1 on failed
|
||||
//return -2 on cancel
|
||||
|
||||
int web_cache_write_end(struct cache_write_context* ctx);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user