本文整理汇总了Java中com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin类的典型用法代码示例。如果您正苦于以下问题:Java NetworkAdmin类的具体用法?Java NetworkAdmin怎么用?Java NetworkAdmin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NetworkAdmin类属于com.aelitis.azureus.core.networkmanager.admin包,在下文中一共展示了NetworkAdmin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runSupport
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
public void
runSupport()
{
try{
printMessage(MessageText.getString("configureWizard.nat.testing") + " TCP " + TCPListenPort + " ... ");
NatChecker checker = new NatChecker(core, NetworkAdmin.getSingleton().getMultiHomedServiceBindAddresses(true)[0], TCPListenPort, false);
switch (checker.getResult()) {
case NatChecker.NAT_OK :
printMessage( "\n" + MessageText.getString("configureWizard.nat.ok") + "\n" + checker.getAdditionalInfo());
break;
case NatChecker.NAT_KO :
printMessage( "\n" + MessageText.getString("configureWizard.nat.ko") + " - " + checker.getAdditionalInfo()+".\n");
break;
default :
printMessage( "\n" + MessageText.getString("configureWizard.nat.unable") + ". \n(" + checker.getAdditionalInfo()+").\n");
break;
}
}finally{
enableNext();
}
}
示例2: propertyChanged
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
public void
propertyChanged(
String property )
{
if ( property == NetworkAdmin.PR_DEFAULT_BIND_ADDRESS ){
readConfig();
}
}
示例3: runSupport
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
public void
runSupport()
{
try{
printMessage(MessageText.getString("configureWizard.nat.testing") + " TCP " + TCPListenPort + " ... ");
NatChecker checker = new NatChecker(AzureusCoreFactory.getSingleton(), NetworkAdmin.getSingleton().getMultiHomedServiceBindAddresses(true)[0], TCPListenPort, false);
switch (checker.getResult()) {
case NatChecker.NAT_OK :
printMessage( "\n" + MessageText.getString("configureWizard.nat.ok") + "\n" + checker.getAdditionalInfo());
break;
case NatChecker.NAT_KO :
printMessage( "\n" + MessageText.getString("configureWizard.nat.ko") + " - " + checker.getAdditionalInfo()+".\n");
break;
default :
printMessage( "\n" + MessageText.getString("configureWizard.nat.unable") + ". \n(" + checker.getAdditionalInfo()+").\n");
break;
}
}finally{
if (display.isDisposed()) {return;}
display.asyncExec(new AERunnable() {
public void runSupport() {
if(bTestTCP != null && ! bTestTCP.isDisposed())
bTestTCP.setEnabled(true);
if(bTestUDP != null && ! bTestUDP.isDisposed())
bTestUDP.setEnabled(true);
if(bApply != null && ! bApply.isDisposed())
bApply.setEnabled(true);
}
});
}
}
示例4: sendLTHandshake
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void sendLTHandshake() {
String client_name = Constants.AZUREUS_PROTOCOL_NAME + " " + Constants.AZUREUS_VERSION;
int localTcpPort = TCPNetworkManager.getSingleton().getTCPListeningPortNumber();
String tcpPortOverride = COConfigurationManager.getStringParameter("TCP.Listen.Port.Override");
try
{
localTcpPort = Integer.parseInt(tcpPortOverride);
} catch (NumberFormatException e) {} // ignore as invalid input
boolean require_crypto = NetworkManager.getCryptoRequired( manager.getAdapter().getCryptoLevel());
Map data_dict = new HashMap();
data_dict.put("v", client_name);
data_dict.put("p", new Integer(localTcpPort));
data_dict.put("e", new Long(require_crypto ? 1L : 0L));
data_dict.put("upload_only", new Long(manager.isSeeding() && !( ENABLE_LAZY_BITFIELD || manual_lazy_bitfield_control )? 1L : 0L));
int metainfo_size = is_metadata_download?0:manager.getTorrentInfoDictSize();
if ( metainfo_size > 0 ){
data_dict.put("metadata_size", new Integer(metainfo_size));
}
NetworkAdmin na = NetworkAdmin.getSingleton();
if ( !na.isSocksActive()){
// don't send public address in handshake
InetAddress defaultV6 = na.hasIPV6Potential(true) ? na.getDefaultPublicAddressV6() : null;
if(defaultV6 != null){
data_dict.put("ipv6",defaultV6.getAddress());
}
}
LTHandshake lt_handshake = new LTHandshake(data_dict, other_peer_bt_lt_ext_version );
lt_handshake.addDefaultExtensionMappings( true, is_metadata_download || metainfo_size > 0 );
connection.getOutgoingMessageQueue().addMessage(lt_handshake, false);
}
示例5: readConfig
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
protected void
readConfig(
boolean first_time )
{
InetAddress new_internal_address = NetworkAdmin.getSingleton().getSingleHomedServiceBindAddress();
if ( new_internal_address == null ){
try{
new_internal_address = InetAddress.getByName( "0.0.0.0" );
}catch( Throwable e ){
}
}
int[] ports = adapter.getPorts();
int new_tcp_port = ports[0];
int new_udp_port = ports[1];
int new_udp_non_data_port = ports[2];
boolean same = true;
if ( !first_time ){
same = internal_address.equals( new_internal_address) &&
tcp_port == new_tcp_port &&
udp_port == new_udp_port &&
udp_non_data_port == new_udp_non_data_port;
}
internal_address = new_internal_address;
tcp_port = new_tcp_port;
udp_port = new_udp_port;
udp_non_data_port = new_udp_non_data_port;
if ( !same ){
manager.informChanged( this );
}
}
示例6: start
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void start() {
try
{
this_mon.enter();
if (tcp_listen_port < 0 || tcp_listen_port > 65535 || tcp_listen_port == 6880)
{
String msg = "Invalid incoming TCP listen port configured, " + tcp_listen_port + ". Port reset to default. Please check your config!";
Debug.out(msg);
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
tcp_listen_port = RandomUtils.generateRandomNetworkListenPort();
COConfigurationManager.setParameter(port_config_key, tcp_listen_port);
}
if (COConfigurationManager.getBooleanParameter(port_enable_config_key))
{
last_non_local_connection_time = COConfigurationManager.getLongParameter( "network.tcp.port." + tcp_listen_port + ".last.nonlocal.incoming", 0 );
if ( last_non_local_connection_time > SystemTime.getCurrentTime()){
last_non_local_connection_time = SystemTime.getCurrentTime();
}
if (serverSelectors.length == 0)
{
InetSocketAddress address;
InetAddress[] bindAddresses = getEffectiveBindAddresses();
List tempSelectors = new ArrayList(bindAddresses.length);
listenFailCounts = new int[bindAddresses.length];
for (int i = 0; i < bindAddresses.length; i++)
{
InetAddress bindAddress = bindAddresses[i];
if(!NetworkAdmin.getSingleton().hasIPV6Potential(true) && bindAddress instanceof Inet6Address)
continue;
if (bindAddress != null)
address = new InetSocketAddress(bindAddress, tcp_listen_port);
else
address = new InetSocketAddress(tcp_listen_port);
VirtualServerChannelSelector serverSelector;
if(bindAddresses.length == 1)
serverSelector = VirtualServerChannelSelectorFactory.createBlocking(address, so_rcvbuf_size, selectListener);
else
serverSelector = VirtualServerChannelSelectorFactory.createNonBlocking(address, so_rcvbuf_size, selectListener);
serverSelector.start();
tempSelectors.add(serverSelector);
}
if(tempSelectors.size() == 0)
Logger.log(new LogAlert(true,LogAlert.AT_WARNING,MessageText.getString("network.bindError")));
serverSelectors = (VirtualServerChannelSelector[])tempSelectors.toArray(new VirtualServerChannelSelector[tempSelectors.size()]);
}
} else
{
Logger.log(new LogEvent(LOGID, "Not starting TCP listener on port " + tcp_listen_port + " as protocol disabled"));
}
} finally
{
this_mon.exit();
}
}
示例7: PRUDPPacketHandlerImpl
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
protected
PRUDPPacketHandlerImpl(
int _port,
InetAddress _bind_ip,
PacketTransformer _packet_transformer )
{
port = _port;
explicit_bind_ip = _bind_ip;
packet_transformer = _packet_transformer;
default_bind_ip = NetworkAdmin.getSingleton().getSingleHomedServiceBindAddress();
calcBind();
final AESemaphore init_sem = new AESemaphore("PRUDPPacketHandler:init");
new AEThread2( "PRUDPPacketReciever:" + port, true )
{
public void
run()
{
receiveLoop(init_sem);
}
}.start();
final TimerEventPeriodic[] f_ev = {null};
TimerEventPeriodic ev =
SimpleTimer.addPeriodicEvent(
"PRUDP:timeouts",
5000,
new TimerEventPerformer()
{
public void
perform(
TimerEvent event )
{
if ( destroyed && f_ev[0] != null ){
f_ev[0].cancel();
}
checkTimeouts();
}
});
f_ev[0] = ev;
init_sem.reserve();
}
示例8: calcBind
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
protected void
calcBind()
{
if ( explicit_bind_ip != null ){
if(altProtocolDelegate != null)
{
altProtocolDelegate.destroy();
altProtocolDelegate = null;
}
target_bind_ip = explicit_bind_ip;
}else{
InetAddress altAddress = null;
NetworkAdmin adm = NetworkAdmin.getSingleton();
try
{
if (default_bind_ip instanceof Inet6Address && !default_bind_ip.isAnyLocalAddress() && adm.hasIPV4Potential())
altAddress = adm.getSingleHomedServiceBindAddress(NetworkAdmin.IP_PROTOCOL_VERSION_REQUIRE_V4);
else if (default_bind_ip instanceof Inet4Address && adm.hasIPV6Potential())
altAddress = adm.getSingleHomedServiceBindAddress(NetworkAdmin.IP_PROTOCOL_VERSION_REQUIRE_V6);
} catch (UnsupportedAddressTypeException e)
{
}
if(altProtocolDelegate != null && !altProtocolDelegate.explicit_bind_ip.equals(altAddress))
{
altProtocolDelegate.destroy();
altProtocolDelegate = null;
}
if(altAddress != null && altProtocolDelegate == null)
{
altProtocolDelegate = new PRUDPPacketHandlerImpl(port,altAddress,packet_transformer);
altProtocolDelegate.stats = stats;
altProtocolDelegate.primordial_handlers = primordial_handlers;
altProtocolDelegate.request_handler = request_handler;
}
target_bind_ip = default_bind_ip;
}
}
示例9: dataSourceChanged
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void dataSourceChanged(Object newDataSource) {
if ( !comp_focused ){
focus_pending_ds = newDataSource;
return;
}
// defer this util here so that a blocking call to get the IP doesn't hang UI construction
if ( my_flag == null ){
InetAddress ia = NetworkAdmin.getSingleton().getDefaultPublicAddress();
if ( ia != null ){
my_flag = ImageRepository.getCountryFlag( ia, false );
}
}
DownloadManager old_manager = manager;
if (newDataSource == null){
manager = null;
}else if (newDataSource instanceof Object[]){
Object temp = ((Object[])newDataSource)[0];
if ( temp instanceof DownloadManager ){
manager = (DownloadManager)temp;
}else if ( temp instanceof DiskManagerFileInfo){
manager = ((DiskManagerFileInfo)temp).getDownloadManager();
}else{
return;
}
}else{
if ( newDataSource instanceof DownloadManager ){
manager = (DownloadManager)newDataSource;
}else if ( newDataSource instanceof DiskManagerFileInfo){
manager = ((DiskManagerFileInfo)newDataSource).getDownloadManager();
}else{
return;
}
}
if ( old_manager == manager ){
return;
}
if (old_manager != null){
old_manager.removePeerListener(this);
}
try {
peers_mon.enter();
peers.clear();
} finally {
peers_mon.exit();
}
if (manager != null){
manager.addPeerListener(this);
}
}
示例10: refreshCapacityPanel
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void
refreshCapacityPanel()
{
if ( speedManager == null ){
return;
}
asn.setText(speedManager.getASN());
estUpCap.setText(limit_to_text.getLimitText(speedManager.getEstimatedUploadCapacityBytesPerSec()));
estDownCap.setText(limit_to_text.getLimitText(speedManager.getEstimatedDownloadCapacityBytesPerSec()));
uploadBiaser.setText( DownloadManagerRateController.getString());
InetAddress current_ip = NetworkAdmin.getSingleton().getDefaultPublicAddress();
currentIP.setText(current_ip==null?"":current_ip.getHostAddress() );
}
示例11: sendLTHandshake
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void sendLTHandshake() {
String client_name = Constants.AZUREUS_PROTOCOL_NAME + " " + Constants.AZUREUS_VERSION;
int localTcpPort = TCPNetworkManager.getSingleton().getTCPListeningPortNumber();
String tcpPortOverride = COConfigurationManager.getStringParameter("TCP.Listen.Port.Override");
try
{
localTcpPort = Integer.parseInt(tcpPortOverride);
} catch (NumberFormatException e) {} // ignore as invalid input
boolean require_crypto = NetworkManager.getCryptoRequired( manager.getAdapter().getCryptoLevel());
Map data_dict = new HashMap();
data_dict.put("v", client_name);
data_dict.put("p", new Integer(localTcpPort));
data_dict.put("e", new Long(require_crypto ? 1L : 0L));
boolean upload_only =
manager.isSeeding() &&
!( ENABLE_LAZY_BITFIELD || manual_lazy_bitfield_control || manager.isSuperSeedMode());
// maintain this for any kinds of compatability
data_dict.put( "upload_only", new Long(upload_only? 1L : 0L));
int metainfo_size;
if ( manager.isPrivateTorrent()){
metainfo_size = 0;
}else{
metainfo_size = is_metadata_download?0:manager.getTorrentInfoDictSize();
}
if ( metainfo_size > 0 ){
data_dict.put("metadata_size", new Integer(metainfo_size));
}
NetworkAdmin na = NetworkAdmin.getSingleton();
if ( !na.isSocksActive()){
// don't send public address in handshake
InetAddress defaultV6 = na.hasIPV6Potential(true) ? na.getDefaultPublicAddressV6() : null;
if(defaultV6 != null){
data_dict.put("ipv6",defaultV6.getAddress());
}
}
LTHandshake lt_handshake = new LTHandshake(data_dict, other_peer_bt_lt_ext_version );
lt_handshake.addDefaultExtensionMappings( true, is_metadata_download || metainfo_size > 0, true );
connection.getOutgoingMessageQueue().addMessage(lt_handshake, false);
}
示例12: readConfig
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void
readConfig(
boolean first_time )
{
InetAddress new_internal_address = NetworkAdmin.getSingleton().getSingleHomedServiceBindAddress();
if ( new_internal_address == null ){
try{
new_internal_address = InetAddress.getByName( "0.0.0.0" );
}catch( Throwable e ){
}
}
int[] ports = adapter.getPorts();
int new_tcp_port = ports[0];
int new_udp_port = ports[1];
int new_udp_non_data_port = ports[2];
boolean same = true;
if ( !first_time ){
same = internal_address.equals( new_internal_address) &&
tcp_port == new_tcp_port &&
udp_port == new_udp_port &&
udp_non_data_port == new_udp_non_data_port;
}
internal_address = new_internal_address;
tcp_port = new_tcp_port;
udp_port = new_udp_port;
udp_non_data_port = new_udp_non_data_port;
if ( !same ){
manager.informChanged( this );
}
}
示例13: start
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void start() {
try
{
this_mon.enter();
if (tcp_listen_port < 0 || tcp_listen_port > 65535 || tcp_listen_port == Constants.INSTANCE_PORT )
{
String msg = "Invalid incoming TCP listen port configured, " + tcp_listen_port + ". Port reset to default. Please check your config!";
Debug.out(msg);
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
tcp_listen_port = RandomUtils.generateRandomNetworkListenPort();
COConfigurationManager.setParameter(port_config_key, tcp_listen_port);
}
if (COConfigurationManager.getBooleanParameter(port_enable_config_key))
{
last_non_local_connection_time = COConfigurationManager.getLongParameter( "network.tcp.port." + tcp_listen_port + ".last.nonlocal.incoming", 0 );
if ( last_non_local_connection_time > SystemTime.getCurrentTime()){
last_non_local_connection_time = SystemTime.getCurrentTime();
}
if (serverSelectors.length == 0)
{
InetSocketAddress address;
InetAddress[] bindAddresses = getEffectiveBindAddresses();
List tempSelectors = new ArrayList(bindAddresses.length);
listenFailCounts = new int[bindAddresses.length];
for (int i = 0; i < bindAddresses.length; i++)
{
InetAddress bindAddress = bindAddresses[i];
if(!NetworkAdmin.getSingleton().hasIPV6Potential(true) && bindAddress instanceof Inet6Address)
continue;
if (bindAddress != null)
address = new InetSocketAddress(bindAddress, tcp_listen_port);
else
address = new InetSocketAddress(tcp_listen_port);
VirtualServerChannelSelector serverSelector;
if(bindAddresses.length == 1)
serverSelector = VirtualServerChannelSelectorFactory.createBlocking(address, so_rcvbuf_size, selectListener);
else
serverSelector = VirtualServerChannelSelectorFactory.createNonBlocking(address, so_rcvbuf_size, selectListener);
serverSelector.start();
tempSelectors.add(serverSelector);
}
if(tempSelectors.size() == 0)
Logger.log(new LogAlert(true,LogAlert.AT_WARNING,MessageText.getString("network.bindError")));
serverSelectors = (VirtualServerChannelSelector[])tempSelectors.toArray(new VirtualServerChannelSelector[tempSelectors.size()]);
}
} else
{
Logger.log(new LogEvent(LOGID, "Not starting TCP listener on port " + tcp_listen_port + " as protocol disabled"));
}
} finally
{
this_mon.exit();
}
}
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:70,代码来源:IncomingSocketChannelManager.java
示例14: updateLocalAddresses
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void
updateLocalAddresses(
NetworkAdmin network_admin )
{
NetworkAdminNetworkInterface[] interfaces = network_admin.getInterfaces();
Set<String> ias = new HashSet<String>();
for ( NetworkAdminNetworkInterface intf: interfaces ){
NetworkAdminNetworkInterfaceAddress[] addresses = intf.getAddresses();
for ( NetworkAdminNetworkInterfaceAddress address: addresses ){
InetAddress ia = address.getAddress();
ias.add( ia.getHostAddress());
}
}
local_addresses = ias;
}
示例15: sendLTHandshake
import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; //导入依赖的package包/类
private void sendLTHandshake() {
String client_name = Constants.AZUREUS_PROTOCOL_NAME + " " + Constants.AZUREUS_VERSION;
int localTcpPort = TCPNetworkManager.getSingleton().getTCPListeningPortNumber();
String tcpPortOverride = COConfigurationManager.getStringParameter("TCP.Listen.Port.Override");
try
{
localTcpPort = Integer.parseInt(tcpPortOverride);
} catch (NumberFormatException e) {} // ignore as invalid input
boolean require_crypto = NetworkManager.getCryptoRequired( manager.getAdapter().getCryptoLevel());
Map data_dict = new HashMap();
data_dict.put("v", client_name);
data_dict.put("p", new Integer(localTcpPort));
data_dict.put("e", new Long(require_crypto ? 1L : 0L));
boolean upload_only =
manager.isSeeding() &&
!( ENABLE_LAZY_BITFIELD || manual_lazy_bitfield_control || manager.isSuperSeedMode());
// maintain this for any kinds of compatability
data_dict.put( "upload_only", new Long(upload_only? 1L : 0L));
int metainfo_size;
if ( manager.isPrivateTorrent()){
metainfo_size = 0;
}else{
metainfo_size = is_metadata_download?0:manager.getTorrentInfoDictSize();
}
if ( metainfo_size > 0 ){
data_dict.put("metadata_size", new Integer(metainfo_size));
}
NetworkAdmin na = NetworkAdmin.getSingleton();
if ( peer_item_identity.getNetwork() == AENetworkClassifier.AT_PUBLIC && !na.isSocksActive()){
// don't send public address in handshake
InetAddress defaultV6 = na.hasIPV6Potential(true) ? na.getDefaultPublicAddressV6() : null;
if(defaultV6 != null){
data_dict.put("ipv6",defaultV6.getAddress());
}
}
LTHandshake lt_handshake = new LTHandshake(data_dict, other_peer_bt_lt_ext_version );
lt_handshake.addDefaultExtensionMappings( true, is_metadata_download || metainfo_size > 0, true );
connection.getOutgoingMessageQueue().addMessage(lt_handshake, false);
}