]> git.proxmox.com Git - proxmox-widget-toolkit.git/blob - Utils.js
reword suspend
[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('Hibernate') ],
451 qmpause: [ 'VM', gettext('Pause') ],
452 qmresume: [ 'VM', gettext('Resume') ],
453 qmconfig: [ 'VM', gettext('Configure') ],
454 vzsnapshot: [ 'CT', gettext('Snapshot') ],
455 vzrollback: [ 'CT', gettext('Rollback') ],
456 vzdelsnapshot: [ 'CT', gettext('Delete Snapshot') ],
457 vzcreate: ['CT', gettext('Create') ],
458 vzrestore: ['CT', gettext('Restore') ],
459 vzdestroy: ['CT', gettext('Destroy') ],
460 vzmigrate: [ 'CT', gettext('Migrate') ],
461 vzclone: [ 'CT', gettext('Clone') ],
462 vztemplate: [ 'CT', gettext('Convert to template') ],
463 vzstart: ['CT', gettext('Start') ],
464 vzstop: ['CT', gettext('Stop') ],
465 vzmount: ['CT', gettext('Mount') ],
466 vzumount: ['CT', gettext('Unmount') ],
467 vzshutdown: ['CT', gettext('Shutdown') ],
468 vzsuspend: [ 'CT', gettext('Suspend') ],
469 vzresume: [ 'CT', gettext('Resume') ],
470 hamigrate: [ 'HA', gettext('Migrate') ],
471 hastart: [ 'HA', gettext('Start') ],
472 hastop: [ 'HA', gettext('Stop') ],
473 srvstart: ['SRV', gettext('Start') ],
474 srvstop: ['SRV', gettext('Stop') ],
475 srvrestart: ['SRV', gettext('Restart') ],
476 srvreload: ['SRV', gettext('Reload') ],
477 cephcreatemgr: ['Ceph Manager', gettext('Create') ],
478 cephdestroymgr: ['Ceph Manager', gettext('Destroy') ],
479 cephcreatemon: ['Ceph Monitor', gettext('Create') ],
480 cephdestroymon: ['Ceph Monitor', gettext('Destroy') ],
481 cephcreateosd: ['Ceph OSD', gettext('Create') ],
482 cephdestroyosd: ['Ceph OSD', gettext('Destroy') ],
483 cephcreatepool: ['Ceph Pool', gettext('Create') ],
484 cephdestroypool: ['Ceph Pool', gettext('Destroy') ],
485 cephfscreate: ['CephFS', gettext('Create') ],
486 cephcreatemds: ['Ceph Metadata Server', gettext('Create') ],
487 cephdestroymds: ['Ceph Metadata Server', gettext('Destroy') ],
488 imgcopy: ['', gettext('Copy data') ],
489 imgdel: ['', gettext('Erase data') ],
490 unknownimgdel: ['', gettext('Destroy image from unknown guest') ],
491 download: ['', gettext('Download') ],
492 vzdump: ['VM/CT', gettext('Backup') ],
493 aptupdate: ['', gettext('Update package database') ],
494 startall: [ '', gettext('Start all VMs and Containers') ],
495 stopall: [ '', gettext('Stop all VMs and Containers') ],
496 migrateall: [ '', gettext('Migrate all VMs and Containers') ],
497 dircreate: [ gettext('Directory Storage'), gettext('Create') ],
498 lvmcreate: [ gettext('LVM Storage'), gettext('Create') ],
499 lvmthincreate: [ gettext('LVM-Thin Storage'), gettext('Create') ],
500 zfscreate: [ gettext('ZFS Storage'), gettext('Create') ]
501 },
502
503 format_task_description: function(type, id) {
504 var farray = Proxmox.Utils.task_desc_table[type];
505 var text;
506 if (!farray) {
507 text = type;
508 if (id) {
509 type += ' ' + id;
510 }
511 return text;
512 }
513 var prefix = farray[0];
514 text = farray[1];
515 if (prefix) {
516 return prefix + ' ' + id + ' - ' + text;
517 }
518 return text;
519 },
520
521 format_size: function(size) {
522 /*jslint confusion: true */
523
524 var units = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
525 var num = 0;
526
527 while (size >= 1024 && ((num++)+1) < units.length) {
528 size = size / 1024;
529 }
530
531 return size.toFixed((num > 0)?2:0) + " " + units[num] + "B";
532 },
533
534 render_upid: function(value, metaData, record) {
535 var type = record.data.type;
536 var id = record.data.id;
537
538 return Proxmox.Utils.format_task_description(type, id);
539 },
540
541 render_uptime: function(value) {
542
543 var uptime = value;
544
545 if (uptime === undefined) {
546 return '';
547 }
548
549 if (uptime <= 0) {
550 return '-';
551 }
552
553 return Proxmox.Utils.format_duration_long(uptime);
554 },
555
556 parse_task_upid: function(upid) {
557 var task = {};
558
559 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]+):$/);
560 if (!res) {
561 throw "unable to parse upid '" + upid + "'";
562 }
563 task.node = res[1];
564 task.pid = parseInt(res[2], 16);
565 task.pstart = parseInt(res[3], 16);
566 task.starttime = parseInt(res[4], 16);
567 task.type = res[5];
568 task.id = res[6];
569 task.user = res[7];
570
571 task.desc = Proxmox.Utils.format_task_description(task.type, task.id);
572
573 return task;
574 },
575
576 render_timestamp: function(value, metaData, record, rowIndex, colIndex, store) {
577 var servertime = new Date(value * 1000);
578 return Ext.Date.format(servertime, 'Y-m-d H:i:s');
579 },
580
581 openXtermJsViewer: function(vmtype, vmid, nodename, vmname, cmd) {
582 var url = Ext.Object.toQueryString({
583 console: vmtype, // kvm, lxc, upgrade or shell
584 xtermjs: 1,
585 vmid: vmid,
586 vmname: vmname,
587 node: nodename,
588 cmd: cmd,
589
590 });
591 var nw = window.open("?" + url, '_blank', 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420');
592 if (nw) {
593 nw.focus();
594 }
595 }
596
597 },
598
599 singleton: true,
600 constructor: function() {
601 var me = this;
602 Ext.apply(me, me.utilities);
603
604 var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
605 var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
606 var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
607 var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
608
609
610 me.IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
611 me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
612
613 var IPV6_REGEXP = "(?:" +
614 "(?:(?:" + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
615 "(?:(?:" + "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" +
616 "(?:(?:(?:" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" +
617 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" +
618 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" +
619 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" +
620 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" + ")" + IPV6_LS32 + ")|" +
621 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" + ")" + IPV6_H16 + ")|" +
622 "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" + ")" + ")" +
623 ")";
624
625 me.IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
626 me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
627 me.IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
628
629 me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
630
631 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])?))";
632 me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
633
634 me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$");
635 me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
636 me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
637 }
638 });