Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
09941318
提交
09941318
authored
12月 11, 2018
作者:
Andrey Volk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11564: [mod_verto] Add ext-rtp-ip detection using stun.
上级
e7e86bf6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
84 行增加
和
1 行删除
+84
-1
switch_stun.h
src/include/switch_stun.h
+9
-0
mod_verto.c
src/mod/endpoints/mod_verto/mod_verto.c
+2
-1
switch_stun.c
src/switch_stun.c
+73
-0
没有找到文件。
src/include/switch_stun.h
浏览文件 @
09941318
...
...
@@ -259,6 +259,15 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_priority(switch_stun_pa
SWITCH_DECLARE
(
switch_status_t
)
switch_stun_lookup
(
char
**
ip
,
switch_port_t
*
port
,
char
*
stunip
,
switch_port_t
stunport
,
char
**
err
,
switch_memory_pool_t
*
pool
);
/*!
\brief Perform a stun ip lookup
\param external_ip replaced with stun results
\param sourceip stun:, host: or an ip
\param external_pool the memory pool to use
\return SUCCESS or FAIL
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_stun_ip_lookup
(
char
**
external_ip
,
const
char
*
sourceip
,
switch_memory_pool_t
*
external_pool
);
/*!
\brief Obtain the padded length of an attribute's value
...
...
src/mod/endpoints/mod_verto/mod_verto.c
浏览文件 @
09941318
...
...
@@ -31,6 +31,7 @@
*/
#include <switch.h>
#include <switch_json.h>
#include <switch_stun.h>
/* Prototypes */
...
...
@@ -4824,7 +4825,7 @@ static switch_status_t parse_config(const char *cf)
if
(
zstr
(
val
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Invalid External RTP IP.
\n
"
);
}
else
{
profile
->
extrtpip
=
switch_core_strdup
(
profile
->
pool
,
va
l
);
switch_stun_ip_lookup
(
&
profile
->
extrtpip
,
val
,
profile
->
poo
l
);
}
}
else
if
(
!
strcasecmp
(
var
,
"debug"
))
{
if
(
val
)
{
...
...
src/switch_stun.c
浏览文件 @
09941318
...
...
@@ -851,6 +851,79 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
return
SWITCH_STATUS_FALSE
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_stun_ip_lookup
(
char
**
external_ip
,
const
char
*
sourceip
,
switch_memory_pool_t
*
external_pool
)
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
char
*
stun_ip
=
NULL
;
switch_port_t
stun_port
=
(
switch_port_t
)
SWITCH_STUN_DEFAULT_PORT
;
char
*
p
;
char
ip_buf
[
256
]
=
""
;
char
*
ip
=
NULL
;
switch_port_t
port
=
0
;
switch_memory_pool_t
*
local_pool
=
NULL
;
char
*
error
=
""
;
if
(
!
sourceip
||
!
external_pool
)
{
*
external_ip
=
NULL
;
goto
end
;
}
ip
=
ip_buf
;
if
(
!
strncasecmp
(
sourceip
,
"host:"
,
5
))
{
status
=
(
*
external_ip
=
switch_stun_host_lookup
(
sourceip
+
5
,
external_pool
))
?
SWITCH_STATUS_SUCCESS
:
SWITCH_STATUS_FALSE
;
}
else
if
(
!
strncasecmp
(
sourceip
,
"stun:"
,
5
))
{
switch_core_new_memory_pool
(
&
local_pool
);
stun_ip
=
switch_core_strdup
(
local_pool
,
sourceip
+
5
);
switch_assert
(
stun_ip
);
if
((
p
=
strchr
(
stun_ip
,
':'
)))
{
int
iport
;
*
p
++
=
'\0'
;
iport
=
atoi
(
p
);
if
(
iport
>
0
&&
iport
<
0xFFFF
)
{
stun_port
=
(
switch_port_t
)
iport
;
}
}
else
{
p
=
stun_ip
;
}
switch_find_local_ip
(
ip_buf
,
sizeof
(
ip_buf
),
NULL
,
AF_INET
);
if
(
zstr
(
stun_ip
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"STUN Failed! NO STUN SERVER
\n
"
);
}
else
{
if
((
switch_stun_lookup
(
&
ip
,
&
port
,
stun_ip
,
stun_port
,
&
error
,
local_pool
))
==
SWITCH_STATUS_SUCCESS
&&
ip
&&
port
)
{
*
external_ip
=
switch_core_strdup
(
external_pool
,
ip
);
status
=
SWITCH_STATUS_SUCCESS
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"External ip address detected using STUN: %s
\n
"
,
ip
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"STUN Failed! [%s]
\n
"
,
error
);
}
}
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
*
external_ip
=
""
;
}
switch_core_destroy_memory_pool
(
&
local_pool
);
}
else
{
*
external_ip
=
switch_core_strdup
(
external_pool
,
sourceip
);
status
=
SWITCH_STATUS_SUCCESS
;
}
end
:
return
status
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论