You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Iwasa Kazmi (JIRA)" <ji...@apache.org> on 2006/10/28 10:21:16 UTC

[jira] Created: (LOG4NET-100) IPAddressConverter improvement for .NET 2 or .NET 3

IPAddressConverter improvement for .NET 2 or .NET 3
---------------------------------------------------

                 Key: LOG4NET-100
                 URL: http://issues.apache.org/jira/browse/LOG4NET-100
             Project: Log4net
          Issue Type: Improvement
          Components: Other
    Affects Versions: 1.2.10, 1.2.11
         Environment: .NET 2.0 or .NET 3.0
            Reporter: Iwasa Kazmi
            Priority: Minor


log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
But it may not convert an IP-address text properly especially on .NET 3.0.
(Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)

If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
Here is a patch.

===================================================================
--- IPAddressConverter.cs	(revision 468656)
+++ IPAddressConverter.cs	(working copy)
@@ -77,8 +77,12 @@
 				try
 				{
 #if NET_2_0
+					// Try to parse the string as an IP address.
+					IPAddress addr;
+					if (IPAddress.TryParse(str, out addr))
+						return addr;
+
 					// Try to resolve via DNS. This is a blocking call. 
-					// GetHostEntry works with either an IPAddress string or a host name
 					IPHostEntry host = Dns.GetHostEntry(str);
 					if (host != null && 
 						host.AddressList != null && 


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (LOG4NET-100) IPAddressConverter improvement for .NET 2 or .NET 3

Posted by "Iwasa Kazmi (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/LOG4NET-100?page=all ]

Iwasa Kazmi updated LOG4NET-100:
--------------------------------

    Description: 
log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
But it may not convert an IP-address text properly especially on .NET 3.0.
(Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)

If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
You can also use Dns.GetHostAddresses(). It converts IP address properly.
It would be better on .NET3.  In .NET2, it seems not recognize IPv6 address.

Here is a patch.

===================================================================
--- IPAddressConverter.cs	(revision 468656)
+++ IPAddressConverter.cs	(working copy)
@@ -77,8 +77,12 @@
 				try
 				{
 #if NET_2_0
+					// Try to parse the string as an IP address.
+					IPAddress addr;
+					if (IPAddress.TryParse(str, out addr))
+						return addr;
+
 					// Try to resolve via DNS. This is a blocking call. 
-					// GetHostEntry works with either an IPAddress string or a host name
 					IPHostEntry host = Dns.GetHostEntry(str);
 					if (host != null && 
 						host.AddressList != null && 


  was:
log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
But it may not convert an IP-address text properly especially on .NET 3.0.
(Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)

If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
Here is a patch.

===================================================================
--- IPAddressConverter.cs	(revision 468656)
+++ IPAddressConverter.cs	(working copy)
@@ -77,8 +77,12 @@
 				try
 				{
 #if NET_2_0
+					// Try to parse the string as an IP address.
+					IPAddress addr;
+					if (IPAddress.TryParse(str, out addr))
+						return addr;
+
 					// Try to resolve via DNS. This is a blocking call. 
-					// GetHostEntry works with either an IPAddress string or a host name
 					IPHostEntry host = Dns.GetHostEntry(str);
 					if (host != null && 
 						host.AddressList != null && 



> IPAddressConverter improvement for .NET 2 or .NET 3
> ---------------------------------------------------
>
>                 Key: LOG4NET-100
>                 URL: http://issues.apache.org/jira/browse/LOG4NET-100
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 1.2.10, 1.2.11
>         Environment: .NET 2.0 or .NET 3.0
>            Reporter: Iwasa Kazmi
>            Priority: Minor
>         Attachments: IPAddressConverter.patch
>
>
> log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
> But it may not convert an IP-address text properly especially on .NET 3.0.
> (Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)
> If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
> You can also use Dns.GetHostAddresses(). It converts IP address properly.
> It would be better on .NET3.  In .NET2, it seems not recognize IPv6 address.
> Here is a patch.
> ===================================================================
> --- IPAddressConverter.cs	(revision 468656)
> +++ IPAddressConverter.cs	(working copy)
> @@ -77,8 +77,12 @@
>  				try
>  				{
>  #if NET_2_0
> +					// Try to parse the string as an IP address.
> +					IPAddress addr;
> +					if (IPAddress.TryParse(str, out addr))
> +						return addr;
> +
>  					// Try to resolve via DNS. This is a blocking call. 
> -					// GetHostEntry works with either an IPAddress string or a host name
>  					IPHostEntry host = Dns.GetHostEntry(str);
>  					if (host != null && 
>  						host.AddressList != null && 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (LOG4NET-100) IPAddressConverter improvement for .NET 2 or .NET 3

Posted by "Nicko Cadell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-100?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nicko Cadell resolved LOG4NET-100.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2.11
         Assignee: Nicko Cadell

Added code to IPAddressConverter to explicitly try to convert the string into an IPAddress before trying to resolve it via DNS. This should have perfromance improvments for values specified as IP Addresses.

> IPAddressConverter improvement for .NET 2 or .NET 3
> ---------------------------------------------------
>
>                 Key: LOG4NET-100
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-100
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 1.2.10
>         Environment: .NET 2.0 or .NET 3.0
>            Reporter: Iwasa Kazmi
>         Assigned To: Nicko Cadell
>            Priority: Minor
>             Fix For: 1.2.11
>
>         Attachments: IPAddressConverter.patch
>
>
> log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
> But it may not convert an IP-address text properly especially on .NET 3.0.
> (Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)
> If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
> You can also use Dns.GetHostAddresses(). It converts IP address properly.
> It would be better on .NET3.  In .NET2, it seems not recognize IPv6 address.
> Here is a patch.
> ===================================================================
> --- IPAddressConverter.cs	(revision 468656)
> +++ IPAddressConverter.cs	(working copy)
> @@ -77,8 +77,12 @@
>  				try
>  				{
>  #if NET_2_0
> +					// Try to parse the string as an IP address.
> +					IPAddress addr;
> +					if (IPAddress.TryParse(str, out addr))
> +						return addr;
> +
>  					// Try to resolve via DNS. This is a blocking call. 
> -					// GetHostEntry works with either an IPAddress string or a host name
>  					IPHostEntry host = Dns.GetHostEntry(str);
>  					if (host != null && 
>  						host.AddressList != null && 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LOG4NET-100) IPAddressConverter improvement for .NET 2 or .NET 3

Posted by "Iwasa Kazmi (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/LOG4NET-100?page=all ]

Iwasa Kazmi updated LOG4NET-100:
--------------------------------

    Attachment: IPAddressConverter.patch

> IPAddressConverter improvement for .NET 2 or .NET 3
> ---------------------------------------------------
>
>                 Key: LOG4NET-100
>                 URL: http://issues.apache.org/jira/browse/LOG4NET-100
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 1.2.10, 1.2.11
>         Environment: .NET 2.0 or .NET 3.0
>            Reporter: Iwasa Kazmi
>            Priority: Minor
>         Attachments: IPAddressConverter.patch
>
>
> log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
> But it may not convert an IP-address text properly especially on .NET 3.0.
> (Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)
> If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
> Here is a patch.
> ===================================================================
> --- IPAddressConverter.cs	(revision 468656)
> +++ IPAddressConverter.cs	(working copy)
> @@ -77,8 +77,12 @@
>  				try
>  				{
>  #if NET_2_0
> +					// Try to parse the string as an IP address.
> +					IPAddress addr;
> +					if (IPAddress.TryParse(str, out addr))
> +						return addr;
> +
>  					// Try to resolve via DNS. This is a blocking call. 
> -					// GetHostEntry works with either an IPAddress string or a host name
>  					IPHostEntry host = Dns.GetHostEntry(str);
>  					if (host != null && 
>  						host.AddressList != null && 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (LOG4NET-100) IPAddressConverter improvement for .NET 2 or .NET 3

Posted by "Nicko Cadell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-100?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nicko Cadell updated LOG4NET-100:
---------------------------------

    Affects Version/s:     (was: 1.2.11)

> IPAddressConverter improvement for .NET 2 or .NET 3
> ---------------------------------------------------
>
>                 Key: LOG4NET-100
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-100
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Other
>    Affects Versions: 1.2.10
>         Environment: .NET 2.0 or .NET 3.0
>            Reporter: Iwasa Kazmi
>            Priority: Minor
>         Attachments: IPAddressConverter.patch
>
>
> log4net.Util.TypeConverters.IPAddressConverter uses only DNS query to get the IP address.
> But it may not convert an IP-address text properly especially on .NET 3.0.
> (Try Dns.GetHostEntry("127.0.0.1") on Vista. It returns some IPv4 and IPv6 addresses.)
> If you want to convert IP-address text directly, you should use IPAddress.Parse() or IPAddress.TryParse().
> You can also use Dns.GetHostAddresses(). It converts IP address properly.
> It would be better on .NET3.  In .NET2, it seems not recognize IPv6 address.
> Here is a patch.
> ===================================================================
> --- IPAddressConverter.cs	(revision 468656)
> +++ IPAddressConverter.cs	(working copy)
> @@ -77,8 +77,12 @@
>  				try
>  				{
>  #if NET_2_0
> +					// Try to parse the string as an IP address.
> +					IPAddress addr;
> +					if (IPAddress.TryParse(str, out addr))
> +						return addr;
> +
>  					// Try to resolve via DNS. This is a blocking call. 
> -					// GetHostEntry works with either an IPAddress string or a host name
>  					IPHostEntry host = Dns.GetHostEntry(str);
>  					if (host != null && 
>  						host.AddressList != null && 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.