Package javaforce

Class STUN

java.lang.Object
javaforce.STUN

public class STUN extends Object
  • Constructor Details

    • STUN

      public STUN()
  • Method Details

    • start

      public boolean start(int localport, String host, String user, String pass, STUN.Listener listener)
      Connects to STUN server and starts socket listening thread.
      Parameters:
      localport - = localport to listen on (-1 = any)
    • getLocalPort

      public int getLocalPort()
    • getLocalAddr

      public String getLocalAddr()
    • close

      public void close()
    • requestPublicIP

      public void requestPublicIP()
      STUN : Request real Public IP
    • requestPublicIP

      public void requestPublicIP(boolean change_ip, boolean change_port)
      STUN : Request real Public IP from a different IP and or Port
    • requestAlloc

      public void requestAlloc(boolean evenPort, byte[] token)
      TURN : Request a UDP data channel. Token is optional, used if last request was for even port (to alloc the odd port).
    • requestBind

      public void requestBind(short channel, String host, int port)
      TURN : Bind to host:port (also a keep alive)
      Parameters:
      channel - : 0x4000 thru 0x7ffe (you pick one by random I guess)
    • requestRefresh

      public void requestRefresh(int seconds)
      TURN : Refresh a connection (keep alive)
    • getIP

      public String getIP()
    • getPort

      public int getPort()
    • sendData

      public void sendData(short channel, byte[] data, int offset, int length)
      TURN : Send out a UDP packet.
    • calcKey

      public static byte[] calcKey(String pass)
    • calcKey

      public static byte[] calcKey(String user, String realm, String pass)
    • calcMsgIntegrity

      public static byte[] calcMsgIntegrity(byte[] data, int length, byte[] key)
    • calcFingerprint

      public static int calcFingerprint(byte[] data, int length)
    • doTest

      public static STUN.NAT doTest(int port, String host1, String host2)
      Performs a quick test to determine your firewall type.
    • main

      public static void main(String[] args)