Add InnerIpFilter

This commit is contained in:
antao 2018-08-31 16:38:46 +08:00
parent 1011d5211d
commit 2ad97c5f56
4 changed files with 60 additions and 1 deletions

View File

@ -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>

View 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
View 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);
}

@ -1 +1 @@
Subproject commit 67655a6e1676abb85fc6386dd9f6ad1a50bd04b3
Subproject commit d2d5c669083047ca43a7dbf849211b808dca92fb