mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
本机范围http api不需要secret
This commit is contained in:
parent
3f51e9aed2
commit
1610bd2415
@ -25,7 +25,8 @@ using namespace mediakit;
|
|||||||
typedef map<string,variant,StrCaseCompare> ApiArgsType;
|
typedef map<string,variant,StrCaseCompare> ApiArgsType;
|
||||||
|
|
||||||
|
|
||||||
#define API_ARGS HttpSession::KeyValue &headerIn, \
|
#define API_ARGS TcpSession &sender, \
|
||||||
|
HttpSession::KeyValue &headerIn, \
|
||||||
HttpSession::KeyValue &headerOut, \
|
HttpSession::KeyValue &headerOut, \
|
||||||
ApiArgsType &allArgs, \
|
ApiArgsType &allArgs, \
|
||||||
Json::Value &val
|
Json::Value &val
|
||||||
@ -33,7 +34,7 @@ typedef map<string,variant,StrCaseCompare> ApiArgsType;
|
|||||||
#define API_REGIST(field, name, ...) \
|
#define API_REGIST(field, name, ...) \
|
||||||
s_map_api.emplace("/index/"#field"/"#name,[](API_ARGS,const HttpSession::HttpResponseInvoker &invoker){ \
|
s_map_api.emplace("/index/"#field"/"#name,[](API_ARGS,const HttpSession::HttpResponseInvoker &invoker){ \
|
||||||
static auto lam = [&](API_ARGS) __VA_ARGS__ ; \
|
static auto lam = [&](API_ARGS) __VA_ARGS__ ; \
|
||||||
lam(headerIn, headerOut, allArgs, val); \
|
lam(sender,headerIn, headerOut, allArgs, val); \
|
||||||
invoker("200 OK", headerOut, val.toStyledString()); \
|
invoker("200 OK", headerOut, val.toStyledString()); \
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ static inline void addHttpListener(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
it->second(headerIn, headerOut, allArgs, val, invoker);
|
it->second(sender,headerIn, headerOut, allArgs, val, invoker);
|
||||||
} catch(ApiRetException &ex){
|
} catch(ApiRetException &ex){
|
||||||
val["code"] = ex.code();
|
val["code"] = ex.code();
|
||||||
val["msg"] = ex.what();
|
val["msg"] = ex.what();
|
||||||
@ -202,12 +203,13 @@ bool checkArgs(Args &&args,First &&first,KeyTypes && ...keys){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_SECRET() \
|
#define CHECK_SECRET() \
|
||||||
CHECK_ARGS("secret"); \
|
if(sender.get_peer_ip() != "127.0.0.1"){ \
|
||||||
if(api_secret != allArgs["secret"]){ \
|
CHECK_ARGS("secret"); \
|
||||||
throw AuthException("secret错误"); \
|
if(api_secret != allArgs["secret"]){ \
|
||||||
|
throw AuthException("secret错误"); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unordered_map<string ,PlayerProxy::Ptr> s_proxyMap;
|
static unordered_map<string ,PlayerProxy::Ptr> s_proxyMap;
|
||||||
static recursive_mutex s_proxyMapMtx;
|
static recursive_mutex s_proxyMapMtx;
|
||||||
static inline string getProxyKey(const string &vhost,const string &app,const string &stream){
|
static inline string getProxyKey(const string &vhost,const string &app,const string &stream){
|
||||||
|
Loading…
Reference in New Issue
Block a user