From 08aebb5852997b6d1082566fd257735e2dba3d62 Mon Sep 17 00:00:00 2001 From: hwware Date: Thu, 5 Dec 2024 20:03:47 +0000 Subject: [PATCH] remove unrelated codes and files --- src/connection.h | 4 ---- src/module.c | 6 ------ src/networking.c | 11 ----------- src/server.c | 3 ++- src/server.h | 1 - src/valkeymodule.h | 2 -- tests/modules/Makefile | 1 - tests/modules/adminport.c | 34 ---------------------------------- 8 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 tests/modules/adminport.c diff --git a/src/connection.h b/src/connection.h index 07a48b9412..8a2775ee34 100644 --- a/src/connection.h +++ b/src/connection.h @@ -134,7 +134,6 @@ struct connection { ConnectionCallbackFunc conn_handler; ConnectionCallbackFunc write_handler; ConnectionCallbackFunc read_handler; - int connected_port; }; #define CONFIG_BINDADDR_MAX 16 @@ -319,9 +318,6 @@ static inline int connFormatAddr(connection *conn, char *buf, size_t buf_len, in return -1; } - if (!remote) { - conn->connected_port = port; - } return formatAddr(buf, buf_len, ip, port); } diff --git a/src/module.c b/src/module.c index 7c246fd864..5f9dff0402 100644 --- a/src/module.c +++ b/src/module.c @@ -1055,11 +1055,6 @@ void VM_KeyAtPos(ValkeyModuleCtx *ctx, int pos) { VM_KeyAtPosWithFlags(ctx, pos, flags); } -/* Return the connected server port of current client */ -int VM_GetClientConnectedPort(ValkeyModuleCtx *ctx) { - return getClientConnectedPort(ctx->client); -} - /* Return non-zero if a module command, that was declared with the * flag "getchannels-api", is called in a special way to get the channel positions * and not to get executed. Otherwise zero is returned. */ @@ -13579,7 +13574,6 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(Strdup); REGISTER_API(CreateCommand); REGISTER_API(GetCommand); - REGISTER_API(GetClientConnectedPort); REGISTER_API(CreateSubcommand); REGISTER_API(SetCommandInfo); REGISTER_API(SetCommandACLCategories); diff --git a/src/networking.c b/src/networking.c index bd51e1cd0b..a83af3a100 100644 --- a/src/networking.c +++ b/src/networking.c @@ -3314,16 +3314,6 @@ char *getClientSockname(client *c) { return c->sockname; } -int getClientConnectedPort(client *c) { - char sockname[NET_ADDR_STR_LEN] = {0}; - - if (c->sockname == NULL) { - genClientAddrString(c, sockname, sizeof(sockname), 0); - c->sockname = sdsnew(sockname); - } - return c->conn->connected_port; -} - int isClientConnIpV6(client *c) { /* The cached client peer id is on the form "[IPv6]:port" for IPv6 * addresses, so we just check for '[' here. */ @@ -3384,7 +3374,6 @@ sds catClientInfoString(sds s, client *client, int hide_user_data) { replBufBlock *cur = listNodeValue(client->ref_repl_buf_node); used_blocks_of_repl_buf = last->id - cur->id + 1; } - sds ret = sdscatfmt( s, FMTARGS( diff --git a/src/server.c b/src/server.c index 8b0bfaa47d..26855bf4d1 100644 --- a/src/server.c +++ b/src/server.c @@ -2877,6 +2877,7 @@ void initListeners(void) { listener->port = server.rdma_ctx_config.port; listener->ct = connectionByType(CONN_TYPE_RDMA); listener->priv = &server.rdma_ctx_config; + } if (server.admin_port != 0) { conn_index = connectionIndexByType(CONN_TYPE_SOCKET); @@ -2885,7 +2886,7 @@ void initListeners(void) { while (server.listeners[conn_index].ct != NULL) { conn_index++; if (conn_index >= CONN_TYPE_MAX) { - serverPanic("No available index for additional TCP listener."); + serverPanic("Failed finding connection listener of %s", CONN_TYPE_SOCKET); } } listener = &server.listeners[conn_index]; diff --git a/src/server.h b/src/server.h index c46c2a5314..22edcb4f78 100644 --- a/src/server.h +++ b/src/server.h @@ -2865,7 +2865,6 @@ void freeClientReplyValue(void *o); void *dupClientReplyValue(void *o); char *getClientPeerId(client *client); char *getClientSockName(client *client); -int getClientConnectedPort(client *client); int isClientConnIpV6(client *c); sds catClientInfoString(sds s, client *client, int hide_user_data); sds catClientInfoShortString(sds s, client *client, int hide_user_data); diff --git a/src/valkeymodule.h b/src/valkeymodule.h index 15c0212d97..7c3adfd477 100644 --- a/src/valkeymodule.h +++ b/src/valkeymodule.h @@ -951,7 +951,6 @@ VALKEYMODULE_API int (*ValkeyModule_CreateCommand)(ValkeyModuleCtx *ctx, int keystep) VALKEYMODULE_ATTR; VALKEYMODULE_API ValkeyModuleCommand *(*ValkeyModule_GetCommand)(ValkeyModuleCtx *ctx, const char *name)VALKEYMODULE_ATTR; -VALKEYMODULE_API int (*ValkeyModule_GetClientConnectedPort)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; VALKEYMODULE_API int (*ValkeyModule_CreateSubcommand)(ValkeyModuleCommand *parent, const char *name, ValkeyModuleCmdFunc cmdfunc, @@ -1668,7 +1667,6 @@ static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, in VALKEYMODULE_GET_API(Strdup); VALKEYMODULE_GET_API(CreateCommand); VALKEYMODULE_GET_API(GetCommand); - VALKEYMODULE_GET_API(GetClientConnectedPort); VALKEYMODULE_GET_API(CreateSubcommand); VALKEYMODULE_GET_API(SetCommandInfo); VALKEYMODULE_GET_API(SetCommandACLCategories); diff --git a/tests/modules/Makefile b/tests/modules/Makefile index 9a39178a17..82813bb6f7 100644 --- a/tests/modules/Makefile +++ b/tests/modules/Makefile @@ -52,7 +52,6 @@ TEST_MODULES = \ mallocsize.so \ aclcheck.so \ list.so \ - adminport.so \ subcommands.so \ reply.so \ cmdintrospection.so \ diff --git a/tests/modules/adminport.c b/tests/modules/adminport.c deleted file mode 100644 index edac6817b9..0000000000 --- a/tests/modules/adminport.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "valkeymodule.h" - -#include - -int testadminport_runspecificcommand(ValkeyModuleCtx *ctx, - ValkeyModuleString **argv, int argc) { - VALKEYMODULE_NOT_USED(argv); - VALKEYMODULE_NOT_USED(argc); - int port = ValkeyModule_GetClientConnectedPort(ctx); - /* Here we assume port 7001 is the admin-port */ - if (port == 7001) { - ValkeyModule_ReplyWithSimpleString(ctx, "You can execute this command"); - } else { - ValkeyModule_ReplyWithSimpleString( - ctx, "You have no permission to execute this command"); - } - return VALKEYMODULE_OK; -} - -int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, - int argc) { - VALKEYMODULE_NOT_USED(argv); - VALKEYMODULE_NOT_USED(argc); - if (ValkeyModule_Init(ctx, "adminport", 1, VALKEYMODULE_APIVER_1) == - VALKEYMODULE_ERR) - return VALKEYMODULE_ERR; - - if (ValkeyModule_CreateCommand(ctx, "testadminport.runspecificcommand", - testadminport_runspecificcommand, "", 0, 0, - 0) == VALKEYMODULE_ERR) - return VALKEYMODULE_ERR; - - return VALKEYMODULE_OK; -}