2626
2727'use strict' ;
2828
29- const { lookup} = require ( 'dns' ) . promises ;
3029const errors = require ( "../../errors.js" ) ;
3130
3231// The host information pattern of the EZConnect URL format.
@@ -71,14 +70,7 @@ const DESCRIPTION_PARAMS = ["ENABLE", "FAILOVER", "LOAD_BALANCE",
7170class EZConnectResolver {
7271 constructor ( url ) {
7372 this . URL_PROPS_ALIAS = this . initializeUrlAlias ( ) ;
74- const jdbcUrlPrefix = url . indexOf ( '@' ) ;
75- if ( jdbcUrlPrefix != - 1 ) {
76- this . url = url . substring ( jdbcUrlPrefix + 1 ) ;
77- this . urlPrefix = url . substring ( 0 , jdbcUrlPrefix + 1 ) ;
78- } else {
79- this . url = url ;
80- this . urlPrefix = "" ;
81- }
73+ this . url = url ;
8274 this . resolvedUrl = '' ;
8375 this . connectionProps = new Map ( ) ;
8476 this . urlProps = new Map ( ) ;
@@ -89,8 +81,8 @@ class EZConnectResolver {
8981 * Returns the resolved long TNS String.
9082 * @return Resolved TNS URL.
9183 */
92- async getResolvedUrl ( ) {
93- await this . parse ( ) ;
84+ getResolvedUrl ( ) {
85+ this . parse ( ) ;
9486 return this . resolvedUrl ;
9587 }
9688
@@ -99,29 +91,22 @@ class EZConnectResolver {
9991 * After parsing the extended settings if the remaining part of the URL is in
10092 * EZConnectURL format then resolve it to long TNS url format.
10193 */
102- async parse ( ) {
94+ parse ( ) {
10395 // First try to parse the extended settings part of the URL.
10496 let parsedUrl = this . parseExtendedSettings ( this . url ) ;
10597 if ( this . connectionProps . size === 0 && this . urlProps . size === 0 ) {
10698 // If we have not parsed anything then use the received url as is.
10799 parsedUrl = this . url ;
108100 }
109-
110- if ( parsedUrl . startsWith ( "(" ) ) {
111- // Skip resolve the URL if it is in TNS format,
112- // TNS format starts with '('
113- this . resolvedUrl = this . urlPrefix + parsedUrl ;
114- } else {
115- // Try to resolve the EZConnectURL to Long TNS URL.
116- this . resolvedUrl = this . urlPrefix + await this . resolveToLongURLFormat ( parsedUrl ) ;
117- }
101+ // Try to resolve the EZConnectURL to Long TNS URL.
102+ this . resolvedUrl = this . resolveToLongURLFormat ( parsedUrl ) ;
118103 }
119104 /**
120105 * Translate the given ezconnect url format to Long TNS format.
121106 * @param url EZConnect URL
122107 * @return Returns resolved TNS url.
123108 */
124- async resolveToLongURLFormat ( url ) {
109+ resolveToLongURLFormat ( url ) {
125110 // URL is in the following format
126111 // [protocol://]host1[,host13][:port1][,host2:port2][/service_name][:server][/instance_name]
127112
@@ -151,7 +136,7 @@ class EZConnectResolver {
151136 const proxyHost = this . urlProps . get ( "HTTPS_PROXY" ) ;
152137 const proxyPort = this . urlProps . get ( "HTTPS_PROXY_PORT" ) ;
153138 const addressInfo =
154- await this . buildAddressList ( hostInfo , protocol , proxyHost , proxyPort ) ;
139+ this . buildAddressList ( hostInfo , protocol , proxyHost , proxyPort ) ;
155140
156141 const connectionIdPrefix =
157142 this . urlProps . get ( "CONNECTION_ID_PREFIX" ) ;
@@ -210,10 +195,8 @@ class EZConnectResolver {
210195* @param proxyPort proxy server port [optional].
211196* @return address information of the DESCRIPTION node.
212197*/
213- async buildAddressList ( hostInfo , protocol ,
198+ buildAddressList ( hostInfo , protocol ,
214199 proxyHost , proxyPort ) {
215- let shost = '' ;
216- let ipcnt = 0 ;
217200 const builder = new Array ( ) ;
218201 let proxyInfo = '' ;
219202 if ( proxyHost != null ) {
@@ -239,7 +222,6 @@ class EZConnectResolver {
239222 }
240223 for ( const hname in hostnames ) {
241224 addressListBuilder . push ( this . getAddrStr ( hostnames [ hname ] , port , protocol , proxyInfo ) ) ;
242- shost = hostnames [ hname ] ;
243225 addressNodeCount ++ ;
244226 }
245227 }
@@ -253,21 +235,6 @@ class EZConnectResolver {
253235 else
254236 builder . push ( parts . join ( '' ) ) ;
255237 }
256- if ( naddr == 1 ) {
257- shost = shost . trim ( ) ;
258- // If it is IPV6 format address then remove the enclosing '[' and ']'
259- if ( shost . startsWith ( "[" ) && shost . endsWith ( "]" ) )
260- shost = shost . substring ( 1 , shost . length - 1 ) ;
261- try {
262- await lookup ( shost ) ;
263- ipcnt ++ ;
264- } catch {
265- // nothing
266- }
267- if ( ipcnt == 0 ) {
268- errors . throwErr ( errors . ERR_INVALID_EZCONNECT_SYNTAX , 'could not resolve hostname' , shost ) ;
269- }
270- }
271238
272239 if ( addressLists . length < 2 && naddr > 1 ) {
273240 this . lb = true ;
0 commit comments