完善ipv6支持

This commit is contained in:
ziyue 2022-05-08 17:06:10 +08:00
parent a44334acaf
commit d037acbf62
4 changed files with 6 additions and 12 deletions

@ -1 +1 @@
Subproject commit d6034e7e3572bcd557fd88438c10b98c5fabdd13 Subproject commit d743ea7facdd643d7732c0f82f0fd6467380ea8c

View File

@ -155,7 +155,7 @@ API_EXPORT const char* API_CALL mk_media_info_get_host(const mk_media_info ctx){
API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx){ API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx){
assert(ctx); assert(ctx);
MediaInfo *info = (MediaInfo *)ctx; MediaInfo *info = (MediaInfo *)ctx;
return std::stoi(info->_port); return info->_port;
} }
API_EXPORT const char* API_CALL mk_media_info_get_app(const mk_media_info ctx){ API_EXPORT const char* API_CALL mk_media_info_get_app(const mk_media_info ctx){

View File

@ -506,14 +506,8 @@ void MediaInfo::parse(const string &url_in){
} }
auto split_vec = split(url.substr(schema_pos + 3), "/"); auto split_vec = split(url.substr(schema_pos + 3), "/");
if (split_vec.size() > 0) { if (split_vec.size() > 0) {
auto vhost = split_vec[0]; splitUrl(split_vec[0], _host, _port);
auto pos = vhost.find(":"); _vhost = _host;
if (pos != string::npos) {
_host = _vhost = vhost.substr(0, pos);
_port = vhost.substr(pos + 1);
} else {
_host = _vhost = vhost;
}
if (_vhost == "localhost" || isIP(_vhost.data())) { if (_vhost == "localhost" || isIP(_vhost.data())) {
//如果访问的是localhost或ip那么则为默认虚拟主机 //如果访问的是localhost或ip那么则为默认虚拟主机
_vhost = DEFAULT_VHOST; _vhost = DEFAULT_VHOST;

View File

@ -159,7 +159,7 @@ public:
std::string _full_url; std::string _full_url;
std::string _schema; std::string _schema;
std::string _host; std::string _host;
std::string _port; uint16_t _port = 0;
std::string _vhost; std::string _vhost;
std::string _app; std::string _app;
std::string _streamid; std::string _streamid;