Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-12-07 10:15:08 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fba11228351200d0c6d5a0895d1a991a16893463
fba11228
1 parent
17bb31ca
private the srs_vhost_resolve
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
40 行增加
和
77 行删除
trunk/src/protocol/srs_protocol_utility.cpp
trunk/src/protocol/srs_protocol_utility.hpp
trunk/src/utest/srs_utest_protocol.cpp
trunk/src/protocol/srs_protocol_utility.cpp
查看文件 @
fba1122
...
...
@@ -41,6 +41,46 @@ using namespace std;
#include <srs_rtmp_stack.hpp>
#include <srs_protocol_io.hpp>
/**
* resolve the vhost in query string
* @pram vhost, update the vhost if query contains the vhost.
* @param app, may contains the vhost in query string format:
* app?vhost=request_vhost
* app...vhost...request_vhost
* @param param, the query, for example, ?vhost=xxx
*/
void
srs_vhost_resolve
(
string
&
vhost
,
string
&
app
,
string
&
param
)
{
// get original param
size_t
pos
=
0
;
if
((
pos
=
app
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
param
=
app
.
substr
(
pos
);
}
// filter tcUrl
app
=
srs_string_replace
(
app
,
","
,
"?"
);
app
=
srs_string_replace
(
app
,
"..."
,
"?"
);
app
=
srs_string_replace
(
app
,
"&&"
,
"?"
);
app
=
srs_string_replace
(
app
,
"="
,
"?"
);
if
((
pos
=
app
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
std
::
string
query
=
app
.
substr
(
pos
+
1
);
app
=
app
.
substr
(
0
,
pos
);
if
((
pos
=
query
.
find
(
"vhost?"
))
!=
std
::
string
::
npos
)
{
query
=
query
.
substr
(
pos
+
6
);
if
(
!
query
.
empty
())
{
vhost
=
query
;
}
if
((
pos
=
vhost
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
vhost
=
vhost
.
substr
(
0
,
pos
);
}
}
}
/* others */
}
void
srs_discovery_tc_url
(
string
tcUrl
,
string
&
schema
,
string
&
host
,
string
&
vhost
,
...
...
@@ -77,38 +117,6 @@ void srs_discovery_tc_url(
srs_vhost_resolve
(
vhost
,
app
,
param
);
}
void
srs_vhost_resolve
(
string
&
vhost
,
string
&
app
,
string
&
param
)
{
// get original param
size_t
pos
=
0
;
if
((
pos
=
app
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
param
=
app
.
substr
(
pos
);
}
// filter tcUrl
app
=
srs_string_replace
(
app
,
","
,
"?"
);
app
=
srs_string_replace
(
app
,
"..."
,
"?"
);
app
=
srs_string_replace
(
app
,
"&&"
,
"?"
);
app
=
srs_string_replace
(
app
,
"="
,
"?"
);
if
((
pos
=
app
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
std
::
string
query
=
app
.
substr
(
pos
+
1
);
app
=
app
.
substr
(
0
,
pos
);
if
((
pos
=
query
.
find
(
"vhost?"
))
!=
std
::
string
::
npos
)
{
query
=
query
.
substr
(
pos
+
6
);
if
(
!
query
.
empty
())
{
vhost
=
query
;
}
if
((
pos
=
vhost
.
find
(
"?"
))
!=
std
::
string
::
npos
)
{
vhost
=
vhost
.
substr
(
0
,
pos
);
}
}
}
/* others */
}
void
srs_random_generate
(
char
*
bytes
,
int
size
)
{
static
bool
_random_initialized
=
false
;
...
...
trunk/src/protocol/srs_protocol_utility.hpp
查看文件 @
fba1122
...
...
@@ -63,18 +63,6 @@ extern void srs_discovery_tc_url(
);
/**
* resolve the vhost in query string
* @pram vhost, update the vhost if query contains the vhost.
* @param app, may contains the vhost in query string format:
* app?vhost=request_vhost
* app...vhost...request_vhost
* @param param, the query, for example, ?vhost=xxx
*/
extern
void
srs_vhost_resolve
(
std
::
string
&
vhost
,
std
::
string
&
app
,
std
::
string
&
param
);
/**
* generate ramdom data for handshake.
*/
extern
void
srs_random_generate
(
char
*
bytes
,
int
size
);
...
...
trunk/src/utest/srs_utest_protocol.cpp
查看文件 @
fba1122
...
...
@@ -424,39 +424,6 @@ VOID TEST(ProtocolHandshakeTest, BytesEqual)
}
/**
* resolve vhost from tcUrl.
*/
VOID
TEST
(
ProtocolUtilityTest
,
VhostResolve
)
{
std
::
string
vhost
=
"vhost"
;
std
::
string
app
=
"app"
;
std
::
string
param
;
srs_vhost_resolve
(
vhost
,
app
,
param
);
EXPECT_STREQ
(
"vhost"
,
vhost
.
c_str
());
EXPECT_STREQ
(
"app"
,
app
.
c_str
());
app
=
"app?vhost=changed"
;
srs_vhost_resolve
(
vhost
,
app
,
param
);
EXPECT_STREQ
(
"changed"
,
vhost
.
c_str
());
EXPECT_STREQ
(
"app"
,
app
.
c_str
());
app
=
"app?vhost=changed1&&query=true"
;
srs_vhost_resolve
(
vhost
,
app
,
param
);
EXPECT_STREQ
(
"changed1"
,
vhost
.
c_str
());
EXPECT_STREQ
(
"app"
,
app
.
c_str
());
app
=
"app?other=true&&vhost=changed2&&query=true"
;
srs_vhost_resolve
(
vhost
,
app
,
param
);
EXPECT_STREQ
(
"changed2"
,
vhost
.
c_str
());
EXPECT_STREQ
(
"app"
,
app
.
c_str
());
app
=
"app...other...true...vhost...changed3...query...true"
;
srs_vhost_resolve
(
vhost
,
app
,
param
);
EXPECT_STREQ
(
"changed3"
,
vhost
.
c_str
());
EXPECT_STREQ
(
"app"
,
app
.
c_str
());
}
/**
* discovery tcUrl to schema/vhost/host/port/app
*/
VOID
TEST
(
ProtocolUtilityTest
,
DiscoveryTcUrl
)
...
...
请
注册
或
登录
后发表评论