This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- main | |
pool: | |
vmImage: ubuntu-latest | |
steps: | |
- checkout: self | |
submodules: true | |
- task: AzureStaticWebApp@0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Determine whether a given The <see cref="IPAddress"/> is part of the IP network. | |
/// </summary> | |
/// <param name="address">The <see cref="IPAddress"/>.</param> | |
/// <returns><see langword="true"/> if the <see cref="IPAddress"/> is part of the IP network. Otherwise, <see langword="false"/>.</returns> | |
public bool Contains(IPAddress address) | |
{ | |
if (Prefix.AddressFamily != address.AddressFamily) | |
{ | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Mvc.Filters; | |
using System.Net; | |
namespace DotNetIpFilter.Services | |
{ | |
/// <summary> | |
/// IpActionFilter | |
/// </summary> | |
public class IpActionFilter : ActionFilterAttribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using NSubstitute; | |
using Microsoft.Extensions.Logging; | |
using DotNetIpFilter.Services; | |
using Microsoft.AspNetCore.Mvc.ModelBinding; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Routing; | |
using Microsoft.AspNetCore.Mvc.Abstractions; | |
using Microsoft.AspNetCore.Mvc.Filters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DotNetIpFilter.Services; | |
using Microsoft.AspNetCore.Mvc; | |
namespace DotNetIpFilter.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
[ServiceFilter(typeof(IpActionFilter))] | |
public class WeatherForecastController : ControllerBase | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DotNetIpFilter.Services; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddControllers(); | |
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | |
builder.Services.AddEndpointsApiExplorer(); | |
builder.Services.AddSwaggerGen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNetIpFilter.Services | |
{ | |
/// <summary> | |
/// IpHostedService | |
/// </summary> | |
public class IpHostedService: IHostedService | |
{ | |
/// <summary> | |
/// The service provider | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNetIpFilter.Services | |
{ | |
/// <summary> | |
/// IIpFilterService | |
/// </summary> | |
public interface IIpFilterService | |
{ | |
/// <summary> | |
/// GetAdminSafeIpList | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DotNetIpFilter.Services | |
{ | |
/// <summary> | |
/// IpFilterService | |
/// </summary> | |
public class IpFilterService : IIpFilterService | |
{ | |
/// <summary> | |
/// Logger | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Mvc.Filters; | |
using System.Net; | |
namespace DotNetIpFilter.Services | |
{ | |
/// <summary> | |
/// IpActionFilter | |
/// </summary> | |
public class IpActionFilter : ActionFilterAttribute |
NewerOlder