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
|
@ -73,6 +73,7 @@ function confirmation()
|
|||
<td class="NormalBold">
|
||||
<asp:DropDownList ID="ddlRecordType" runat="server" SelectedValue='<%# Bind("RecordType") %>' CssClass="NormalTextBox" AutoPostBack="True" OnSelectedIndexChanged="ddlRecordType_SelectedIndexChanged">
|
||||
<asp:ListItem>A</asp:ListItem>
|
||||
<asp:ListItem>AAAA</asp:ListItem>
|
||||
<asp:ListItem>MX</asp:ListItem>
|
||||
<asp:ListItem>NS</asp:ListItem>
|
||||
<asp:ListItem>TXT</asp:ListItem>
|
||||
|
@ -89,11 +90,11 @@ function confirmation()
|
|||
<tr id="rowData" runat="server">
|
||||
<td class="SubHead"><asp:Label ID="lblRecordData" runat="server" meta:resourcekey="lblRecordData" Text="Record Data:"></asp:Label></td>
|
||||
<td class="NormalBold" nowrap>
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="200px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="260px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="valRequireData" runat="server" ControlToValidate="txtRecordData"
|
||||
ErrorMessage="*" ValidationGroup="DnsZoneRecord" Display="Dynamic"></asp:RequiredFieldValidator>
|
||||
<asp:regularexpressionvalidator id="IPValidator" 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" ErrorMessage="Please enter a valid IP" ValidationGroup="DnsZoneRecord" ControlToValidate="txtRecordData" CssClass="NormalBold"></asp:regularexpressionvalidator>
|
||||
<asp:CustomValidator ID="IPValidator" runat="server" ControlToValidate="txtRecordData" ValidationGroup="DnsZoneRecord" Display="Dynamic" CssClass="NormalBold"
|
||||
Text="Please enter a valid IP" OnServerValidate="Validate" meta:resourcekey="IPValidator" />
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
@ -102,14 +103,14 @@ function confirmation()
|
|||
<td class="NormalBold">
|
||||
<asp:TextBox ID="txtMXPriority" runat="server" Width="30" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="valRequireMxPriority" runat="server" ControlToValidate="txtMXPriority"
|
||||
ErrorMessage="*" ValidationGroup="DnsZoneRecord" Display="Dynamic"></asp:RequiredFieldValidator>
|
||||
ErrorMessage="*" ValidationGroup="DnsZoneRecord" Display="Dynamic" />
|
||||
<asp:RegularExpressionValidator ID="valRequireCorrectPriority" runat="server" ControlToValidate="txtMXPriority"
|
||||
ErrorMessage="*" ValidationExpression="\d{1,3}"></asp:RegularExpressionValidator></td>
|
||||
ErrorMessage="*" ValidationExpression="\d{1,3}" ValidationGroup="DnsZoneRecord" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="FormFooter">
|
||||
<asp:Button ID="btnSave" runat="server" meta:resourcekey="btnSave" Text="Save" CssClass="Button1" OnClick="btnSave_Click" OnClientClick = "ShowProgressDialog('Saving DNS Zone Record ...');" ValidationGroup="DnsZoneRecord" />
|
||||
<asp:Button ID="btnCancel" runat="server" meta:resourcekey="btnCancel" Text="Cancel" CssClass="Button1" OnClick="btnCancel_Click" CausesValidation="False" /></td>
|
||||
<asp:Button ID="btnCancel" runat="server" meta:resourcekey="btnCancel" Text="Cancel" CssClass="Button1" OnClick="btnCancel_Click" CausesValidation="False" />
|
||||
</div>
|
||||
</asp:Panel>
|
|
@ -109,6 +109,11 @@ namespace WebsitePanel.Portal
|
|||
lblRecordData.Text = "IP:";
|
||||
IPValidator.Enabled = true;
|
||||
}
|
||||
else if (ddlRecordType.SelectedValue == "AAAA")
|
||||
{
|
||||
lblRecordData.Text = "IP (v6):";
|
||||
IPValidator.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblRecordData.Text = "Record Data:";
|
||||
|
@ -116,6 +121,14 @@ namespace WebsitePanel.Portal
|
|||
}
|
||||
}
|
||||
|
||||
protected void Validate(object source, ServerValidateEventArgs args) {
|
||||
var ip = args.Value;
|
||||
System.Net.IPAddress ipaddr;
|
||||
args.IsValid = System.Net.IPAddress.TryParse(ip, out ipaddr) && (ip.Contains(":") || ip.Contains(".")) &&
|
||||
((ddlRecordType.SelectedValue == "A" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) ||
|
||||
(ddlRecordType.SelectedValue == "AAAA" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6));
|
||||
}
|
||||
|
||||
private void SaveRecord()
|
||||
{
|
||||
if (Page.IsValid)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.3074
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -173,7 +172,7 @@ namespace WebsitePanel.Portal {
|
|||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RegularExpressionValidator IPValidator;
|
||||
protected global::System.Web.UI.WebControls.CustomValidator IPValidator;
|
||||
|
||||
/// <summary>
|
||||
/// rowMXPriority control.
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
<td class="NormalBold" width="100%">
|
||||
<asp:DropDownList ID="ddlRecordType" runat="server" SelectedValue='<%# Bind("RecordType") %>' CssClass="NormalTextBox" AutoPostBack="True" OnSelectedIndexChanged="ddlRecordType_SelectedIndexChanged">
|
||||
<asp:ListItem>A</asp:ListItem>
|
||||
<asp:ListItem>AAAA</asp:ListItem>
|
||||
<asp:ListItem>MX</asp:ListItem>
|
||||
<asp:ListItem>NS</asp:ListItem>
|
||||
<asp:ListItem>TXT</asp:ListItem>
|
||||
|
@ -129,14 +130,14 @@
|
|||
<tr id="rowData" runat="server">
|
||||
<td class="SubHead"><asp:Label ID="lblRecordData" runat="server" meta:resourcekey="lblRecordData" Text="Record Data:"></asp:Label></td>
|
||||
<td class="NormalBold" nowrap>
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="200px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="260px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="valRequireData" runat="server" ControlToValidate="txtRecordData"
|
||||
ErrorMessage="*" ValidationGroup="DnsZoneRecord" Display="Dynamic"></asp:RequiredFieldValidator>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<asp:regularexpressionvalidator id="IPValidator1" 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" ErrorMessage="Please enter a valid IP" ValidationGroup="DnsZoneRecord" ControlToValidate="txtRecordData" CssClass="NormalBold"></asp:regularexpressionvalidator>
|
||||
<asp:CustomValidator ID="IPValidator" runat="server" ControlToValidate="txtRecordData" ValidationGroup="DnsZoneRecord" Display="Dynamic"
|
||||
OnServerValidate="Validate" Text="Please enter a valid IP" meta:resourcekey="IPValidator" />
|
||||
</tr>
|
||||
<tr id="rowMXPriority" runat="server">
|
||||
<td class="SubHead"><asp:Label ID="lblMXPriority" runat="server" meta:resourcekey="lblMXPriority" Text="MX Priority:"></asp:Label></td>
|
||||
|
|
|
@ -110,15 +110,27 @@ namespace WebsitePanel.Portal.ExchangeServer
|
|||
if (ddlRecordType.SelectedValue == "A")
|
||||
{
|
||||
lblRecordData.Text = "IP:";
|
||||
IPValidator1.Enabled = true;
|
||||
}
|
||||
IPValidator.Enabled = true;
|
||||
}
|
||||
else if (ddlRecordType.SelectedValue == "AAAA") {
|
||||
lblRecordData.Text = "IPv6:";
|
||||
IPValidator.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblRecordData.Text = "Record Data:";
|
||||
IPValidator1.Enabled = false;
|
||||
IPValidator.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Validate(object source, ServerValidateEventArgs args) {
|
||||
var ip = args.Value;
|
||||
System.Net.IPAddress ipaddr;
|
||||
args.IsValid = System.Net.IPAddress.TryParse(ip, out ipaddr) && (ip.Contains(":") || ip.Contains(".")) &&
|
||||
((ddlRecordType.SelectedValue == "A" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) ||
|
||||
(ddlRecordType.SelectedValue == "AAAA" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6));
|
||||
}
|
||||
|
||||
private void SaveRecord()
|
||||
{
|
||||
if (!Page.IsValid)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -230,13 +229,13 @@ namespace WebsitePanel.Portal.ExchangeServer {
|
|||
protected global::System.Web.UI.WebControls.RequiredFieldValidator valRequireData;
|
||||
|
||||
/// <summary>
|
||||
/// IPValidator1 control.
|
||||
/// IPValidator control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RegularExpressionValidator IPValidator1;
|
||||
protected global::System.Web.UI.WebControls.CustomValidator IPValidator;
|
||||
|
||||
/// <summary>
|
||||
/// rowMXPriority control.
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<td class="Normal" width="100%">
|
||||
<asp:DropDownList ID="ddlRecordType" runat="server" SelectedValue='<%# Bind("RecordType") %>' CssClass="NormalTextBox" AutoPostBack="True" OnSelectedIndexChanged="ddlRecordType_SelectedIndexChanged">
|
||||
<asp:ListItem>A</asp:ListItem>
|
||||
<asp:ListItem>AAAA</asp:ListItem>
|
||||
<asp:ListItem>MX</asp:ListItem>
|
||||
<asp:ListItem>NS</asp:ListItem>
|
||||
<asp:ListItem>TXT</asp:ListItem>
|
||||
|
@ -51,13 +52,21 @@
|
|||
<tr id="rowData" runat="server">
|
||||
<td class="SubHead"><asp:Label ID="lblRecordData" runat="server" meta:resourcekey="lblRecordData" Text="Record Data:"></asp:Label></td>
|
||||
<td class="Normal" nowrap>
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="100px" CssClass="NormalTextBox"></asp:TextBox><uc1:SelectIPAddress ID="ipAddress" runat="server" />
|
||||
<asp:TextBox ID="txtRecordData" runat="server" Width="260px" CssClass="NormalTextBox"></asp:TextBox><uc1:SelectIPAddress ID="ipAddress" runat="server" />
|
||||
<asp:RequiredFieldValidator ID="valRequireData" runat="server" ControlToValidate="txtRecordData"
|
||||
ErrorMessage="*" ValidationGroup="DnsRecord" Display="Dynamic"></asp:RequiredFieldValidator>
|
||||
<asp:CustomValidator ID="IPValidator" runat="server" ControlToValidate="txtRecordData" ValidationGroup="DnsRecord" Display="Dynamic" CssClass="NormalBold"
|
||||
OnServerValidate="Validate" Text="Please enter a valid IP" meta:resourcekey="IPValidator"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="rowMXPriority" runat="server">
|
||||
<td class="SubHead"><asp:Label ID="lblMXPriority" runat="server" meta:resourcekey="lblMXPriority" Text="MX Priority:"></asp:Label></td>
|
||||
<td class="Normal">
|
||||
<asp:TextBox ID="txtMXPriority" runat="server" Width="30" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="valRequireMxPriority" runat="server" ControlToValidate="txtMXPriority"
|
||||
ErrorMessage="*" ValidationGroup="DnsRecord" Display="Dynamic"></asp:RequiredFieldValidator>
|
||||
<asp:RegularExpressionValidator ID="valRequireCorrectPriority" runat="server" ControlToValidate="txtMXPriority"
|
||||
ErrorMessage="*" ValidationExpression="\d{1,3}" ValidationGroup="DnsRecord" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -138,13 +138,33 @@ namespace WebsitePanel.Portal
|
|||
|
||||
private void ToggleRecordControls()
|
||||
{
|
||||
ipAddress.Visible = (ddlRecordType.SelectedValue == "A");
|
||||
//rowData.Visible = (ddlRecordType.SelectedValue != "A");
|
||||
ipAddress.Visible = (ddlRecordType.SelectedValue == "A" || ddlRecordType.SelectedValue == "AAAA");
|
||||
//rowData.Visible = (ddlRecordType.SelectedValue != "A" && ddlRecordType.SelectedValue != "AAAA");
|
||||
rowMXPriority.Visible = (ddlRecordType.SelectedValue == "MX");
|
||||
if (ddlRecordType.SelectedValue == "A") {
|
||||
lblRecordData.Text = "IP:";
|
||||
IPValidator.Enabled = true;
|
||||
} else if (ddlRecordType.SelectedValue == "AAAA") {
|
||||
lblRecordData.Text = "IP (v6):";
|
||||
IPValidator.Enabled = true;
|
||||
} else {
|
||||
lblRecordData.Text = "Record Data:";
|
||||
IPValidator.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Validate(object source, ServerValidateEventArgs args) {
|
||||
var ip = args.Value;
|
||||
System.Net.IPAddress ipaddr;
|
||||
args.IsValid = System.Net.IPAddress.TryParse(ip, out ipaddr) && (ip.Contains(":") || ip.Contains(".")) &&
|
||||
((ddlRecordType.SelectedValue == "A" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) ||
|
||||
(ddlRecordType.SelectedValue == "AAAA" && ipaddr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6));
|
||||
}
|
||||
|
||||
private void SaveRecord()
|
||||
{
|
||||
if (!Page.IsValid) return;
|
||||
|
||||
GlobalDnsRecord record = new GlobalDnsRecord();
|
||||
record.RecordId = (int)ViewState["RecordID"];
|
||||
record.RecordType = ddlRecordType.SelectedValue;
|
||||
|
|
|
@ -1,32 +1,204 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebsitePanel.Portal {
|
||||
|
||||
|
||||
public partial class GlobalDnsRecordsControl {
|
||||
protected System.Web.UI.WebControls.Panel pnlRecords;
|
||||
protected System.Web.UI.WebControls.Button btnAdd;
|
||||
protected System.Web.UI.WebControls.GridView gvRecords;
|
||||
protected System.Web.UI.WebControls.Panel pnlEdit;
|
||||
protected System.Web.UI.WebControls.Label lblRecordType;
|
||||
protected System.Web.UI.WebControls.DropDownList ddlRecordType;
|
||||
protected System.Web.UI.WebControls.Label lblRecordName;
|
||||
protected System.Web.UI.WebControls.TextBox txtRecordName;
|
||||
protected System.Web.UI.HtmlControls.HtmlTableRow rowData;
|
||||
protected System.Web.UI.WebControls.Label lblRecordData;
|
||||
protected System.Web.UI.WebControls.TextBox txtRecordData;
|
||||
protected WebsitePanel.Portal.SelectIPAddress ipAddress;
|
||||
protected System.Web.UI.HtmlControls.HtmlTableRow rowMXPriority;
|
||||
protected System.Web.UI.WebControls.Label lblMXPriority;
|
||||
protected System.Web.UI.WebControls.TextBox txtMXPriority;
|
||||
protected System.Web.UI.WebControls.Button btnSave;
|
||||
protected System.Web.UI.WebControls.Button btnCancel;
|
||||
|
||||
/// <summary>
|
||||
/// pnlRecords control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Panel pnlRecords;
|
||||
|
||||
/// <summary>
|
||||
/// btnAdd control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnAdd;
|
||||
|
||||
/// <summary>
|
||||
/// gvRecords control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.GridView gvRecords;
|
||||
|
||||
/// <summary>
|
||||
/// pnlEdit control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Panel pnlEdit;
|
||||
|
||||
/// <summary>
|
||||
/// lblRecordType control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblRecordType;
|
||||
|
||||
/// <summary>
|
||||
/// ddlRecordType control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList ddlRecordType;
|
||||
|
||||
/// <summary>
|
||||
/// lblRecordName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblRecordName;
|
||||
|
||||
/// <summary>
|
||||
/// txtRecordName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtRecordName;
|
||||
|
||||
/// <summary>
|
||||
/// rowData control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlTableRow rowData;
|
||||
|
||||
/// <summary>
|
||||
/// lblRecordData control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblRecordData;
|
||||
|
||||
/// <summary>
|
||||
/// txtRecordData control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtRecordData;
|
||||
|
||||
/// <summary>
|
||||
/// ipAddress control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::WebsitePanel.Portal.SelectIPAddress ipAddress;
|
||||
|
||||
/// <summary>
|
||||
/// valRequireData control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RequiredFieldValidator valRequireData;
|
||||
|
||||
/// <summary>
|
||||
/// IPValidator control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CustomValidator IPValidator;
|
||||
|
||||
/// <summary>
|
||||
/// rowMXPriority control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlTableRow rowMXPriority;
|
||||
|
||||
/// <summary>
|
||||
/// lblMXPriority control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblMXPriority;
|
||||
|
||||
/// <summary>
|
||||
/// txtMXPriority control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtMXPriority;
|
||||
|
||||
/// <summary>
|
||||
/// valRequireMxPriority control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RequiredFieldValidator valRequireMxPriority;
|
||||
|
||||
/// <summary>
|
||||
/// valRequireCorrectPriority control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.RegularExpressionValidator valRequireCorrectPriority;
|
||||
|
||||
/// <summary>
|
||||
/// btnSave control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnSave;
|
||||
|
||||
/// <summary>
|
||||
/// btnCancel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnCancel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
<asp:ValidationSummary ID="validatorsSummary" runat="server"
|
||||
ValidationGroup="EditAddress" ShowMessageBox="True" ShowSummary="False" />
|
||||
|
||||
<table cellspacing="0" cellpadding="3">
|
||||
<asp:CustomValidator ID="consistentAddresses" runat="server" ErrorMessage="You must not mix IPv4 and IPv6 addresses." ValidationGroup="EditAddress" Display="dynamic" ServerValidate="CheckIPAddresses" />
|
||||
|
||||
<table cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td style="width:150px;">
|
||||
<asp:Localize ID="locPool" runat="server" meta:resourcekey="locPool" Text="Pool:"></asp:Localize>
|
||||
|
@ -33,7 +35,7 @@
|
|||
<td><asp:Localize ID="lblExternalIP" runat="server" meta:resourcekey="lblExternalIP" Text="IP Address:"></asp:Localize></td>
|
||||
<td>
|
||||
|
||||
<wsp:EditIPAddressControl id="startIP" runat="server" ValidationGroup="EditAddress" Required="true" />
|
||||
<wsp:EditIPAddressControl id="startIP" runat="server" ValidationGroup="EditAddress" Required="true" AllowSubnet="true" />
|
||||
|
||||
<asp:Localize ID="locTo" runat="server" meta:resourcekey="locTo" Text="to"></asp:Localize>
|
||||
|
||||
|
@ -52,7 +54,7 @@
|
|||
<tr id="SubnetRow" runat="server">
|
||||
<td><asp:Localize ID="locSubnetMask" runat="server" meta:resourcekey="locSubnetMask" Text="Subnet Mask:"></asp:Localize></td>
|
||||
<td class="NormalBold">
|
||||
<wsp:EditIPAddressControl id="subnetMask" runat="server" ValidationGroup="EditAddress" Required="true" />
|
||||
<wsp:EditIPAddressControl id="subnetMask" runat="server" ValidationGroup="EditAddress" Required="true" AllowSubnet="true" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="GatewayRow" runat="server">
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace WebsitePanel.Portal
|
|||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
// bind dropdowns
|
||||
try
|
||||
{
|
||||
|
@ -96,7 +97,7 @@ namespace WebsitePanel.Portal
|
|||
string comments = txtComments.Text.Trim();
|
||||
|
||||
// add ip address
|
||||
if (endIP.Text != "")
|
||||
if (endIP.Text != "" || startIP.Text.Contains("/"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -162,5 +163,12 @@ namespace WebsitePanel.Portal
|
|||
SubnetRow.Visible = vps;
|
||||
GatewayRow.Visible = vps;
|
||||
}
|
||||
|
||||
public void CheckIPAddresses(object sender, ServerValidateEventArgs args) {
|
||||
startIP.Validate(sender, args);
|
||||
endIP.Validate(sender, args);
|
||||
subnetMask.Validate(sender, args);
|
||||
args.IsValid = startIP.IsV6 == endIP.IsV6 && (startIP.IsV6 == subnetMask.IsV6 || subnetMask.IsMask);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -31,6 +30,15 @@ namespace WebsitePanel.Portal {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ValidationSummary validatorsSummary;
|
||||
|
||||
/// <summary>
|
||||
/// consistent Addresses control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CustomValidator consistentAddresses;
|
||||
|
||||
/// <summary>
|
||||
/// locPool control.
|
||||
/// </summary>
|
||||
|
|
|
@ -288,7 +288,7 @@
|
|||
<td>
|
||||
<wsp:EditIPAddressControl id="privateIPAddress" runat="server" Required="true" />
|
||||
/
|
||||
<asp:TextBox ID="privateSubnetMask" runat="server" MaxLength="2" Width="40px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:TextBox ID="privateSubnetMask" runat="server" MaxLength="3" Width="40px" CssClass="NormalTextBox"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="privateSubnetMaskValidator" runat="server" ControlToValidate="privateSubnetMask"
|
||||
Text="*" meta:resourcekey="privateSubnetMaskValidator" Display="Dynamic" SetFocusOnError="true" />
|
||||
</td>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4927
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<pages controlRenderingCompatibilityVersion="3.5">
|
||||
<controls>
|
||||
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
|
||||
</controls>
|
||||
</pages>
|
||||
<compilation targetFramework="4.0">
|
||||
</compilation>
|
||||
</system.web>
|
||||
</configuration>
|
||||
<system.web>
|
||||
<pages controlRenderingCompatibilityVersion="3.5">
|
||||
<controls>
|
||||
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
|
||||
</controls>
|
||||
</pages>
|
||||
<compilation targetFramework="4.0" debug="true"/>
|
||||
</system.web>
|
||||
</configuration>
|
Loading…
Add table
Add a link
Reference in a new issue