Skip to content

Commit 8d28f7f

Browse files
committed
implemented md5-hashing in notify_relay_redirect mode
1 parent 0166380 commit 8d28f7f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

ngx_rtmp_notify_module.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <ngx_config.h>
88
#include <ngx_core.h>
9+
#include <ngx_md5.h>
910
#include "ngx_rtmp.h"
1011
#include "ngx_rtmp_cmd_module.h"
1112
#include "ngx_rtmp_netcall_module.h"
@@ -979,6 +980,22 @@ ngx_rtmp_notify_connect_handle(ngx_rtmp_session_t *s,
979980
}
980981

981982

983+
static void
984+
ngx_rtmp_notify_set_name(u_char *dst, size_t dst_len, u_char *src,
985+
size_t src_len)
986+
{
987+
u_char result[16], *p;
988+
ngx_md5_t md5;
989+
990+
ngx_md5_init(&md5);
991+
ngx_md5_update(&md5, src, src_len);
992+
ngx_md5_final(result, &md5);
993+
994+
p = ngx_hex_dump(dst, result, ngx_min((dst_len - 1) / 2, 16));
995+
*p = '\0';
996+
}
997+
998+
982999
static ngx_int_t
9831000
ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
9841001
void *arg, ngx_chain_t *in)
@@ -1025,7 +1042,7 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
10251042

10261043
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
10271044
if (nacf->relay_redirect) {
1028-
*ngx_cpymem(v->name, name, rc) = 0;
1045+
ngx_rtmp_notify_set_name(v->name, NGX_RTMP_MAX_NAME, name, (size_t) rc);
10291046
}
10301047

10311048
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
@@ -1104,7 +1121,7 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s,
11041121

11051122
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
11061123
if (nacf->relay_redirect) {
1107-
*ngx_cpymem(v->name, name, rc) = 0;
1124+
ngx_rtmp_notify_set_name(v->name, NGX_RTMP_MAX_NAME, name, (size_t) rc);
11081125
}
11091126

11101127
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,

0 commit comments

Comments
 (0)