diff --git a/server/WebHook.cpp b/server/WebHook.cpp index c185444b..23fd7c4a 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -625,7 +625,11 @@ void installWebHook() { if (!hook_enable || hook_http_access.empty()) { // 未开启http文件访问鉴权,那么允许访问,但是每次访问都要鉴权; // 因为后续随时都可能开启鉴权(重载配置文件后可能重新开启鉴权) - invoker("", "", 0); + if (!HttpFileManager::isIPAllowed(sender.get_peer_ip())) { + invoker("Your ip is not allowed to access the service.", "", 0); + } else { + invoker("", "", 0); + } return; } diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index cd3ca62c..52f8fabd 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -382,11 +382,6 @@ static void canAccessPath(Session &sender, const Parser &parser, const MediaInfo return; } - if (!HttpFileManager::isIPAllowed(sender.get_peer_ip())) { - callback("Your ip is not allowed to access the service.", nullptr); - return; - } - // 事件未被拦截,则认为是http下载请求 bool flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpAccess, parser, path, is_dir, accessPathInvoker, static_cast(sender)); if (!flag) {