Module convex.peer
Package convex.net

Class IPUtils

java.lang.Object
convex.net.IPUtils

public class IPUtils extends Object
  • Constructor Details

    • IPUtils

      public IPUtils()
  • Method Details

    • tryGetIP

      public static InetAddress tryGetIP() throws InterruptedException
      Throws:
      InterruptedException
    • tryGetWTF

      public static String tryGetWTF() throws InterruptedException
      Throws:
      InterruptedException
    • toInetSocketAddress

      public static InetSocketAddress toInetSocketAddress(Object o)
      Converts a Object to an InetSocketAddress
      Parameters:
      o - An Object to convert to a socket address. May be a String or existing InetSocketAddress
      Returns:
      A valid InetSocketAddress, or null if not in valid format
    • toInetSocketAddress

      public static InetSocketAddress toInetSocketAddress(String s)
      Converts a String to an InetSocketAddress
      Parameters:
      s - A string in the format of a valid URL or "myhost.com:17888"
      Returns:
      A valid InetSocketAddress, or null if not in valid format
    • toInetSocketAddress

      public static InetSocketAddress toInetSocketAddress(URL url)
      Converts a URL to an InetSocketAddress. Will assume default port if not specified.
      Parameters:
      url - A valid URL
      Returns:
      A valid InetSocketAddress for the URL
    • toInetSocketAddress

      public static InetSocketAddress toInetSocketAddress(URI uri)
      Converts a URI to an InetSocketAddress. Will assume default port if not specified.
      Parameters:
      uri - A valid URI
      Returns:
      A valid InetSocketAddress for the URI
    • main

      public static void main(String[] args) throws InterruptedException
      Throws:
      InterruptedException
    • parseAddress

      public static InetSocketAddress parseAddress(String hostname, Integer port)
      Parses a socket address
      Parameters:
      hostname - Hostname or "host:port" string
      port - Port to use (null implies default peer port, or whatever specified in hostname)
      Returns:
      Socket address or null if failed to parse