Table of Contents

Class IpBanner

Namespace
Dynamicweb.SystemTools.Security
Assembly
Dynamicweb.dll

Handling banning of IP's

public class IpBanner
Inheritance
IpBanner
Inherited Members

Methods

BanIp(string, DateTime)

Bans the specified IP for till the specified expiration time.

public static void BanIp(string ip, DateTime banExpiration)

Parameters

ip string

The ip to ban.

banExpiration DateTime

The ban expiration datetime.

BanIp(string, DateTime, string)

Bans the specified IP for till the specified expiration time.

public static void BanIp(string ip, DateTime banExpiration, string cause)

Parameters

ip string

The ip to ban. Use GetClientIpAddress() to handle forward IPs

banExpiration DateTime

The ban expiration datetime.

cause string

BanIp(string, string)

public static void BanIp(string ip, string cause)

Parameters

ip string
cause string

GetClientIpAddress()

Gets the client ip address either from X_FORWARDED_FOR or X-CLIENT-IP header or UserHostAddress of the request.

public static string? GetClientIpAddress()

Returns

string

An ip address. If X_FORWARDED_FOR or X-CLIENT-IP header contains a value of more IPs, the string is analyzed from the right and returns the first instance that is not a private IP (192.168./10./172.16.-172.32./169.254.*)

IsBanned(string)

Determines whether the specified ip is banned.

public static bool IsBanned(string ip)

Parameters

ip string

The ip.

Returns

bool

true if the specified ip is banned; otherwise, false.

IsPrivateIpAddress(string)

public static bool IsPrivateIpAddress(string ipAddress1)

Parameters

ipAddress1 string

Returns

bool

IsWhitelistIpAddress(string)

public static bool IsWhitelistIpAddress(string ipAddress1)

Parameters

ipAddress1 string

Returns

bool
To top