mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Config: Support overwrote by environment variables. (#3197)
* Support overwrite by environment virable. * modify duplicated code * Config: Add stat for envrionment config. * Config: Fix utest fail. Co-authored-by: pengfei.ma <pengfei.ma@ctechm.com> Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
dc20d5ddbc
commit
eb04f92176
8 changed files with 474 additions and 84 deletions
|
@ -1421,7 +1421,7 @@ string srs_string_dumps_hex(const char* str, int length, int limit, char seperat
|
|||
return string(buf, len);
|
||||
}
|
||||
|
||||
string srs_getenv(string key)
|
||||
string srs_getenv(const string& key)
|
||||
{
|
||||
string ekey = key;
|
||||
if (srs_string_starts_with(key, "$")) {
|
||||
|
@ -1432,6 +1432,15 @@ string srs_getenv(string key)
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string::iterator it;
|
||||
for (it = ekey.begin(); it != ekey.end(); ++it) {
|
||||
if (*it >= 'a' && *it <= 'z') {
|
||||
*it += ('A' - 'a');
|
||||
} else if (*it == '.') {
|
||||
*it = '_';
|
||||
}
|
||||
}
|
||||
|
||||
char* value = ::getenv(ekey.c_str());
|
||||
if (value) {
|
||||
return value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue