26
26
27
27
'use strict' ;
28
28
29
- const { lookup} = require ( 'dns' ) . promises ;
30
29
const errors = require ( "../../errors.js" ) ;
31
30
32
31
// The host information pattern of the EZConnect URL format.
@@ -71,14 +70,7 @@ const DESCRIPTION_PARAMS = ["ENABLE", "FAILOVER", "LOAD_BALANCE",
71
70
class EZConnectResolver {
72
71
constructor ( url ) {
73
72
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 ;
82
74
this . resolvedUrl = '' ;
83
75
this . connectionProps = new Map ( ) ;
84
76
this . urlProps = new Map ( ) ;
@@ -89,8 +81,8 @@ class EZConnectResolver {
89
81
* Returns the resolved long TNS String.
90
82
* @return Resolved TNS URL.
91
83
*/
92
- async getResolvedUrl ( ) {
93
- await this . parse ( ) ;
84
+ getResolvedUrl ( ) {
85
+ this . parse ( ) ;
94
86
return this . resolvedUrl ;
95
87
}
96
88
@@ -99,29 +91,22 @@ class EZConnectResolver {
99
91
* After parsing the extended settings if the remaining part of the URL is in
100
92
* EZConnectURL format then resolve it to long TNS url format.
101
93
*/
102
- async parse ( ) {
94
+ parse ( ) {
103
95
// First try to parse the extended settings part of the URL.
104
96
let parsedUrl = this . parseExtendedSettings ( this . url ) ;
105
97
if ( this . connectionProps . size === 0 && this . urlProps . size === 0 ) {
106
98
// If we have not parsed anything then use the received url as is.
107
99
parsedUrl = this . url ;
108
100
}
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 ) ;
118
103
}
119
104
/**
120
105
* Translate the given ezconnect url format to Long TNS format.
121
106
* @param url EZConnect URL
122
107
* @return Returns resolved TNS url.
123
108
*/
124
- async resolveToLongURLFormat ( url ) {
109
+ resolveToLongURLFormat ( url ) {
125
110
// URL is in the following format
126
111
// [protocol://]host1[,host13][:port1][,host2:port2][/service_name][:server][/instance_name]
127
112
@@ -151,7 +136,7 @@ class EZConnectResolver {
151
136
const proxyHost = this . urlProps . get ( "HTTPS_PROXY" ) ;
152
137
const proxyPort = this . urlProps . get ( "HTTPS_PROXY_PORT" ) ;
153
138
const addressInfo =
154
- await this . buildAddressList ( hostInfo , protocol , proxyHost , proxyPort ) ;
139
+ this . buildAddressList ( hostInfo , protocol , proxyHost , proxyPort ) ;
155
140
156
141
const connectionIdPrefix =
157
142
this . urlProps . get ( "CONNECTION_ID_PREFIX" ) ;
@@ -210,10 +195,8 @@ class EZConnectResolver {
210
195
* @param proxyPort proxy server port [optional].
211
196
* @return address information of the DESCRIPTION node.
212
197
*/
213
- async buildAddressList ( hostInfo , protocol ,
198
+ buildAddressList ( hostInfo , protocol ,
214
199
proxyHost , proxyPort ) {
215
- let shost = '' ;
216
- let ipcnt = 0 ;
217
200
const builder = new Array ( ) ;
218
201
let proxyInfo = '' ;
219
202
if ( proxyHost != null ) {
@@ -239,7 +222,6 @@ class EZConnectResolver {
239
222
}
240
223
for ( const hname in hostnames ) {
241
224
addressListBuilder . push ( this . getAddrStr ( hostnames [ hname ] , port , protocol , proxyInfo ) ) ;
242
- shost = hostnames [ hname ] ;
243
225
addressNodeCount ++ ;
244
226
}
245
227
}
@@ -253,21 +235,6 @@ class EZConnectResolver {
253
235
else
254
236
builder . push ( parts . join ( '' ) ) ;
255
237
}
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
- }
271
238
272
239
if ( addressLists . length < 2 && naddr > 1 ) {
273
240
this . lb = true ;
0 commit comments