From WikiChip
Difference between revisions of "mirc/ipv6"
< mirc

(mIRC option)
(Major edit to try to explain IPv6 issues more clearly.)
Line 1: Line 1:
 
{{mirc title|IPv6}}
 
{{mirc title|IPv6}}
  
mIRC has a pretty weird implementation of ipv6 and it is not really well integrated with the scripting language.
+
This page has been written to describe how IPv6 support has been provided in mIRC v7 onwards and the quirks of the current implementation, and to provide guidance to scripters on how to code /dns and /sockopen commands so that they work reliably regardless of the IPv4/v6 connectivity of the local and remote systems and regardless of the IP version used by the current IRC connection.
  
== /server -6 (without -4) & ipv6 server address ==
 
  
When you use /server -6 (without -4) or connect to an ipv6 ip address (passing an hostname which eventually resolve to an ipv6 address or passing an ipv6 address), this puts the whole status window in an ipv6 mode, meaning that disconnecting and reconnecting, regardless of how you do it, will attempt to connect with ipv6.
+
== Background ==
 +
mIRC was first conceived in 1995, when the Internet was in its infancy and IP version 4 seemed like it would easily scale to cope with global usage. But that was before mobile phones became IP based and the Internet of Things joined the fray.
  
It must be noted that in the above situation, ipv4 is simply disabled by default, any script which has to resolve ipv4 addresses run from that status window will fail, by default, this is breaking backward compatibility.
+
Eventually it became clear that IP version 4 would run out of addresses at some point, and a new IP version 6 Internet was launched in parallel. The IPv4 Internet and IPv6 Internet share a lot of concepts and technologies, but they are essentially separate networks, with end-points (users or servers) residing either on the IP v4 network '''or''' the IP v6 network '''or''' both. (There are some technologies that provide some co-existence functionality, but these are probably not relevant here.)
  
Such scripts can now be updated by using the -4 switches on either /server, /dns, or /sockopen, which force it to 'support' ipv4
+
Version of mIRC up to v6.x supported only IP v4. Version 7.0 in April 2010 introduced the first support for IPv6 and as IPv6 started to be supported by both IRC servers and IRC users, mIRC's IPv6 functionality was tweaked through to c. 2016 and is now considered to be mature and stable.
  
== mIRC option ==
+
Up until December 2019, IPv4 addresses have been the primary allocation, with some servers and users also having an IPv6 address. This has meant that an IPv6 user wanting an IP connection with an IPv4 end-point could use IPv4 instead. However IPv4 addresses are now in seriously short availability, and it will become increasingly likely that both servers and end-users will start having only IPv6 addresses. (We should perhaps expect there to be a greater focus in coming years on IPv6 to IPv4 gateways to allow IPv6-only users easily to connect to IPv4 only end-points, however these are likely to be implemented either by Internet-based gateways or within the Windows network stack, and so they should not directly impact mIRC - or at least we hope not.)
  
Remember, this option can be enabled/disabled at alt + o > Connect > options > ports button > Enable IPv6 support and prioritize IPv6 over IPv4 connections.
+
However, it should be recognised that mIRC's IPv6 support was implemented before there was widespread real-world usage of IPv6, and with the benefit of hindsight there are some areas in which questionable decisions were made - the consequence is that mIRC (currently) has some implementation oddities that scripters and some users need to be aware of.
  
In this mode, IPv6 has priority but IPv4 is not disabled.
+
== mIRC Settings ==
 +
There are actually surprisingly few mIRC settings relating to IPv6. Out of the box, mIRC is capable of talking to both IPv4 and IPv6 networks without special configuration.
  
This mode is recommended. Use /server -6 only if you want to disable IPv4 for anything happening from that connection by default, which should not be something you want to do.
+
There is one mIRC setting for IPv6: '''Tools''' / '''Options...''' / '''Connect''' / '''Options''' / '''Ports...''' / '''Enable IPv6 support and prioritize IPv6 over IPv4 connections'''.
  
== Notes ==
+
Despite the title of this option, IPv6 '''''is''''' supported regardless of whether this option is checked or not. Indeed this option seems to have only two significant impacts:
  
if you use /sockopen -d without -4 and/or -6 switches, it will base its DNS resolution on whether the bind address is ipv4/ipv6.
+
# Setting the default IP version for a new connection window
 +
# Enabling fallback to IPv4 for default DNS lookups in one specific case described below.
  
== Issues ==
+
== Connecting to an IRC server ==
 +
When a new connection window is opened (because you start mIRC or you do File / New Window or you click the Connect Button in Options / Connect with New window checked or by a /server -m/n command manually or in a script), the default IP version for the connection is set based on the '''Enable IPv6 support and prioritize IPv6 over IPv4 connections''' setting.
  
