IPv6 support v1.0
Server: Added IPv6 support for all DNS Providers, but only tested ISC BIND & MS DNS Enterprise Server: Added support for IPv6. Hyper-V not tested, and probably doesn't work. When using IPv6 with Hyper-V it assigns "/CIDR" to the subnet mask, and I don't know if this is the correct implementation. Portal: Modified all IP input masks to accept and validate IPv6. IP Ranges support IP/CIDR format.
This commit is contained in:
parent
90219f284f
commit
c4a1b5f4d6
44 changed files with 3221 additions and 247 deletions
|
@ -1,8 +1,5 @@
|
|||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditIPAddressControl.ascx.cs" Inherits="WebsitePanel.Portal.UserControls.EditIPAddressControl" %>
|
||||
<asp:TextBox ID="txtAddress" runat="server" Width="110px" MaxLength="15" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:TextBox ID="txtAddress" runat="server" Width="260px" MaxLength="45" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="requireAddressValidator" runat="server" meta:resourcekey="requireAddressValidator"
|
||||
ControlToValidate="txtAddress" SetFocusOnError="true" Text="*" Enabled="false" Display="Dynamic">
|
||||
</asp:RequiredFieldValidator><asp:RegularExpressionValidator id="addressValidator" runat="server"
|
||||
ValidationExpression="^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$"
|
||||
Display="Dynamic" SetFocusOnError="true" ControlToValidate="txtAddress" Text="*" meta:resourcekey="addressValidator">
|
||||
</asp:RegularExpressionValidator>
|
||||
ControlToValidate="txtAddress" SetFocusOnError="true" Text="*" Enabled="false" Display="Dynamic" />
|
||||
<asp:CustomValidator ID="addressValidator" runat="server" ControlToValidate="txtAddress" OnServerValidate="Validate" Text="*" meta:resourcekey="addressValidator"/>
|
|
@ -34,8 +34,16 @@ using System.Web.UI.WebControls;
|
|||
|
||||
namespace WebsitePanel.Portal.UserControls
|
||||
{
|
||||
[Flags]
|
||||
public enum IPValidationMode { V4 = 1, V6 = 2, V4AndV6 = 3 };
|
||||
|
||||
public partial class EditIPAddressControl : WebsitePanelControlBase
|
||||
{
|
||||
|
||||
public IPValidationMode Validation { get; set; }
|
||||
|
||||
public EditIPAddressControl() { Validation = IPValidationMode.V4AndV6; AllowSubnet = false; }
|
||||
|
||||
public bool Required
|
||||
{
|
||||
get { return requireAddressValidator.Enabled; }
|
||||
|
@ -86,5 +94,30 @@ namespace WebsitePanel.Portal.UserControls
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public bool AllowSubnet { get; set; }
|
||||
public bool IsV6 { get; private set; }
|
||||
public bool IsMask { get; private set; }
|
||||
|
||||
public void Validate(object source, ServerValidateEventArgs args) {
|
||||
IsMask = IsV6 = false;
|
||||
var ip = args.Value;
|
||||
int net = 0;
|
||||
if (ip.Contains("/")) {
|
||||
args.IsValid = AllowSubnet;
|
||||
var tokens = ip.Split('/');
|
||||
ip = tokens[0];
|
||||
args.IsValid &= int.TryParse(tokens[1], out net) && net <= 128;
|
||||
if (string.IsNullOrEmpty(ip)) {
|
||||
IsMask = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.Net.IPAddress ipaddr;
|
||||
args.IsValid &= System.Net.IPAddress.TryParse(ip, out ipaddr) && (ip.Contains(":") || ip.Contains(".")) &&
|
||||
(((Validation & IPValidationMode.V6) != 0 && (IsV6 = ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)) ||
|
||||
((Validation & IPValidationMode.V4) != 0 && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork));
|
||||
args.IsValid &= ipaddr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork || net < 32;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1434
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -38,6 +37,6 @@ namespace WebsitePanel.Portal.UserControls {
|
|||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RegularExpressionValidator addressValidator;
|
||||
protected global::System.Web.UI.WebControls.CustomValidator addressValidator;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue