diff --git a/src/module.c b/src/module.c index 52c92d5164..0e4169d777 100644 --- a/src/module.c +++ b/src/module.c @@ -1054,6 +1054,11 @@ 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. */ @@ -2309,10 +2314,6 @@ int VM_IsModuleNameBusy(const char *name) { return de != NULL; } -int VM_GetClientConnectedPort(ValkeyModuleCtx *ctx) { - return getClientConnectedPort(ctx->client); -} - /* Return the current UNIX time in milliseconds. */ mstime_t VM_Milliseconds(void) { return mstime(); diff --git a/tests/modules/adminport.c b/tests/modules/adminport.c index 155013928d..edac6817b9 100644 --- a/tests/modules/adminport.c +++ b/tests/modules/adminport.c @@ -7,6 +7,7 @@ int testadminport_runspecificcommand(ValkeyModuleCtx *ctx, 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 {