mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 11:47:56 +08:00
Add InnerIpFilter
This commit is contained in:
parent
1011d5211d
commit
2ad97c5f56
@ -25,6 +25,7 @@
|
||||
#include <drogon/PutFilter.h>
|
||||
#include <drogon/DeleteFilter.h>
|
||||
#include <drogon/LocalHostFilter.h>
|
||||
#include <drogon/InnerIpFilter.h>
|
||||
#include <drogon/version.h>
|
||||
#include <drogon/NotFound.h>
|
||||
#include <drogon/HttpClient.h>
|
||||
|
29
lib/inc/drogon/InnerIpFilter.h
Normal file
29
lib/inc/drogon/InnerIpFilter.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drogon/HttpFilter.h>
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
class InnerIpFilter:public HttpFilter<InnerIpFilter>
|
||||
{
|
||||
public:
|
||||
InnerIpFilter(){}
|
||||
virtual void doFilter(const HttpRequestPtr& req,
|
||||
const FilterCallback &fcb,
|
||||
const FilterChainCallback &fccb) override ;
|
||||
};
|
||||
}
|
29
lib/src/InnerIpFilter.cc
Normal file
29
lib/src/InnerIpFilter.cc
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/InnerIpFilter.h>
|
||||
#include "HttpResponseImpl.h"
|
||||
using namespace drogon;
|
||||
void InnerIpFilter::doFilter(const HttpRequestPtr& req,
|
||||
const FilterCallback &fcb,
|
||||
const FilterChainCallback &fccb)
|
||||
{
|
||||
if(req->peerAddr().isInnerIp())
|
||||
{
|
||||
fccb();
|
||||
return;
|
||||
}
|
||||
auto res=drogon::HttpResponse::newNotFoundResponse();
|
||||
fcb(res);
|
||||
}
|
2
trantor
2
trantor
@ -1 +1 @@
|
||||
Subproject commit 67655a6e1676abb85fc6386dd9f6ad1a50bd04b3
|
||||
Subproject commit d2d5c669083047ca43a7dbf849211b808dca92fb
|
Loading…
Reference in New Issue
Block a user