FileDocCategorySizeDatePackage
ConnectionEndpoint.javaAPI DocAzureus 3.0.3.43846Wed Feb 14 17:18:58 GMT 2007com.aelitis.azureus.core.networkmanager

ConnectionEndpoint

public class ConnectionEndpoint extends Object

Fields Summary
private InetSocketAddress
notional_address
private ProtocolEndpoint[]
protocols
Constructors Summary
public ConnectionEndpoint(InetSocketAddress _notional_address)

		notional_address	= _notional_address;
	
Methods Summary
public voidaddProtocol(ProtocolEndpoint ep)

		if ( protocols == null ){
			
			protocols = new ProtocolEndpoint[]{ ep };
			
		}else{
		
			for (int i=0;i<protocols.length;i++){
				
				if ( protocols[i] == ep ){
					
					return;
				}
			}
			
			ProtocolEndpoint[]	new_ep = new ProtocolEndpoint[ protocols.length + 1 ];
			
			System.arraycopy( protocols, 0, new_ep, 0, protocols.length );
			
			new_ep[ protocols.length ] = ep;
			
			protocols	= new_ep;
		}
		
		ep.setConnectionEndpoint( this );
	
public ConnectionAttemptconnectOutbound(boolean connect_with_crypto, boolean allow_fallback, byte[][] shared_secrets, java.nio.ByteBuffer initial_data, com.aelitis.azureus.core.networkmanager.Transport.ConnectListener listener)

		ProtocolEndpoint	protocol = protocols[0];
		
		final Transport transport = protocol.connectOutbound( connect_with_crypto, allow_fallback, shared_secrets, initial_data, listener );
		
		return( 
			new ConnectionAttempt()
			{
				public void 
				abandon() 
				{
					if ( transport != null ){
						
						transport.close( "Connection attempt abandoned" );
					}
				}
			});
	
public java.lang.StringgetDescription()

		String	str = "[";
		
		for (int i=0;i<protocols.length;i++){
			
			str += (i==0?"":",") + protocols[i].getDescription();
		}
		
		return( str + "]" );
	
public java.net.InetSocketAddressgetNotionalAddress()

		return( notional_address );
	
public ProtocolEndpoint[]getProtocols()

		if ( protocols == null ){
			
			return( new ProtocolEndpoint[0] );
		}
		
		return( protocols );
	
public booleanmatchIP(java.lang.String ip)

		if ( matchIP( ip, notional_address )){
			
			return( true );
		}
		
		ProtocolEndpoint[]	peps = getProtocols();
		
		for (int i=0;i<peps.length;i++){
			
			ProtocolEndpoint	pep = peps[i];
			
			if ( pep.getType() == ProtocolEndpoint.PROTOCOL_TCP ){
				
				ProtocolEndpointTCP	tcp = (ProtocolEndpointTCP)pep;
				
				if ( matchIP( ip, tcp.getAddress())){
					
					return( true );
				}
			}else{
				
				ProtocolEndpointUDP	tcp = (ProtocolEndpointUDP)pep;
				
				if ( matchIP( ip, tcp.getAddress())){
					
					return( true );
				}				
			}
		}
		
		return( false );
	
protected booleanmatchIP(java.lang.String ip, java.net.InetSocketAddress address)

		return( ip.equals( address.getAddress().getHostAddress()));