public static boolean isDNSName( String host ) { return( AENetworkClassifier.categoriseAddress( host ) == AENetworkClassifier.AT_PUBLIC ); }
public static boolean isNonDNSName( String host ) { return( AENetworkClassifier.categoriseAddress( host ) != AENetworkClassifier.AT_PUBLIC ); }
public static boolean applyLANRateLimits( InetSocketAddress address ) { if ( i2p_is_lan_limit ){ if ( address.isUnresolved()){ return( AENetworkClassifier.categoriseAddress( address ) == AENetworkClassifier.AT_I2P ); } } return( false ); }
public static InetAddress getByName( String host ) throws UnknownHostException { if ( AENetworkClassifier.categoriseAddress( host ) == AENetworkClassifier.AT_PUBLIC ){ return( InetAddress.getByName( host )); } throw( new UnknownHostException( host )); }
public static InetAddress[] getAllByName( String host ) throws UnknownHostException { if ( AENetworkClassifier.categoriseAddress( host ) == AENetworkClassifier.AT_PUBLIC ){ return( InetAddress.getAllByName( host )); } throw( new UnknownHostException( host )); }
@Override public boolean isAnonymous() { try{ return( AENetworkClassifier.categoriseAddress( new URL( searchURLFormat ).getHost()) != AENetworkClassifier.AT_PUBLIC ); }catch( Throwable e ){ return( false ); } }
public static void main( String[] args ) { String[] tests = { null, "12345", "192.168.1.2", "fred.i2p", "fred.i2", "bill.onion", "bill.onio" }; for ( String str: tests ){ System.out.println( str + " -> " + categoriseAddress( str )); } } }
@Override public String getNetwork() { return( AENetworkClassifier.categoriseAddress( getIp())); }
public static String categoriseAddress( InetSocketAddress isa ) { return( categoriseAddress( AddressUtils.getHostAddress( isa ))); }
public static String adjustHostFromHosting( String host_in ) { if ( tracker_ip.length() > 0 ){ String address_type = AENetworkClassifier.categoriseAddress( host_in ); String target_ip = (String)override_map.get( address_type ); if ( target_ip == null ){ target_ip = tracker_ip; } if ( isLoopback( host_in )){ return( target_ip ); } } return( host_in ); }
public static String getPublicIPOverride() { String explicit_ips = COConfigurationManager.getStringParameter( "Override Ip", "" ); if ( explicit_ips.length() > 0 ){ StringTokenizer tok = new StringTokenizer( explicit_ips, ";" ); while( tok.hasMoreTokens()){ String this_address = tok.nextToken().trim(); if ( this_address.length() > 0 ){ String cat = AENetworkClassifier.categoriseAddress( this_address ); if ( cat == AENetworkClassifier.AT_PUBLIC ){ return( this_address ); } } } } return( null ); }
protected PeerItem( String _address, int _tcp_port, byte _source, byte _handshake, int _udp_port, byte _crypto_level, int _up_speed ) { byte[] raw; network = AENetworkClassifier.categoriseAddress( _address ); try{ if ( network == AENetworkClassifier.AT_PUBLIC ){ try{ //see if we can resolve the address into a compact raw IPv4/6 byte array (4 or 16 bytes) InetAddress ip = InetAddress.getByName( _address ); raw = ip.getAddress(); } catch( UnknownHostException e ) { //not a standard IPv4/6 address, so just use the full string bytes raw = _address.getBytes( "ISO8859-1" ); } }else{ raw = _address.getBytes( "ISO8859-1" ); } }catch( UnsupportedEncodingException e ){ raw = _address.getBytes(); } address = raw; tcp_port = (short)_tcp_port; udp_port = (short)_udp_port; source = _source; hashcode = new String( address ).hashCode() + tcp_port; handshake = _handshake; crypto_level = _crypto_level; up_speed = (short)_up_speed; priority = PeerUtils.getPeerPriority( address, tcp_port ); }
public static DNSTXTEntry getDNSTXTEntry( URL url ) { if ( isDecentralised( url )){ return( null ); } String host = url.getHost(); String tracker_network = AENetworkClassifier.categoriseAddress( host ); if ( tracker_network != AENetworkClassifier.AT_PUBLIC ){ return( null ); } return( getDNSTXTEntry( host, false, null )); }
public static String adjustLink( String link ) { if ( link == null || link.length() < 5 ){ return( link ); } char c = link.charAt(0); if ( c == 'h' || c == 'H' || c == 'f' || c == 'F' ){ if ( MetaSearchManagerFactory.getSingleton().getProxyRequestsEnabled()){ try{ String host = new URL( link ).getHost(); if ( AENetworkClassifier.categoriseAddress( host ) != AENetworkClassifier.AT_PUBLIC ){ return( link ); } InetAddress ia = HostNameToIPResolver.hostAddressToInetAddress( host ); if ( ia != null ){ if ( ia.isLoopbackAddress() || ia.isLinkLocalAddress() || ia.isSiteLocalAddress()){ return( link ); } } }catch( Throwable e ){ } return( "tor:" + link ); } } return( link ); }
@Override public boolean isNetworkEnabled( HashWrapper hash, URL url ) { DownloadManager dm = getDownloadManager(hash); if ( dm == null ){ return( false ); } String nw = AENetworkClassifier.categoriseAddress( url.getHost()); String[] networks = dm.getDownloadState().getNetworks(); for (int i=0;i<networks.length;i++){ if ( networks[i] == nw ){ return( true ); } } return( false ); }
protected void addExplicitSources() { for (int i=0;i<sources.length;i++){ try{ InetSocketAddress source = sources[i]; if ( AENetworkClassifier.categoriseAddress( source ) == AENetworkClassifier.AT_PUBLIC ){ contactFound( db.importContact(sources[i])); } }catch( Throwable e ){ Debug.printStackTrace(e); } } }
public static String getNetwork( PEPeer peer ) { if ( peer == null ){ return( null ); } String net = (String)peer.getUserData( net_key ); if ( net == null ){ net = AENetworkClassifier.categoriseAddress( peer.getIp()); peer.setUserData( net_key, net ); } return( net ); }
@Override public void run(PEPeer peer) { boolean sel = boost_item.getSelection(); if ( AENetworkClassifier.categoriseAddress( peer.getIp()) == AENetworkClassifier.AT_PUBLIC ){ DownloadManager dm = peer_dm_map.get( peer ); if ( dm != null ){ bp.setPartialBuddy( PluginCoreUtils.wrap( dm ), PluginCoreUtils.wrap( peer ), sel ); } } } });
private static final class QueueEntry { public QueueEntry(PEPeerTransportProtocol trans) { transport = trans; } final PEPeerTransportProtocol transport; final long addTime = SystemTime.getMonotonousTime(); }
public PEPeerTransportProtocol( PEPeerControl _manager, String _peer_source, NetworkConnection _connection, Map _initial_user_data ) { manager = _manager; peer_source = _peer_source; connection = _connection; data = _initial_user_data; incoming = true; is_metadata_download = manager.isMetadataDownload(); diskManager =manager.getDiskManager(); piecePicker =manager.getPiecePicker(); nbPieces =diskManager.getNbPieces(); InetSocketAddress notional_address = _connection.getEndpoint().getNotionalAddress(); ip = AddressUtils.getHostAddress( notional_address ); network = AENetworkClassifier.categoriseAddress( ip ); port = notional_address.getPort(); peer_item_identity = PeerItemFactory.createPeerItem( ip, port, PeerItem.convertSourceID( _peer_source ), PeerItemFactory.HANDSHAKE_TYPE_PLAIN, 0, PeerItemFactory.CRYPTO_LEVEL_1, 0 ); //this will be recreated upon az handshake decode plugin_connection = new ConnectionImpl(connection, incoming); peer_stats = manager.createPeerStats( this ); changePeerState( PEPeer.CONNECTING ); }