FileDocCategorySizeDatePackage
AZPortClashHandler.javaAPI DocAzureus 3.0.3.43620Mon Jul 17 13:14:22 BST 2006com.aelitis.azureus.core.instancemanager.impl

AZPortClashHandler

public class AZPortClashHandler extends Object implements com.aelitis.azureus.core.instancemanager.AZInstanceManagerListener

Fields Summary
private com.aelitis.azureus.core.instancemanager.AZInstance
my_instance
private int
last_warned_tcp
private int
last_warned_udp
private int
last_warned_udp2
Constructors Summary
protected AZPortClashHandler(AZInstanceManagerImpl inst_man)

		my_instance = inst_man.getMyInstance();
		
		inst_man.addListener( this );
	
Methods Summary
protected voidcheck(com.aelitis.azureus.core.instancemanager.AZInstance instance)

		if ( instance == my_instance ){
			
			return;
		}
		
		InetAddress	my_ext 		= my_instance.getExternalAddress();
		InetAddress	other_ext 	= instance.getExternalAddress();
		
		if ( 	my_ext.isLoopbackAddress() || 
				other_ext.isLoopbackAddress() ||
				my_ext.equals( other_ext )){
		
			String	warning = null;
			
			int	my_tcp = my_instance.getTCPListenPort();
			
			if ( my_tcp != 0 && my_tcp != last_warned_tcp && my_tcp == instance.getTCPListenPort()){
				
				warning = "TCP " + my_tcp;
				
				last_warned_tcp	= my_tcp;
			}
			
			int	my_udp 	= my_instance.getUDPListenPort();
			int my_udp2	= my_instance.getUDPNonDataListenPort();
			
			int	other_udp 	= instance.getUDPListenPort();
			int other_udp2	= instance.getUDPNonDataListenPort();
			
			if ( my_udp != 0 && my_udp != last_warned_udp && ( my_udp == other_udp || my_udp == other_udp2 )){
				
				warning = (warning==null?"":(warning + ", ")) + "UDP " + my_udp;
				
				last_warned_udp	= my_udp;
			}
			
			if ( my_udp != my_udp2 && my_udp2 != 0 && my_udp2 != last_warned_udp2 && ( my_udp2 == other_udp || my_udp2 == other_udp2 )){
				
				warning = (warning==null?"":(warning + ", ")) + "UDP " + my_udp2;
				
				last_warned_udp2	= my_udp2;
			}
			
			
			if ( warning != null ){
				
				Logger.logTextResource(
					new LogAlert(true, LogAlert.AT_WARNING,"azinstancehandler.alert.portclash"),
					new String[]{ 
						warning, 
						String.valueOf(RandomUtils.LISTEN_PORT_MIN ), 
						String.valueOf(RandomUtils.LISTEN_PORT_MAX)});
			}
		}
	
public voidinstanceChanged(com.aelitis.azureus.core.instancemanager.AZInstance instance)

		check( instance );
	
public voidinstanceFound(com.aelitis.azureus.core.instancemanager.AZInstance instance)

		check( instance );
	
public voidinstanceLost(com.aelitis.azureus.core.instancemanager.AZInstance instance)

	
	
public voidinstanceTracked(com.aelitis.azureus.core.instancemanager.AZInstanceTracked instance)