There are severals issues with this:
+
If you try to connect to an IRC server using a domain name, then mIRC tries first to connect using the current default IP version for the connection window, and if it is unable to do so then it will try the other IP version.
  
1) If you're using the /server -6 (or equivalent) option, it just breaks old scripts which couldn't use the -4 switch before to connect to ipv4 ip address.
+
If you connect using a specific IP address or with a -4/-6 switch, then mIRC will connect only with the IP version implied by these.
  
2) All in all, the only way to correctly get ipv4 fallback on any ipv6 connection is to never use /server -6 nor pass an ipv6 ip address, which seriously limits how you can connect: you are forced to pass an hostname.
+
Once a connection is made, the IP version used becomes the default version for future connections in this window.
It does not make sense to see mirc being connected using ipv6 with ipv4 fallback support because we passed an hostname which resolved to ipv6 address and see mIRC fail on ipv4 just because we passed the ipv6 directly to /server.
 
  
 +
== DNS lookups - IPv4, v6 or both ==
 +
In order to convert a domain name (for an IRC server or for a socket connection) to an IP address (either an IPv4 or IPv6 address), mIRC requests Windows to do a DNS lookup.
 +
 +
For connecting to an IRC server, mIRC queries IP versions as necessary to connect as above.
 +
 +
For all other DNS lookups i.e. /dns or /sockopen:
 +
 +
* If you specify -4 and / or -6 switches, these version(s) are queried.
 +
* If you don't specify either -4 or -6, then mIRC uses only the IP version of the current connection window (regardless of whether mIRC is connected to a server on that window or not) - but with the following exception:
 +
* If all of the following conditions are true, mIRC queries both IPv4 and IPv6:
 +
# You are connected to an IRC server via IPv6
 +
# '''Enable IPv6 support and prioritize IPv6 over IPv4 connections''' is checked
 +
# You have connected using a domain name without being explicit about the IP version i.e. you did not use -4 or -6 and did not use an explicit IP address
 +
 +
== Implications for Scripts ==
 +
If you are wanting to query both types of IP version i.e. in order to connect to an IPv4/6 end-point regardless of whether your IRC connection is IPv4/6, then '''you should explicitly use the -46 switch on the /dns or /sockopen command''' in order for your script to connect reliably regardless of the IRC version used by the connection window.
 +
 +
== Wiki authors' comments ==
 +
With the benefit of hindsight, this behaviour is a bit odd as e.g. a /sockopen without -4 or -6 for a domain which is only on the internet on one IP version will connect when the IRC connection has been made using that version, but will not connect when the IP connection is on the opposite IP version (with the above specific exception). Consequently scripts need to explicitly code -46 on every /dns or /sockopen command in order to make a connection on the opposite IP version and scripts that have been written without this e.g. written before IPv6 was implemented in mIRC will not have backward compatibility and will not work reliably. With the benefit of hindsight, it might have been better for /sockopen without -4 or -6 to always work in a priority sequence, either first on the connections IP version (or the IP version prioritised in mIRC Options) and then on the opposite version if a connection could not be made with that version - though this mitigated by the exceptional fallback in the circumstances identified above. If mIRC made this change now, it might break backwards compatibility with any scripts that explicitly rely on the current odd behaviour (assuming that any such scripts exist) but would make all the older scripts work without changes. Because the number of IPv6 connected mIRC users is expected to grow substantially over the next few years, this incompatibility for older scripts may become a much more significant issue. [[User:Sophist|Sophist]] ([[User talk:Sophist|talk]]) / [[User:Ouims|Ouims]] ([[User talk:Ouims|talk]]) 15:09, 20 December 2019 (EST)
  
 
[[Category:mIRC|ipv6]]
 
[[Category:mIRC|ipv6]]

Revision as of 15:10, 20 December 2019


This page has been written to describe how IPv6 support has been provided in mIRC v7 onwards and the quirks of the current implementation, and to provide guidance to scripters on how to code /dns and /sockopen commands so that they work reliably regardless of the IPv4/v6 connectivity of the local and remote systems and regardless of the IP version used by the current IRC connection.


Background

mIRC was first conceived in 1995, when the Internet was in its infancy and IP version 4 seemed like it would easily scale to cope with global usage. But that was before mobile phones became IP based and the Internet of Things joined the fray.

Eventually it became clear that IP version 4 would run out of addresses at some point, and a new IP version 6 Internet was launched in parallel. The IPv4 Internet and IPv6 Internet share a lot of concepts and technologies, but they are essentially separate networks, with end-points (users or servers) residing either on the IP v4 network or the IP v6 network or both. (There are some technologies that provide some co-existence functionality, but these are probably not relevant here.)

