mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #319, support enable or disable vhost.
This commit is contained in:
parent
631e76cd32
commit
e8a00de4a3
3 changed files with 93 additions and 10 deletions
|
|
@ -721,16 +721,9 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
|
|||
|
||||
// ENABLED => DISABLED
|
||||
if (get_vhost_enabled(old_vhost) && !get_vhost_enabled(new_vhost)) {
|
||||
srs_trace("vhost %s removed, reload it.", vhost.c_str());
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_vhost_removed(vhost)) != ERROR_SUCCESS) {
|
||||
srs_error("notify subscribes removed "
|
||||
"vhost %s failed. ret=%d", vhost.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
if ((ret = do_reload_vhost_removed(vhost)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
srs_trace("reload removed vhost %s success.", vhost.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2514,6 +2507,42 @@ int SrsConfig::raw_delete_vhost(string vhost, bool& applied)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::raw_disable_vhost(string vhost, bool& applied)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
applied = false;
|
||||
|
||||
SrsConfDirective* conf = root->get("vhost", vhost);
|
||||
conf->get_or_create("enabled")->set_arg0("off");
|
||||
|
||||
if ((ret = do_reload_vhost_removed(vhost)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
applied = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::raw_enable_vhost(string vhost, bool& applied)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
applied = false;
|
||||
|
||||
SrsConfDirective* conf = root->get("vhost", vhost);
|
||||
conf->get_or_create("enabled")->set_arg0("on");
|
||||
|
||||
if ((ret = do_reload_vhost_added(vhost)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
applied = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::do_reload_listen()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
|
@ -2670,6 +2699,26 @@ int SrsConfig::do_reload_vhost_added(string vhost)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsConfig::do_reload_vhost_removed(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
srs_trace("vhost %s removed, reload it.", vhost.c_str());
|
||||
|
||||
vector<ISrsReloadHandler*>::iterator it;
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_vhost_removed(vhost)) != ERROR_SUCCESS) {
|
||||
srs_error("notify subscribes removed "
|
||||
"vhost %s failed. ret=%d", vhost.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
srs_trace("reload removed vhost %s success.", vhost.c_str());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
string SrsConfig::config()
|
||||
{
|
||||
return config_file;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue