normalize static method

String normalize(
  1. String ip
)

::ffff:1.2.3.4 becomes 1.2.3.4. The server listens on IPv6, so IPv4 clients come in this form. Other values stay the same.

Implementation

static String normalize(String ip) {
  if (ip.length > 7 && ip.startsWith('::') && ip.contains('.')) {
    String prefix = ip.substring(0, 7).toLowerCase();
    if (prefix == '::ffff:') return ip.substring(7);
  }
  return ip;
}