Version of mIRC up to v6.x supported only IP v4. Version 7.0 in April 2010 introduced the first support for IPv6 and as IPv6 started to be supported by both IRC servers and IRC users, mIRC's IPv6 functionality was tweaked through to c. 2016 and is now considered to be mature and stable.

Up until December 2019, IPv4 addresses have been the primary allocation, with some servers and users also having an IPv6 address. This has meant that an IPv6 user wanting an IP connection with an IPv4 end-point could use IPv4 instead. However IPv4 addresses are now in seriously short availability, and it will become increasingly likely that both servers and end-users will start having only IPv6 addresses. (We should perhaps expect there to be a greater focus in coming years on IPv6 to IPv4 gateways to allow IPv6-only users easily to connect to IPv4 only end-points, however these are likely to be implemented either by Internet-based gateways or within the Windows network stack, and so they should not directly impact mIRC - or at least we hope not.)

However, it should be recognised that mIRC's IPv6 support was implemented before there was widespread real-world usage of IPv6, and with the benefit of hindsight there are some areas in which questionable decisions were made - the consequence is that mIRC (currently) has some implementation oddities that scripters and some users need to be aware of.

mIRC Settings

There are actually surprisingly few mIRC settings relating to IPv6. Out of the box, mIRC is capable of talking to both IPv4 and IPv6 networks without special configuration.

There is one mIRC setting for IPv6: Tools / Options... / Connect / Options / Ports... / Enable IPv6 support and prioritize IPv6 over IPv4 connections.

Despite the title of this option, IPv6 is supported regardless of whether this option is checked or not. Indeed this option seems to have only two significant impacts:

  1. Setting the default IP version for a new connection window
  2. Enabling fallback to IPv4 for default DNS lookups in one specific case described below.

Connecting to an IRC server

When a new connection window is opened (because you start mIRC or you do File / New Window or you click the Connect Button in Options / Connect with New window checked or by a /server -m/n command manually or in a script), the default IP version for the connection is set based on the Enable IPv6 support and prioritize IPv6 over IPv4 connections setting.

If you try to connect to an IRC server using a domain name, then mIRC tries first to connect using the current default IP version for the connection window, and if it is unable to do so then it will try the other IP version.

If you connect using a specific IP address or with a -4/-6 switch, then mIRC will connect only with the IP version implied by these.

Once a connection is made, the IP version used becomes the default version for future connections in this window.

DNS lookups - IPv4, v6 or both

In order to convert a domain name (for an IRC server or for a socket connection) to an IP address (either an IPv4 or IPv6 address), mIRC requests Windows to do a DNS lookup.

For connecting to an IRC server, mIRC queries IP versions as necessary to connect as above.

For all other DNS lookups i.e. /dns or /sockopen:

  • If you specify -4 and / or -6 switches, these version(s) are queried.
  • If you don't specify either -4 or -6, then mIRC uses only the IP version of the current connection window (regardless of whether mIRC is connected to a server on that window or not) - but with the following exception:
  • If all of the following conditions are true, mIRC queries both IPv4 and IPv6:
  1. You are connected to an IRC server via IPv6
  2. Enable IPv6 support and prioritize IPv6 over IPv4 connections is checked
  3. You have connected using a domain name without being explicit about the IP version i.e. you did not use -4 or -6 and did not use an explicit IP address

Implications for Scripts

If you are wanting to query both types of IP version i.e. in order to connect to an IPv4/6 end-point regardless of whether your IRC connection is IPv4/6, then you should explicitly use the -46 switch on the /dns or /sockopen command in order for your script to connect reliably regardless of the IRC version used by the connection window.

Wiki authors' comments

With the benefit of hindsight, this behaviour is a bit odd as e.g. a /sockopen without -4 or -6 for a domain which is only on the internet on one IP version will connect when the IRC connection has been made using that version, but will not connect when the IP connection is on the opposite IP version (with the above specific exception). Consequently scripts need to explicitly code -46 on every /dns or /sockopen command in order to make a connection on the opposite IP version and scripts that have been written without this e.g. written before IPv6 was implemented in mIRC will not have backward compatibility and will not work reliably. With the benefit of hindsight, it might have been better for /sockopen without -4 or -6 to always work in a priority sequence, either first on the connections IP version (or the IP version prioritised in mIRC Options) and then on the opposite version if a connection could not be made with that version - though this mitigated by the exceptional fallback in the circumstances identified above. If mIRC made this change now, it might break backwards compatibility with any scripts that explicitly rely on the current odd behaviour (assuming that any such scripts exist) but would make all the older scripts work without changes. Because the number of IPv6 connected mIRC users is expected to grow substantially over the next few years, this incompatibility for older scripts may become a much more significant issue. Sophist (talk) / Ouims (talk) 15:09, 20 December 2019 (EST)