diff --git a/core/include/dap_common.h b/core/include/dap_common.h index c03864a9da1f146dc5491a3e63e0b869bfa733ba..a2845f4c277faace29fbf6a64cf53049048c20e3 100755 --- a/core/include/dap_common.h +++ b/core/include/dap_common.h @@ -874,3 +874,5 @@ DAP_STATIC_INLINE int dap_stream_node_addr_from_str(dap_stream_node_addr_t *a_ad } DAP_STATIC_INLINE bool dap_stream_node_addr_is_blank(dap_stream_node_addr_t *a_addr) { return !a_addr->uint64; } + +const char *dap_stream_node_addr_to_str_static(dap_stream_node_addr_t a_address); \ No newline at end of file diff --git a/core/src/dap_common.c b/core/src/dap_common.c index 0c4201fe64d308254c410c191444f56758072b9c..2c0b70d9e8f6ee84f0254e678e25a54ac0e6d54c 100755 --- a/core/src/dap_common.c +++ b/core/src/dap_common.c @@ -1446,6 +1446,19 @@ ssize_t dap_writev(dap_file_handle_t a_hf, const char* a_filename, iovec_t const #endif } +#ifdef __cplusplus +extern "C" { +#endif +const char *dap_stream_node_addr_to_str_static(dap_stream_node_addr_t a_address) +{ + static _Thread_local char s_buf[23] = { '\0' }; + dap_snprintf(s_buf, sizeof(s_buf), NODE_ADDR_FP_STR, NODE_ADDR_FP_ARGS_S(a_address)); + return s_buf; +} +#ifdef __cplusplus +} +#endif + #ifdef DAP_SYS_DEBUG dap_memstat_rec_t *g_memstat [MEMSTAT$K_MAXNR]; /* Array to keep pointers to module/facility specific memstat vecros */ static pthread_rwlock_t s_memstat_lock = PTHREAD_RWLOCK_INITIALIZER; diff --git a/net/server/enc_server/dap_enc_http.c b/net/server/enc_server/dap_enc_http.c index ac53e0792b185ef163cabf65850370260d9cf231..ff91ffc6ceecf91bd6cfb06633b0bf8f82930fb1 100644 --- a/net/server/enc_server/dap_enc_http.c +++ b/net/server/enc_server/dap_enc_http.c @@ -142,6 +142,13 @@ void enc_http_proc(struct dap_http_simple *cl_st, void * arg) return; } l_bias += dap_sign_get_size(l_sign); + dap_stream_node_addr_t l_client_pkey_node_addr = dap_stream_node_addr_from_sign(l_sign); + const char *l_client_node_addr_str = dap_stream_node_addr_to_str_static(l_client_pkey_node_addr); + if (dap_http_ban_list_client_check(l_client_node_addr_str, NULL, NULL)) { + log_it(L_ERROR, "Client %s is banned.", l_client_node_addr_str); + *return_code = Http_Status_Forbidden; + return; + } } if (l_sign_validated_count != l_sign_count) { log_it(L_ERROR, "Can't authorize all %zu signs", l_sign_count); diff --git a/net/stream/stream/include/dap_stream.h b/net/stream/stream/include/dap_stream.h index 2334ecf590ffa96651adcb27eb424d4958a4b945..b2ebbec95d95fbbe7f293156c1e65d16d2d42569 100644 --- a/net/stream/stream/include/dap_stream.h +++ b/net/stream/stream/include/dap_stream.h @@ -118,13 +118,6 @@ DAP_STATIC_INLINE char* dap_stream_node_addr_to_str(dap_stream_node_addr_t a_add } -DAP_STATIC_INLINE char *dap_stream_node_addr_to_str_static(dap_stream_node_addr_t a_address) -{ - static _Thread_local char s_buf[23] = { '\0' }; - dap_snprintf(s_buf, sizeof(s_buf), NODE_ADDR_FP_STR, NODE_ADDR_FP_ARGS_S(a_address)); - return s_buf; -} - DAP_STATIC_INLINE void dap_stream_node_addr_from_hash(dap_hash_fast_t *a_hash, dap_stream_node_addr_t *a_node_addr) { // Copy fist four and last four octets of hash to fill node addr