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-08-30 07:59:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6bd05f9cfcdb4e4f9de7beb7a7c148897d54676e
6bd05f9c
1 parent
bc24c040
for #319, refine the config forward.
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
119 行增加
和
45 行删除
trunk/conf/demo.conf
trunk/conf/forward.master.conf
trunk/conf/full.conf
trunk/conf/full.one.vhost.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_source.cpp
trunk/conf/demo.conf
查看文件 @
6bd05f9
...
...
@@ -44,7 +44,10 @@ vhost demo.srs.com {
enabled
on
;
gop_cache
on
;
queue_length
30
;
forward
127
.
0
.
0
.
1
:
19350
;
forward
{
enabled
on
;
destination
127
.
0
.
0
.
1
:
19350
;
}
bandcheck
{
enabled
off
;
}
...
...
trunk/conf/forward.master.conf
查看文件 @
6bd05f9
...
...
@@ -8,5 +8,8 @@ pid ./objs/srs.master.pid;
srs_log_tank
file
;
srs_log_file
./
objs
/
srs
.
master
.
log
;
vhost
__
defaultVhost__
{
forward
127
.
0
.
0
.
1
:
19350
;
forward
{
enabled
on
;
destination
127
.
0
.
0
.
1
:
19350
;
}
}
...
...
trunk/conf/full.conf
查看文件 @
6bd05f9
...
...
@@ -268,33 +268,6 @@ vhost removed.srs.com {
# @see scope.vhost.srs.com
enabled
off
;
}
# the vhost for antisuck.
vhost
refer
.
anti_suck
.
com
{
# refer hotlink-denial.
...
...
@@ -534,13 +507,47 @@ vhost stream.control.com {
# the vhost which forward publish streams.
vhost
same
.
vhost
.
forward
.
srs
.
com
{
# forward all publish stream to the specified server.
# this used to split/forward the current stream for cluster active-standby,
# active-active for cdn to build high available fault tolerance system.
# format: {ip}:{port} {ip_N}:{port_N}
forward
127
.
0
.
0
.
1
:
1936
127
.
0
.
0
.
1
:
1937
;
# forward stream to other servers.
forward
{
# whether enable the forward.
# default: off
enabled
on
;
# forward all publish stream to the specified server.
# this used to split/forward the current stream for cluster active-standby,
# active-active for cdn to build high available fault tolerance system.
# format: {ip}:{port} {ip_N}:{port_N}
destination
127
.
0
.
0
.
1
:
1936
127
.
0
.
0
.
1
:
1937
;
}
}
# the vhost for exec, fork process when publish stream.
vhost
exec
.
srs
.
com
{
# the exec used to fork process when got some event.
...
...
trunk/conf/full.one.vhost.conf
查看文件 @
6bd05f9
...
...
@@ -62,8 +62,8 @@ vhost vhost.srs.com {
debug_srs_upnode
off
;
}
# TODO
forward
{
enabled
off
;
destination
127
.
0
.
0
.
1
:
1936
127
.
0
.
0
.
1
:
1937
;
}
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
6bd05f9
...
...
@@ -1575,7 +1575,7 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj)
sobj
->
set
(
"exec"
,
SrsAmf0Any
::
boolean
(
get_exec_enabled
(
dir
->
name
)));
sobj
->
set
(
"bandcheck"
,
SrsAmf0Any
::
boolean
(
get_bw_check_enabled
(
dir
->
name
)));
sobj
->
set
(
"origin"
,
SrsAmf0Any
::
boolean
(
!
get_vhost_is_edge
(
dir
->
name
)));
sobj
->
set
(
"forward"
,
SrsAmf0Any
::
boolean
(
get_forward
(
dir
->
name
)));
sobj
->
set
(
"forward"
,
SrsAmf0Any
::
boolean
(
get_forward
_enabled
(
dir
->
name
)));
sobj
->
set
(
"security"
,
SrsAmf0Any
::
boolean
(
get_security_enabled
(
dir
->
name
)));
sobj
->
set
(
"refer"
,
SrsAmf0Any
::
boolean
(
get_refer_enabled
(
dir
->
name
)));
...
...
@@ -1679,7 +1679,18 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
// forward
if
((
dir
=
vhost
->
get
(
"forward"
))
!=
NULL
)
{
obj
->
set
(
"forward"
,
dir
->
dumps_args
());
SrsAmf0Object
*
forward
=
SrsAmf0Any
::
object
();
obj
->
set
(
"forward"
,
forward
);
for
(
int
i
=
0
;
i
<
(
int
)
dir
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
sdir
=
dir
->
directives
.
at
(
i
);
if
(
sdir
->
name
==
"enabled"
)
{
forward
->
set
(
"enabled"
,
sdir
->
dumps_arg0_to_boolean
());
}
else
if
(
sdir
->
name
==
"destination"
)
{
forward
->
set
(
"destination"
,
sdir
->
dumps_args
());
}
}
}
// debug_srs_upnode
...
...
@@ -2705,15 +2716,14 @@ int SrsConfig::check_config()
}
}
}
else
if
(
n
==
"forward"
)
{
// TODO: FIXME: implements it.
/*for (int j = 0; j < (int)conf->directives.size(); j++) {
for
(
int
j
=
0
;
j
<
(
int
)
conf
->
directives
.
size
();
j
++
)
{
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if (m != "enabled" && m != "
vhost" && m != "refer
") {
if
(
m
!=
"enabled"
&&
m
!=
"
destination
"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost forward directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
}
}
*/
}
}
else
if
(
n
==
"security"
)
{
for
(
int
j
=
0
;
j
<
(
int
)
conf
->
directives
.
size
();
j
++
)
{
SrsConfDirective
*
security
=
conf
->
at
(
j
);
...
...
@@ -3581,14 +3591,41 @@ int SrsConfig::get_global_chunk_size()
return
::
atoi
(
conf
->
arg0
().
c_str
());
}
SrsConfDirective
*
SrsConfig
::
get_forwar
d
(
string
vhost
)
bool
SrsConfig
::
get_forward_enable
d
(
string
vhost
)
{
static
bool
DEFAULT
=
false
;
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
DEFAULT
;
}
conf
=
conf
->
get
(
"forward"
);
if
(
!
conf
)
{
return
DEFAULT
;
}
conf
=
conf
->
get
(
"enabled"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
DEFAULT
;
}
return
SRS_CONF_PERFER_FALSE
(
conf
->
arg0
());
}
SrsConfDirective
*
SrsConfig
::
get_forwards
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
NULL
;
}
conf
=
conf
->
get
(
"forward"
);
if
(
!
conf
)
{
return
NULL
;
}
return
conf
->
get
(
"
forward
"
);
return
conf
->
get
(
"
destination
"
);
}
SrsConfDirective
*
SrsConfig
::
get_vhost_http_hooks
(
string
vhost
)
...
...
@@ -5774,6 +5811,22 @@ int srs_config_transform_vhost(SrsConfDirective* root)
continue
;
}
// SRS3.0, change the forward.
// SRS1/2:
// vhost { forward; }
// SRS3+:
// vhost { forward { enabled; destination; } }
if
(
n
==
"forward"
)
{
conf
->
get_or_create
(
"enabled"
,
"on"
);
SrsConfDirective
*
destination
=
conf
->
get_or_create
(
"destination"
);
destination
->
args
=
conf
->
args
;
conf
->
args
.
clear
();
++
it
;
continue
;
}
++
it
;
}
}
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
6bd05f9
...
...
@@ -599,9 +599,13 @@ private:
// forward section
public:
/**
* whether the forwarder enabled.
*/
virtual
bool
get_forward_enabled
(
std
::
string
vhost
);
/**
* get the forward directive of vhost.
*/
virtual
SrsConfDirective
*
get_forward
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_forward
s
(
std
::
string
vhost
);
// http_hooks section
private:
/**
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
6bd05f9
...
...
@@ -2235,7 +2235,11 @@ int SrsSource::create_forwarders()
{
int
ret
=
ERROR_SUCCESS
;
SrsConfDirective
*
conf
=
_srs_config
->
get_forward
(
_req
->
vhost
);
if
(
_srs_config
->
get_forward_enabled
(
_req
->
vhost
))
{
return
ret
;
}
SrsConfDirective
*
conf
=
_srs_config
->
get_forwards
(
_req
->
vhost
);
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
args
.
size
();
i
++
)
{
std
::
string
forward_server
=
conf
->
args
.
at
(
i
);
...
...
请
注册
或
登录
后发表评论