mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-16 13:05:59 +08:00
增加http代理功能 (#2988)
支持通过http代理拉流, 避免内外网复杂网络环境时需要专门配置防火墙,现在只需要配置一台代理内网的服务器. --------- Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <cinttypes>
|
||||
#include "Parser.h"
|
||||
#include "strCoding.h"
|
||||
#include "macros.h"
|
||||
#include "Util/base64.h"
|
||||
#include "Network/sockutil.h"
|
||||
#include "Common/macros.h"
|
||||
|
||||
@@ -325,6 +325,25 @@ void splitUrl(const std::string &url, std::string &host, uint16_t &port) {
|
||||
host = url.substr(0, pos);
|
||||
checkHost(host);
|
||||
}
|
||||
|
||||
void parseProxyUrl(const std::string &proxy_url, std::string &proxy_host, uint16_t &proxy_port, std::string &proxy_auth) {
|
||||
// 判断是否包含http://, 如果是则去掉
|
||||
std::string host;
|
||||
auto pos = proxy_url.find("://");
|
||||
if (pos != string::npos) {
|
||||
host = proxy_url.substr(pos + 3);
|
||||
} else {
|
||||
host = proxy_url;
|
||||
}
|
||||
// 判断是否包含用户名和密码
|
||||
pos = host.rfind('@');
|
||||
if (pos != string::npos) {
|
||||
proxy_auth = encodeBase64(host.substr(0, pos));
|
||||
host = host.substr(pos + 1, host.size());
|
||||
}
|
||||
splitUrl(host, proxy_host, proxy_port);
|
||||
}
|
||||
|
||||
#if 0
|
||||
//测试代码
|
||||
static onceToken token([](){
|
||||
|
||||
Reference in New Issue
Block a user