Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c5cd9819
提交
c5cd9819
authored
8月 01, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-6690 #resolve
上级
fb274514
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
1 行删除
+40
-1
mod_verto.c
src/mod/endpoints/mod_verto/mod_verto.c
+37
-1
mod_verto.h
src/mod/endpoints/mod_verto/mod_verto.h
+3
-0
没有找到文件。
src/mod/endpoints/mod_verto/mod_verto.c
浏览文件 @
c5cd9819
...
@@ -805,6 +805,23 @@ static void check_permissions(jsock_t *jsock, switch_xml_t x_user, cJSON *params
...
@@ -805,6 +805,23 @@ static void check_permissions(jsock_t *jsock, switch_xml_t x_user, cJSON *params
}
}
static
void
login_fire_custom_event
(
jsock_t
*
jsock
,
cJSON
*
params
,
int
success
,
const
char
*
result_txt
)
{
switch_event_t
*
s_event
;
if
(
switch_event_create_subclass
(
&
s_event
,
SWITCH_EVENT_CUSTOM
,
MY_EVENT_LOGIN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_profile_name"
,
jsock
->
profile
->
name
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_client_address"
,
jsock
->
name
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_login"
,
cJSON_GetObjectCstr
(
params
,
"login"
));
if
(
success
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_sessid"
,
cJSON_GetObjectCstr
(
params
,
"sessid"
));
}
switch_event_add_header
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_success"
,
"%d"
,
success
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_result_txt"
,
result_txt
);
switch_event_fire
(
&
s_event
);
}
}
static
switch_bool_t
check_auth
(
jsock_t
*
jsock
,
cJSON
*
params
,
int
*
code
,
char
*
message
,
switch_size_t
mlen
)
static
switch_bool_t
check_auth
(
jsock_t
*
jsock
,
cJSON
*
params
,
int
*
code
,
char
*
message
,
switch_size_t
mlen
)
{
{
switch_bool_t
r
=
SWITCH_FALSE
;
switch_bool_t
r
=
SWITCH_FALSE
;
...
@@ -827,6 +844,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
...
@@ -827,6 +844,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
if
(
zstr
(
passwd
))
{
if
(
zstr
(
passwd
))
{
*
code
=
CODE_AUTH_FAILED
;
*
code
=
CODE_AUTH_FAILED
;
switch_snprintf
(
message
,
mlen
,
"Missing passwd"
);
switch_snprintf
(
message
,
mlen
,
"Missing passwd"
);
login_fire_custom_event
(
jsock
,
params
,
0
,
"Missing passwd"
);
goto
end
;
goto
end
;
}
}
...
@@ -835,6 +853,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
...
@@ -835,6 +853,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
if
(
!
(
r
=
!
strcmp
(
passwd
,
jsock
->
profile
->
root_passwd
)))
{
if
(
!
(
r
=
!
strcmp
(
passwd
,
jsock
->
profile
->
root_passwd
)))
{
*
code
=
CODE_AUTH_FAILED
;
*
code
=
CODE_AUTH_FAILED
;
switch_snprintf
(
message
,
mlen
,
"Authentication Failure"
);
switch_snprintf
(
message
,
mlen
,
"Authentication Failure"
);
login_fire_custom_event
(
jsock
,
params
,
0
,
"Authentication Failure"
);
}
}
}
else
if
(
!
zstr
(
jsock
->
profile
->
userauth
))
{
}
else
if
(
!
zstr
(
jsock
->
profile
->
userauth
))
{
...
@@ -868,6 +887,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
...
@@ -868,6 +887,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
if
(
switch_xml_locate_user_merged
(
"id"
,
id
,
domain
,
NULL
,
&
x_user
,
req_params
)
!=
SWITCH_STATUS_SUCCESS
&&
!
jsock
->
profile
->
blind_reg
)
{
if
(
switch_xml_locate_user_merged
(
"id"
,
id
,
domain
,
NULL
,
&
x_user
,
req_params
)
!=
SWITCH_STATUS_SUCCESS
&&
!
jsock
->
profile
->
blind_reg
)
{
*
code
=
CODE_AUTH_FAILED
;
*
code
=
CODE_AUTH_FAILED
;
switch_snprintf
(
message
,
mlen
,
"Login Incorrect"
);
switch_snprintf
(
message
,
mlen
,
"Login Incorrect"
);
login_fire_custom_event
(
jsock
,
params
,
0
,
"Login Incorrect"
);
}
else
{
}
else
{
switch_xml_t
x_param
,
x_params
;
switch_xml_t
x_param
,
x_params
;
const
char
*
use_passwd
=
NULL
,
*
verto_context
=
NULL
,
*
verto_dialplan
=
NULL
;
const
char
*
use_passwd
=
NULL
,
*
verto_context
=
NULL
,
*
verto_dialplan
=
NULL
;
...
@@ -924,6 +944,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
...
@@ -924,6 +944,7 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
*
code
=
CODE_AUTH_FAILED
;
*
code
=
CODE_AUTH_FAILED
;
switch_snprintf
(
message
,
mlen
,
"Authentication Failure"
);
switch_snprintf
(
message
,
mlen
,
"Authentication Failure"
);
jsock
->
uid
=
NULL
;
jsock
->
uid
=
NULL
;
login_fire_custom_event
(
jsock
,
params
,
0
,
"Authentication Failure"
);
}
else
{
}
else
{
r
=
SWITCH_TRUE
;
r
=
SWITCH_TRUE
;
check_permissions
(
jsock
,
x_user
,
params
);
check_permissions
(
jsock
,
x_user
,
params
);
...
@@ -1345,6 +1366,8 @@ static void jsock_flush(jsock_t *jsock)
...
@@ -1345,6 +1366,8 @@ static void jsock_flush(jsock_t *jsock)
static
void
*
SWITCH_THREAD_FUNC
client_thread
(
switch_thread_t
*
thread
,
void
*
obj
)
static
void
*
SWITCH_THREAD_FUNC
client_thread
(
switch_thread_t
*
thread
,
void
*
obj
)
{
{
switch_event_t
*
s_event
;
jsock_t
*
jsock
=
(
jsock_t
*
)
obj
;
jsock_t
*
jsock
=
(
jsock_t
*
)
obj
;
switch_event_create
(
&
jsock
->
params
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_event_create
(
&
jsock
->
params
,
SWITCH_EVENT_CHANNEL_DATA
);
...
@@ -1380,6 +1403,11 @@ static void *SWITCH_THREAD_FUNC client_thread(switch_thread_t *thread, void *obj
...
@@ -1380,6 +1403,11 @@ static void *SWITCH_THREAD_FUNC client_thread(switch_thread_t *thread, void *obj
jsock_flush
(
jsock
);
jsock_flush
(
jsock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Ending client thread.
\n
"
,
jsock
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Ending client thread.
\n
"
,
jsock
->
name
);
if
(
switch_event_create_subclass
(
&
s_event
,
SWITCH_EVENT_CUSTOM
,
MY_EVENT_CLIENT_DISCONNECT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_profile_name"
,
jsock
->
profile
->
name
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_client_address"
,
jsock
->
name
);
switch_event_fire
(
&
s_event
);
}
switch_thread_rwlock_wrlock
(
jsock
->
rwlock
);
switch_thread_rwlock_wrlock
(
jsock
->
rwlock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Thread ended
\n
"
,
jsock
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Thread ended
\n
"
,
jsock
->
name
);
switch_thread_rwlock_unlock
(
jsock
->
rwlock
);
switch_thread_rwlock_unlock
(
jsock
->
rwlock
);
...
@@ -3028,6 +3056,8 @@ static switch_bool_t login_func(const char *method, cJSON *params, jsock_t *jsoc
...
@@ -3028,6 +3056,8 @@ static switch_bool_t login_func(const char *method, cJSON *params, jsock_t *jsoc
*
response
=
cJSON_CreateObject
();
*
response
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
*
response
,
"message"
,
cJSON_CreateString
(
"logged in"
));
cJSON_AddItemToObject
(
*
response
,
"message"
,
cJSON_CreateString
(
"logged in"
));
login_fire_custom_event
(
jsock
,
params
,
1
,
"Logged in"
);
return
SWITCH_TRUE
;
return
SWITCH_TRUE
;
}
}
...
@@ -3142,6 +3172,7 @@ static int start_jsock(verto_profile_t *profile, int sock)
...
@@ -3142,6 +3172,7 @@ static int start_jsock(verto_profile_t *profile, int sock)
jsock_type_t
ptype
=
PTYPE_CLIENT
;
jsock_type_t
ptype
=
PTYPE_CLIENT
;
switch_thread_data_t
*
td
;
switch_thread_data_t
*
td
;
switch_memory_pool_t
*
pool
;
switch_memory_pool_t
*
pool
;
switch_event_t
*
s_event
;
switch_core_new_memory_pool
(
&
pool
);
switch_core_new_memory_pool
(
&
pool
);
...
@@ -3173,7 +3204,12 @@ static int start_jsock(verto_profile_t *profile, int sock)
...
@@ -3173,7 +3204,12 @@ static int start_jsock(verto_profile_t *profile, int sock)
jsock
->
ptype
=
ptype
;
jsock
->
ptype
=
ptype
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Client Connect.
\n
"
,
jsock
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Client Connect.
\n
"
,
jsock
->
name
);
if
(
switch_event_create_subclass
(
&
s_event
,
SWITCH_EVENT_CUSTOM
,
MY_EVENT_CLIENT_CONNECT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_profile_name"
,
profile
->
name
);
switch_event_add_header
(
s_event
,
SWITCH_STACK_BOTTOM
,
"verto_client_address"
,
"%s:%d"
,
inet_ntoa
(
jsock
->
remote_addr
.
sin_addr
),
ntohs
(
jsock
->
remote_addr
.
sin_port
));
switch_event_fire
(
&
s_event
);
}
/* no nagle please */
/* no nagle please */
setsockopt
(
jsock
->
client_socket
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
flag
,
sizeof
(
flag
));
setsockopt
(
jsock
->
client_socket
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
flag
,
sizeof
(
flag
));
...
...
src/mod/endpoints/mod_verto/mod_verto.h
浏览文件 @
c5cd9819
...
@@ -67,6 +67,9 @@
...
@@ -67,6 +67,9 @@
#define CODE_AUTH_FAILED -32001
#define CODE_AUTH_FAILED -32001
#define CODE_SESSION_ERROR -32002
#define CODE_SESSION_ERROR -32002
#define MY_EVENT_CLIENT_CONNECT "verto::client_connect"
#define MY_EVENT_CLIENT_DISCONNECT "verto::client_disconnect"
#define MY_EVENT_LOGIN "verto::login"
typedef
enum
{
typedef
enum
{
PTYPE_CLIENT
=
(
1
<<
0
),
PTYPE_CLIENT
=
(
1
<<
0
),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论