]> git.proxmox.com Git - proxmox-widget-toolkit.git/blob - Utils.js
fix typo
[proxmox-widget-toolkit.git] / Utils.js
1 Ext.ns('Proxmox');
2 Ext.ns('Proxmox.Setup');
3
4 if (!Ext.isDefined(Proxmox.Setup.auth_cookie_name)) {
5 throw "Proxmox library not initialized";
6 }
7
8 // avoid errors related to Accessible Rich Internet Applications
9 // (access for people with disabilities)
10 // TODO reenable after all components are upgraded
11 Ext.enableAria = false;
12 Ext.enableAriaButtons = false;
13 Ext.enableAriaPanels = false;
14
15 // avoid errors when running without development tools
16 if (!Ext.isDefined(Ext.global.console)) {
17 var console = {
18 dir: function() {},
19 log: function() {}
20 };
21 }
22
23 Ext.Ajax.defaultHeaders = {
24 'Accept': 'application/json'
25 };
26
27 Ext.Ajax.on('beforerequest', function(conn, options) {
28 if (Proxmox.CSRFPreventionToken) {
29 if (!options.headers) {
30 options.headers = {};
31 }
32 options.headers.CSRFPreventionToken = Proxmox.CSRFPreventionToken;
33 }
34 });
35
36 Ext.define('Proxmox.Utils', { utilities: {
37
38 // this singleton contains miscellaneous utilities
39
40 yesText: gettext('Yes'),
41 noText: gettext('No'),
42 enabledText: gettext('Enabled'),
43 disabledText: gettext('Disabled'),
44 noneText: gettext('none'),
45 errorText: gettext('Error'),
46 unknownText: gettext('Unknown'),
47 defaultText: gettext('Default'),
48 daysText: gettext('days'),
49 dayText: gettext('day'),
50 runningText: gettext('running'),
51 stoppedText: gettext('stopped'),
52 neverText: gettext('never'),
53 totalText: gettext('Total'),
54 usedText: gettext('Used'),
55 directoryText: gettext('Directory'),
56 stateText: gettext('State'),
57 groupText: gettext('Group'),
58
59 language_map: {
60 zh_CN: 'Chinese (Simplified)',
61 zh_TW: 'Chinese (Traditional)',
62 ca: 'Catalan',
63 da: 'Danish',
64 en: 'English',
65 eu: 'Euskera (Basque)',
66 fr: 'French',
67 de: 'German',
68 it: 'Italian',
69 es: 'Spanish',
70 ja: 'Japanese',
71 nb: 'Norwegian (Bokmal)',
72 nn: 'Norwegian (Nynorsk)',
73 fa: 'Persian (Farsi)',
74 pl: 'Polish',
75 pt_BR: 'Portuguese (Brazil)',
76 ru: 'Russian',
77 sl: 'Slovenian',
78 sv: 'Swedish',
79 tr: 'Turkish'
80 },
81
82 render_language: function (value) {
83 if (!value) {
84 return Proxmox.Utils.defaultText + ' (English)';
85 }
86 var text = Proxmox.Utils.language_map[value];
87 if (text) {
88 return text + ' (' + value + ')';
89 }
90 return value;
91 },
92
93 language_array: function() {
94 var data = [['__default__', Proxmox.Utils.render_language('')]];
95 Ext.Object.each(Proxmox.Utils.language_map, function(key, value) {
96 data.push([key, Proxmox.Utils.render_language(value)]);
97 });
98
99 return data;
100 },
101
102 getNoSubKeyHtml: function(url) {
103 // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
104 return Ext.String.format('You do not have a valid subscription for this server. Please visit <a target="_blank" href="{0}">www.proxmox.com</a> to get a list of available options.', url || 'http://www.proxmox.com');
105 },
106
107 format_boolean_with_default: function(value) {
108 if (Ext.isDefined(value) && value !== '__default__') {
109 return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
110 }
111 return Proxmox.Utils.defaultText;
112 },
113
114 format_boolean: function(value) {
115 return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
116 },
117
118 format_neg_boolean: function(value) {
119 return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
120 },
121
122 format_enabled_toggle: function(value) {
123 return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
124 },
125
126 format_expire: function(date) {
127 if (!date) {
128 return Proxmox.Utils.neverText;
129 }
130 return Ext.Date.format(date, "Y-m-d");
131 },
132
133 format_duration_long: function(ut) {
134
135 var days = Math.floor(ut / 86400);
136 ut -= days*86400;
137 var hours = Math.floor(ut / 3600);
138 ut -= hours*3600;
139 var mins = Math.floor(ut / 60);
140 ut -= mins*60;
141
142 var hours_str = '00' + hours.toString();
143 hours_str = hours_str.substr(hours_str.length - 2);
144 var mins_str = "00" + mins.toString();
145 mins_str = mins_str.substr(mins_str.length - 2);
146 var ut_str = "00" + ut.toString();
147 ut_str = ut_str.substr(ut_str.length - 2);
148
149 if (days) {
150 var ds = days > 1 ? Proxmox.Utils.daysText : Proxmox.Utils.dayText;
151 return days.toString() + ' ' + ds + ' ' +
152 hours_str + ':' + mins_str + ':' + ut_str;
153 } else {
154 return hours_str + ':' + mins_str + ':' + ut_str;
155 }
156 },
157
158 format_subscription_level: function(level) {
159 if (level === 'c') {
160 return 'Community';
161 } else if (level === 'b') {
162 return 'Basic';
163 } else if (level === 's') {
164 return 'Standard';
165 } else if (level === 'p') {
166 return 'Premium';
167 } else {
168 return Proxmox.Utils.noneText;
169 }
170 },
171
172 compute_min_label_width: function(text, width) {
173
174 if (width === undefined) { width = 100; }
175
176 var tm = new Ext.util.TextMetrics();
177 var min = tm.getWidth(text + ':');
178
179 return min < width ? width : min;
180 },
181
182 authOK: function() {
183 return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
184 },
185
186 authClear: function() {
187 Ext.util.Cookies.clear(Proxmox.Setup.auth_cookie_name);
188 },
189
190 // comp.setLoading() is buggy in ExtJS 4.0.7, so we
191 // use el.mask() instead
192 setErrorMask: function(comp, msg) {
193 var el = comp.el;
194 if (!el) {
195 return;
196 }
197 if (!msg) {
198 el.unmask();
199 } else {
200 if (msg === true) {
201 el.mask(gettext("Loading..."));
202 } else {
203 el.mask(msg);
204 }
205 }
206 },
207
208 monStoreErrors: function(me, store, clearMaskBeforeLoad) {
209 if (clearMaskBeforeLoad) {
210 me.mon(store, 'beforeload', function(s, operation, eOpts) {
211 Proxmox.Utils.setErrorMask(me, false);
212 });
213 } else {
214 me.mon(store, 'beforeload', function(s, operation, eOpts) {
215 if (!me.loadCount) {
216 me.loadCount = 0; // make sure it is numeric
217 Proxmox.Utils.setErrorMask(me, true);
218 }
219 });
220 }
221
222 // only works with 'proxmox' proxy
223 me.mon(store.proxy, 'afterload', function(proxy, request, success) {
224 me.loadCount++;
225
226 if (success) {
227 Proxmox.Utils.setErrorMask(me, false);
228 return;
229 }
230
231 var msg;
232 /*jslint nomen: true */
233 var operation = request._operation;
234 var error = operation.getError();
235 if (error.statusText) {
236 msg = error.statusText + ' (' + error.status + ')';
237 } else {
238 msg = gettext('Connection error');
239 }
240 Proxmox.Utils.setErrorMask(me, msg);
241 });
242 },
243
244 extractRequestError: function(result, verbose) {
245 var msg = gettext('Successful');
246
247 if (!result.success) {
248 msg = gettext("Unknown error");
249 if (result.message) {
250 msg = result.message;
251 if (result.status) {
252 msg += ' (' + result.status + ')';
253 }
254 }
255 if (verbose && Ext.isObject(result.errors)) {
256 msg += "<br>";
257 Ext.Object.each(result.errors, function(prop, desc) {
258 msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
259 Ext.htmlEncode(desc);
260 });
261 }
262 }
263
264 return msg;
265 },
266
267 // Ext.Ajax.request
268 API2Request: function(reqOpts) {
269
270 var newopts = Ext.apply({
271 waitMsg: gettext('Please wait...')
272 }, reqOpts);
273
274 if (!newopts.url.match(/^\/api2/)) {
275 newopts.url = '/api2/extjs' + newopts.url;
276 }
277 delete newopts.callback;
278
279 var createWrapper = function(successFn, callbackFn, failureFn) {
280 Ext.apply(newopts, {
281 success: function(response, options) {
282 if (options.waitMsgTarget) {
283 if (Proxmox.Utils.toolkit === 'touch') {
284 options.waitMsgTarget.setMasked(false);
285 } else {
286 options.waitMsgTarget.setLoading(false);
287 }
288 }
289 var result = Ext.decode(response.responseText);
290 response.result = result;
291 if (!result.success) {
292 response.htmlStatus = Proxmox.Utils.extractRequestError(result, true);
293 Ext.callback(callbackFn, options.scope, [options, false, response]);
294 Ext.callback(failureFn, options.scope, [response, options]);
295 return;
296 }
297 Ext.callback(callbackFn, options.scope, [options, true, response]);
298 Ext.callback(successFn, options.scope, [response, options]);
299 },
300 failure: function(response, options) {
301 if (options.waitMsgTarget) {
302 if (Proxmox.Utils.toolkit === 'touch') {
303 options.waitMsgTarget.setMasked(false);
304 } else {
305 options.waitMsgTarget.setLoading(false);
306 }
307 }
308 response.result = {};
309 try {
310 response.result = Ext.decode(response.responseText);
311 } catch(e) {}
312 var msg = gettext('Connection error') + ' - server offline?';
313 if (response.aborted) {
314 msg = gettext('Connection error') + ' - aborted.';
315 } else if (response.timedout) {
316 msg = gettext('Connection error') + ' - Timeout.';
317 } else if (response.status && response.statusText) {
318 msg = gettext('Connection error') + ' ' + response.status + ': ' + response.statusText;
319 }
320 response.htmlStatus = msg;
321 Ext.callback(callbackFn, options.scope, [options, false, response]);
322 Ext.callback(failureFn, options.scope, [response, options]);
323 }
324 });
325 };
326
327 createWrapper(reqOpts.success, reqOpts.callback, reqOpts.failure);
328
329 var target = newopts.waitMsgTarget;
330 if (target) {
331 if (Proxmox.Utils.toolkit === 'touch') {
332 target.setMasked({ xtype: 'loadmask', message: newopts.waitMsg} );
333 } else {
334 // Note: ExtJS bug - this does not work when component is not rendered
335 target.setLoading(newopts.waitMsg);
336 }
337 }
338 Ext.Ajax.request(newopts);
339 },
340
341 checked_command: function(orig_cmd) {
342 Proxmox.Utils.API2Request({
343 url: '/nodes/localhost/subscription',
344 method: 'GET',
345 //waitMsgTarget: me,
346 failure: function(response, opts) {
347 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
348 },
349 success: function(response, opts) {
350 var data = response.result.data;
351
352 if (data.status !== 'Active') {
353 Ext.Msg.show({
354 title: gettext('No valid subscription'),
355 icon: Ext.Msg.WARNING,
356 msg: Proxmox.Utils.getNoSubKeyHtml(data.url),
357 buttons: Ext.Msg.OK,
358 callback: function(btn) {
359 if (btn !== 'ok') {
360 return;
361 }
362 orig_cmd();
363 }
364 });
365 } else {
366 orig_cmd();
367 }
368 }
369 });
370 },
371
372 assemble_field_data: function(values, data) {
373 if (Ext.isObject(data)) {
374 Ext.Object.each(data, function(name, val) {
375 if (values.hasOwnProperty(name)) {
376 var bucket = values[name];
377 if (!Ext.isArray(bucket)) {
378 bucket = values[name] = [bucket];
379 }
380 if (Ext.isArray(val)) {
381 values[name] = bucket.concat(val);
382 } else {
383 bucket.push(val);
384 }
385 } else {
386 values[name] = val;
387 }
388 });
389 }
390 },
391
392 dialog_title: function(subject, create, isAdd) {
393 if (create) {
394 if (isAdd) {
395 return gettext('Add') + ': ' + subject;
396 } else {
397 return gettext('Create') + ': ' + subject;
398 }
399 } else {
400 return gettext('Edit') + ': ' + subject;
401 }
402 },
403
404 network_iface_types: {
405 eth: gettext("Network Device"),
406 bridge: 'Linux Bridge',
407 bond: 'Linux Bond',
408 vlan: 'Linux VLAN',
409 OVSBridge: 'OVS Bridge',
410 OVSBond: 'OVS Bond',
411 OVSPort: 'OVS Port',
412 OVSIntPort: 'OVS IntPort'
413 },
414
415 render_network_iface_type: function(value) {
416 return Proxmox.Utils.network_iface_types[value] ||
417 Proxmox.Utils.unknownText;
418 },
419
420 task_desc_table: {
421 acmenewcert: [ 'SRV', gettext('Order Certificate') ],
422 acmeregister: [ 'ACME Account', gettext('Register') ],
423 acmedeactivate: [ 'ACME Account', gettext('Deactivate') ],
424 acmeupdate: [ 'ACME Account', gettext('Update') ],
425 acmerefresh: [ 'ACME Account', gettext('Refresh') ],
426 acmerenew: [ 'SRV', gettext('Renew Certificate') ],
427 acmerevoke: [ 'SRV', gettext('Revoke Certificate') ],
428 'move_volume': [ 'CT', gettext('Move Volume') ],
429 clustercreate: [ '', gettext('Create Cluster') ],
430 clusterjoin: [ '', gettext('Join Cluster') ],
431 diskinit: [ 'Disk', gettext('Initialize Disk with GPT') ],
432 vncproxy: [ 'VM/CT', gettext('Console') ],
433 spiceproxy: [ 'VM/CT', gettext('Console') + ' (Spice)' ],
434 vncshell: [ '', gettext('Shell') ],
435 spiceshell: [ '', gettext('Shell') + ' (Spice)' ],
436 qmsnapshot: [ 'VM', gettext('Snapshot') ],
437 qmrollback: [ 'VM', gettext('Rollback') ],
438 qmdelsnapshot: [ 'VM', gettext('Delete Snapshot') ],
439 qmcreate: [ 'VM', gettext('Create') ],
440 qmrestore: [ 'VM', gettext('Restore') ],
441 qmdestroy: [ 'VM', gettext('Destroy') ],
442 qmigrate: [ 'VM', gettext('Migrate') ],
443 qmclone: [ 'VM', gettext('Clone') ],
444 qmmove: [ 'VM', gettext('Move disk') ],
445 qmtemplate: [ 'VM', gettext('Convert to template') ],
446 qmstart: [ 'VM', gettext('Start') ],
447 qmstop: [ 'VM', gettext('Stop') ],
448 qmreset: [ 'VM', gettext('Reset') ],
449 qmshutdown: [ 'VM', gettext('Shutdown') ],
450 qmsuspend: [ 'VM', gettext('Suspend') ],
451 qmresume: [ 'VM', gettext('Resume') ],
452 qmconfig: [ 'VM', gettext('Configure') ],
453 vzsnapshot: [ 'CT', gettext('Snapshot') ],
454 vzrollback: [ 'CT', gettext('Rollback') ],
455 vzdelsnapshot: [ 'CT', gettext('Delete Snapshot') ],
456 vzcreate: ['CT', gettext('Create') ],
457 vzrestore: ['CT', gettext('Restore') ],
458 vzdestroy: ['CT', gettext('Destroy') ],
459 vzmigrate: [ 'CT', gettext('Migrate') ],
460 vzclone: [ 'CT', gettext('Clone') ],
461 vztemplate: [ 'CT', gettext('Convert to template') ],
462 vzstart: ['CT', gettext('Start') ],
463 vzstop: ['CT', gettext('Stop') ],
464 vzmount: ['CT', gettext('Mount') ],
465 vzumount: ['CT', gettext('Unmount') ],
466 vzshutdown: ['CT', gettext('Shutdown') ],
467 vzsuspend: [ 'CT', gettext('Suspend') ],
468 vzresume: [ 'CT', gettext('Resume') ],
469 hamigrate: [ 'HA', gettext('Migrate') ],
470 hastart: [ 'HA', gettext('Start') ],
471 hastop: [ 'HA', gettext('Stop') ],
472 srvstart: ['SRV', gettext('Start') ],
473 srvstop: ['SRV', gettext('Stop') ],
474 srvrestart: ['SRV', gettext('Restart') ],
475 srvreload: ['SRV', gettext('Reload') ],
476 cephcreatemgr: ['Ceph Manager', gettext('Create') ],
477 cephdestroymgr: ['Ceph Manager', gettext('Destroy') ],
478 cephcreatemon: ['Ceph Monitor', gettext('Create') ],
479 cephdestroymon: ['Ceph Monitor', gettext('Destroy') ],
480 cephcreateosd: ['Ceph OSD', gettext('Create') ],
481 cephdestroyosd: ['Ceph OSD', gettext('Destroy') ],
482 cephcreatepool: ['Ceph Pool', gettext('Create') ],
483 cephdestroypool: ['Ceph Pool', gettext('Destroy') ],
484 cephfscreate: ['CephFS', gettext('Create') ],
485 cephcreatemds: ['Ceph Metadata Server', gettext('Create') ],
486 cephdestroymds: ['Ceph Metadata Server', gettext('Destroy') ],
487 imgcopy: ['', gettext('Copy data') ],
488 imgdel: ['', gettext('Erase data') ],
489 unknownimgdel: ['', gettext('Destroy image from unknown guest') ],
490 download: ['', gettext('Download') ],
491 vzdump: ['', gettext('Backup') ],
492 aptupdate: ['', gettext('Update package database') ],
493 startall: [ '', gettext('Start all VMs and Containers') ],
494 stopall: [ '', gettext('Stop all VMs and Containers') ],
495 migrateall: [ '', gettext('Migrate all VMs and Containers') ],
496 dircreate: [ gettext('Directory Storage'), gettext('Create') ],
497 lvmcreate: [ gettext('LVM Storage'), gettext('Create') ],
498 lvmthincreate: [ gettext('LVM-Thin Storage'), gettext('Create') ],
499 zfscreate: [ gettext('ZFS Storage'), gettext('Create') ]
500 },
501
502 format_task_description: function(type, id) {
503 var farray = Proxmox.Utils.task_desc_table[type];
504 var text;
505 if (!farray) {
506 text = type;
507 if (id) {
508 type += ' ' + id;
509 }
510 return text;
511 }
512 var prefix = farray[0];
513 text = farray[1];
514 if (prefix) {
515 return prefix + ' ' + id + ' - ' + text;
516 }
517 return text;
518 },
519
520 format_size: function(size) {
521 /*jslint confusion: true */
522
523 var units = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
524 var num = 0;
525
526 while (size >= 1024 && ((num++)+1) < units.length) {
527 size = size / 1024;
528 }
529
530 return size.toFixed((num > 0)?2:0) + " " + units[num] + "B";
531 },
532
533 render_upid: function(value, metaData, record) {
534 var type = record.data.type;
535 var id = record.data.id;
536
537 return Proxmox.Utils.format_task_description(type, id);
538 },
539
540 render_uptime: function(value) {
541
542 var uptime = value;
543
544 if (uptime === undefined) {
545 return '';
546 }
547
548 if (uptime <= 0) {
549 return '-';
550 }
551
552 return Proxmox.Utils.format_duration_long(uptime);
553 },
554
555 parse_task_upid: function(upid) {
556 var task = {};
557
558 var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
559 if (!res) {
560 throw "unable to parse upid '" + upid + "'";
561 }
562 task.node = res[1];
563 task.pid = parseInt(res[2], 16);
564 task.pstart = parseInt(res[3], 16);
565 task.starttime = parseInt(res[4], 16);
566 task.type = res[5];
567 task.id = res[6];
568 task.user = res[7];
569
570 task.desc = Proxmox.Utils.format_task_description(task.type, task.id);
571
572 return task;
573 },
574
575 render_timestamp: function(value, metaData, record, rowIndex, colIndex, store) {
576 var servertime = new Date(value * 1000);
577 return Ext.Date.format(servertime, 'Y-m-d H:i:s');
578 },
579
580 openXtermJsViewer: function(vmtype, vmid, nodename, vmname) {
581 var url = Ext.urlEncode({
582 console: vmtype, // kvm, lxc, upgrade or shell
583 xtermjs: 1,
584 vmid: vmid,
585 vmname: vmname,
586 node: nodename
587 });
588 var nw = window.open("?" + url, '_blank', 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420');
589 nw.focus();
590 }
591
592 },
593
594 singleton: true,
595 constructor: function() {
596 var me = this;
597 Ext.apply(me, me.utilities);
598
599 var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
600 var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
601 var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
602 var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
603
604
605 me.IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
606 me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
607
608 var IPV6_REGEXP = "(?:" +
609 "(?:(?:" + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
610 "(?:(?:" + "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" +
611 "(?:(?:(?:" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" +
612 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" +
613 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" +
614 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" +
615 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" + ")" + IPV6_LS32 + ")|" +
616 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" + ")" + IPV6_H16 + ")|" +
617 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" + ")" + ")" +
618 ")";
619
620 me.IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
621 me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
622 me.IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
623
624 me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
625
626 var DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))";
627 me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
628
629 me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$");
630 me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
631 me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
632 }
633 });