PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/azureus-4.7.0.2/com/aelitis/azureus/core/networkmanager/admin/NetworkAdmin.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 232 lines | 132 code | 59 blank | 41 comment | 2 complexity | 10c078ff742576f6333c0f3686ac7072 MD5 | raw file
  1. /*
  2. * Created on 1 Nov 2006
  3. * Created by Paul Gardner
  4. * Copyright (C) 2006 Aelitis, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * AELITIS, SAS au capital de 63.529,40 euros
  19. * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
  20. *
  21. */
  22. package com.aelitis.azureus.core.networkmanager.admin;
  23. import java.io.IOException;
  24. import java.net.InetAddress;
  25. import java.nio.channels.UnsupportedAddressTypeException;
  26. import org.gudy.azureus2.core3.util.IndentWriter;
  27. import com.aelitis.azureus.core.AzureusCore;
  28. import com.aelitis.azureus.core.networkmanager.admin.impl.NetworkAdminImpl;
  29. public abstract class
  30. NetworkAdmin
  31. {
  32. private static NetworkAdmin singleton;
  33. public static final String PR_NETWORK_INTERFACES = "Network Interfaces";
  34. public static final String PR_DEFAULT_BIND_ADDRESS = "Default Bind IP";
  35. public static final String PR_AS = "AS";
  36. public static final int IP_PROTOCOL_VERSION_AUTO = 0;
  37. public static final int IP_PROTOCOL_VERSION_REQUIRE_V4 = 1;
  38. public static final int IP_PROTOCOL_VERSION_REQUIRE_V6 = 2;
  39. public static final String[] PR_NAMES = {
  40. PR_NETWORK_INTERFACES,
  41. PR_DEFAULT_BIND_ADDRESS,
  42. PR_AS
  43. };
  44. public static synchronized NetworkAdmin
  45. getSingleton()
  46. {
  47. if ( singleton == null ){
  48. singleton = new NetworkAdminImpl();
  49. }
  50. return( singleton );
  51. }
  52. public InetAddress getSingleHomedServiceBindAddress() {return getSingleHomedServiceBindAddress(IP_PROTOCOL_VERSION_AUTO);}
  53. /**
  54. * @throws UnsupportedAddressTypeException when no address matching the v4/v6 requirements is found, always returns an address when auto is selected
  55. */
  56. public abstract InetAddress
  57. getSingleHomedServiceBindAddress(int protocolVersion) throws UnsupportedAddressTypeException;
  58. public abstract InetAddress[]
  59. getMultiHomedServiceBindAddresses(boolean forNIO);
  60. public abstract InetAddress
  61. getMultiHomedOutgoingRoundRobinBindAddress(InetAddress target);
  62. public abstract String
  63. getNetworkInterfacesAsString();
  64. public abstract InetAddress[]
  65. getAllBindAddresses(
  66. boolean include_wildcard );
  67. public abstract InetAddress
  68. guessRoutableBindAddress();
  69. /**
  70. * Returns the list of current addresses that can successfully be bound
  71. * to with an ephemeral port
  72. * @return
  73. */
  74. public abstract InetAddress[]
  75. getBindableAddresses();
  76. public abstract int
  77. getBindablePort(
  78. int preferred_port )
  79. throws IOException;
  80. public abstract NetworkAdminNetworkInterface[]
  81. getInterfaces();
  82. public abstract boolean
  83. hasIPV4Potential();
  84. public boolean hasIPV6Potential() {return hasIPV6Potential(false);}
  85. public abstract boolean
  86. hasIPV6Potential(boolean forNIO);
  87. public abstract NetworkAdminProtocol[]
  88. getOutboundProtocols(
  89. AzureusCore azureus_core);
  90. public abstract NetworkAdminProtocol[]
  91. getInboundProtocols(
  92. AzureusCore azureus_core );
  93. public abstract NetworkAdminProtocol
  94. createInboundProtocol(
  95. AzureusCore azureus_core,
  96. int type,
  97. int port );
  98. public abstract InetAddress
  99. testProtocol(
  100. NetworkAdminProtocol protocol )
  101. throws NetworkAdminException;
  102. public abstract NetworkAdminSocksProxy[]
  103. getSocksProxies();
  104. public abstract NetworkAdminHTTPProxy
  105. getHTTPProxy();
  106. public abstract NetworkAdminNATDevice[]
  107. getNATDevices(
  108. AzureusCore azureus_core);
  109. /**
  110. * Only call if the supplied address is believed to be the current public address
  111. * @param address
  112. * @return
  113. * @throws NetworkAdminException
  114. */
  115. public abstract NetworkAdminASN
  116. lookupCurrentASN(
  117. InetAddress address )
  118. throws NetworkAdminException;
  119. public abstract NetworkAdminASN
  120. getCurrentASN();
  121. /**
  122. * ad-hoc query
  123. * @param address
  124. * @return
  125. * @throws NetworkAdminException
  126. */
  127. public abstract NetworkAdminASN
  128. lookupASN(
  129. InetAddress address )
  130. throws NetworkAdminException;
  131. public abstract void
  132. lookupASN(
  133. InetAddress address,
  134. NetworkAdminASNListener listener );
  135. public abstract boolean
  136. canTraceRoute();
  137. public abstract void
  138. getRoutes(
  139. final InetAddress target,
  140. final int max_millis,
  141. final NetworkAdminRoutesListener listener )
  142. throws NetworkAdminException;
  143. public abstract boolean
  144. canPing();
  145. public abstract void
  146. pingTargets(
  147. final InetAddress target,
  148. final int max_millis,
  149. final NetworkAdminRoutesListener listener )
  150. throws NetworkAdminException;
  151. public abstract InetAddress
  152. getDefaultPublicAddress();
  153. public abstract InetAddress getDefaultPublicAddressV6();
  154. public abstract boolean hasDHTIPV6();
  155. public abstract void
  156. addPropertyChangeListener(
  157. NetworkAdminPropertyChangeListener listener );
  158. public abstract void
  159. addAndFirePropertyChangeListener(
  160. NetworkAdminPropertyChangeListener listener );
  161. public abstract void
  162. removePropertyChangeListener(
  163. NetworkAdminPropertyChangeListener listener );
  164. public abstract void
  165. runInitialChecks(
  166. AzureusCore azureus_core);
  167. public abstract void
  168. logNATStatus(
  169. IndentWriter iw );
  170. public abstract void
  171. generateDiagnostics(
  172. IndentWriter iw );
  173. }