public MobicentsExtendedListeningPoint findMatchingListeningPoint ( final String ipAddress , int port , String transport ) { String tmpTransport = transport ; int portChecked = checkPortRange ( port , tmpTransport ) ; if ( tmpTransport == null ) { tmpTransport = ListeningPoint . UDP ; } // we check first if a listening point can be found (we only do the host resolving if not found to have better perf ) MobicentsExtendedListeningPoint listeningPoint = null ; if ( ipAddress . indexOf ( ' ' ) != - 1 ) { String ipAddressTmp = extractIPV6Brackets ( ipAddress ) ; // IPv6 here, Jain-Sip stack remove scope zone which is included in the key of listener object for ( String key : extendedListeningPointsCacheMap . keySet ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Find listening point for IPv6: " + key + " compare: " + ipAddressTmp + " port " + portChecked + " transport " + tmpTransport . toLowerCase ( ) ) ; } if ( key . contains ( ipAddressTmp ) && key . contains ( String . valueOf ( portChecked ) + ":" + tmpTransport . toLowerCase ( ) ) ) { listeningPoint = extendedListeningPointsCacheMap . get ( key ) ; break ; } } } else { listeningPoint = extendedListeningPointsCacheMap . get ( ipAddress + "/" + portChecked + ":" + tmpTransport . toLowerCase ( ) ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Checked Listening Point " + ipAddress + "/" + portChecked + ":" + tmpTransport . toLowerCase ( ) + " against existing listening points, found " + listeningPoint ) ; } if ( listeningPoint == null && ! Inet6Util . isValidIP6Address ( ipAddress ) && ! Inet6Util . isValidIPV4Address ( ipAddress ) ) { // if no listening point has been found and the ipaddress is not a valid IP6 address nor a valid IPV4 address // then we try to resolve it as a hostname Queue < Hop > hops = null ; try { hops = sipApplicationDispatcher . getDNSServerLocator ( ) . getDnsLookupPerformer ( ) . locateHopsForNonNumericAddressWithPort ( ipAddress , portChecked , tmpTransport . toLowerCase ( ) ) ; } catch ( Exception e ) { // not important it can mean that the ipAddress provided is not a hostname // but an ip address not found in the searched listening points above } if ( hops != null ) { for ( Hop hop : hops ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Checking Hop " + hop . getHost ( ) + "/" + portChecked + ":" + tmpTransport . toLowerCase ( ) + " against existing listening points" ) ; } listeningPoint = extendedListeningPointsCacheMap . get ( hop . getHost ( ) + "/" + portChecked + ":" + tmpTransport . toLowerCase ( ) ) ; if ( listeningPoint != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Found listening point " + listeningPoint ) ; } return listeningPoint ; } } } } return listeningPoint ; }
Retrieve the first matching listening Point corresponding to the ipAddress port and transport given in parameter .