Package javaforce
Class STUN
java.lang.Object
javaforce.STUN
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic enumstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcFingerprint(byte[] data, int length) static byte[]static byte[]static byte[]calcMsgIntegrity(byte[] data, int length, byte[] key) voidclose()static STUN.NATPerforms a quick test to determine your firewall type.getIP()intintgetPort()static voidvoidrequestAlloc(boolean evenPort, byte[] token) TURN : Request a UDP data channel.voidrequestBind(short channel, String host, int port) TURN : Bind to host:port (also a keep alive)voidSTUN : Request real Public IPvoidrequestPublicIP(boolean change_ip, boolean change_port) STUN : Request real Public IP from a different IP and or PortvoidrequestRefresh(int seconds) TURN : Refresh a connection (keep alive)voidsendData(short channel, byte[] data, int offset, int length) TURN : Send out a UDP packet.booleanstart(int localport, String host, String user, String pass, STUN.Listener listener) Connects to STUN server and starts socket listening thread.
-
Constructor Details
-
STUN
public STUN()
-
-
Method Details
-
start
Connects to STUN server and starts socket listening thread.- Parameters:
localport- = localport to listen on (-1 = any)
-
getLocalPort
public int getLocalPort() -
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
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
-
getPort
public int getPort() -
sendData
public void sendData(short channel, byte[] data, int offset, int length) TURN : Send out a UDP packet. -
calcKey
-
calcKey
-
calcMsgIntegrity
public static byte[] calcMsgIntegrity(byte[] data, int length, byte[] key) -
calcFingerprint
public static int calcFingerprint(byte[] data, int length) -
doTest
Performs a quick test to determine your firewall type. -
main
-