Unsupported library that attempts to punch holes through NAT
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

.#DiscoveryTestDemo.java.1.3 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * This file is part of JSTUN.
  3. *
  4. * Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
  5. * reserved.
  6. *
  7. * This software is licensed under either the GNU Public License (GPL),
  8. * or the Apache 2.0 license. Copies of both license agreements are
  9. * included in this distribution.
  10. */
  11. package de.javawi.jstun.test.demo;
  12. import java.net.BindException;
  13. import java.net.InetAddress;
  14. import java.net.NetworkInterface;
  15. import java.util.Enumeration;
  16. import java.util.logging.FileHandler;
  17. import java.util.logging.Handler;
  18. import java.util.logging.Level;
  19. import java.util.logging.Logger;
  20. import java.util.logging.SimpleFormatter;
  21. import de.javawi.jstun.test.DiscoveryTest;
  22. public class DiscoveryTestDemo implements Runnable {
  23. InetAddress iaddress;
  24. public DiscoveryTestDemo(InetAddress iaddress) {
  25. this.iaddress = iaddress;
  26. }
  27. public void run() {
  28. try {
  29. DiscoveryTest test = new DiscoveryTest(iaddress, "stun.sipgate.net", 10000);
  30. //DiscoveryTest test = new DiscoveryTest(iaddress, "stun.sipgate.net", 10000);
  31. // iphone-stun.freenet.de:3478
  32. // larry.gloo.net:3478
  33. // stun.xten.net:3478
  34. // stun.sipgate.net:10000
  35. System.out.println(test.test());
  36. } catch (BindException be) {
  37. System.out.println(iaddress.toString() + ": " + be.getMessage());
  38. } catch (Exception e) {
  39. System.out.println(e.getMessage());
  40. e.printStackTrace();
  41. }
  42. }
  43. public static void main(String[] args) {
  44. try {
  45. Handler fh = new FileHandler("logging.txt");
  46. fh.setFormatter(new SimpleFormatter());
  47. Logger.getLogger("de.javawi.stun").addHandler(fh);
  48. Logger.getLogger("de.javawi.stun").setLevel(Level.ALL);
  49. Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
  50. while (ifaces.hasMoreElements()) {
  51. NetworkInterface iface = ifaces.nextElement();
  52. Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
  53. while (iaddresses.hasMoreElements()) {
  54. InetAddress iaddress = iaddresses.nextElement();
  55. if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) {
  56. Thread thread = new Thread(new DiscoveryTestDemo(iaddress));
  57. thread.start();
  58. }
  59. }
  60. }
  61. } catch (Exception e) {
  62. System.out.println(e.getMessage());
  63. }
  64. }
  65. }