2017-01-30 09:45:41 +01:00
Ext . ns ( 'Proxmox' ) ;
Ext . ns ( 'Proxmox.Setup' ) ;
2017-01-30 12:10:56 +01:00
if ( ! Ext . isDefined ( Proxmox . Setup . auth _cookie _name ) ) {
throw "Proxmox library not initialized" ;
2017-01-30 09:45:41 +01:00
}
// avoid errors related to Accessible Rich Internet Applications
// (access for people with disabilities)
// TODO reenable after all components are upgraded
Ext . enableAria = false ;
Ext . enableAriaButtons = false ;
Ext . enableAriaPanels = false ;
// avoid errors when running without development tools
if ( ! Ext . isDefined ( Ext . global . console ) ) {
var console = {
dir : function ( ) { } ,
log : function ( ) { }
} ;
}
Ext . Ajax . defaultHeaders = {
'Accept' : 'application/json'
} ;
Ext . Ajax . on ( 'beforerequest' , function ( conn , options ) {
if ( Proxmox . CSRFPreventionToken ) {
if ( ! options . headers ) {
options . headers = { } ;
}
options . headers . CSRFPreventionToken = Proxmox . CSRFPreventionToken ;
}
} ) ;
Ext . define ( 'Proxmox.Utils' , { utilities : {
// this singleton contains miscellaneous utilities
2017-02-24 08:18:36 +01:00
yesText : gettext ( 'Yes' ) ,
noText : gettext ( 'No' ) ,
enabledText : gettext ( 'Enabled' ) ,
disabledText : gettext ( 'Disabled' ) ,
noneText : gettext ( 'none' ) ,
errorText : gettext ( 'Error' ) ,
2017-01-31 17:05:09 +01:00
unknownText : gettext ( 'Unknown' ) ,
2017-02-24 08:18:36 +01:00
defaultText : gettext ( 'Default' ) ,
daysText : gettext ( 'days' ) ,
dayText : gettext ( 'day' ) ,
runningText : gettext ( 'running' ) ,
stoppedText : gettext ( 'stopped' ) ,
neverText : gettext ( 'never' ) ,
totalText : gettext ( 'Total' ) ,
usedText : gettext ( 'Used' ) ,
directoryText : gettext ( 'Directory' ) ,
stateText : gettext ( 'State' ) ,
groupText : gettext ( 'Group' ) ,
2017-10-04 10:50:59 +02:00
language _map : {
2018-01-15 14:09:41 +01:00
zh _CN : 'Chinese' ,
ca : 'Catalan' ,
da : 'Danish' ,
2017-10-04 10:50:59 +02:00
en : 'English' ,
2018-01-15 14:09:41 +01:00
eu : 'Euskera (Basque)' ,
2017-10-04 10:50:59 +02:00
fr : 'French' ,
de : 'German' ,
it : 'Italian' ,
2018-01-15 14:09:41 +01:00
es : 'Spanish' ,
ja : 'Japanese' ,
nb : 'Norwegian (Bokmal)' ,
nn : 'Norwegian (Nynorsk)' ,
fa : 'Persian (Farsi)' ,
pl : 'Polish' ,
pt _BR : 'Portuguese (Brazil)' ,
ru : 'Russian' ,
sl : 'Slovenian' ,
sv : 'Swedish' ,
tr : 'Turkish'
2017-10-04 10:50:59 +02:00
} ,
render _language : function ( value ) {
if ( ! value ) {
return Proxmox . Utils . defaultText + ' (English)' ;
}
var text = Proxmox . Utils . language _map [ value ] ;
if ( text ) {
return text + ' (' + value + ')' ;
}
return value ;
} ,
language _array : function ( ) {
var data = [ [ '__default__' , Proxmox . Utils . render _language ( '' ) ] ] ;
Ext . Object . each ( Proxmox . Utils . language _map , function ( key , value ) {
data . push ( [ key , Proxmox . Utils . render _language ( value ) ] ) ;
} ) ;
return data ;
} ,
2017-09-21 13:05:07 +02:00
getNoSubKeyHtml : function ( url ) {
// url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
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' ) ;
} ,
2017-02-24 08:19:35 +01:00
format _boolean _with _default : function ( value ) {
if ( Ext . isDefined ( value ) && value !== '__default__' ) {
return value ? Proxmox . Utils . yesText : Proxmox . Utils . noText ;
}
return Proxmox . Utils . defaultText ;
} ,
format _boolean : function ( value ) {
return value ? Proxmox . Utils . yesText : Proxmox . Utils . noText ;
} ,
format _neg _boolean : function ( value ) {
return ! value ? Proxmox . Utils . yesText : Proxmox . Utils . noText ;
} ,
2017-01-31 17:05:09 +01:00
2017-02-24 17:43:49 +01:00
format _enabled _toggle : function ( value ) {
return value ? Proxmox . Utils . enabledText : Proxmox . Utils . disabledText ;
} ,
2017-03-27 09:43:02 +02:00
format _expire : function ( date ) {
if ( ! date ) {
return Proxmox . Utils . neverText ;
}
return Ext . Date . format ( date , "Y-m-d" ) ;
} ,
2017-04-12 10:55:32 +02:00
format _duration _long : function ( ut ) {
var days = Math . floor ( ut / 86400 ) ;
ut -= days * 86400 ;
var hours = Math . floor ( ut / 3600 ) ;
ut -= hours * 3600 ;
var mins = Math . floor ( ut / 60 ) ;
ut -= mins * 60 ;
var hours _str = '00' + hours . toString ( ) ;
hours _str = hours _str . substr ( hours _str . length - 2 ) ;
var mins _str = "00" + mins . toString ( ) ;
mins _str = mins _str . substr ( mins _str . length - 2 ) ;
var ut _str = "00" + ut . toString ( ) ;
ut _str = ut _str . substr ( ut _str . length - 2 ) ;
if ( days ) {
var ds = days > 1 ? Proxmox . Utils . daysText : Proxmox . Utils . dayText ;
return days . toString ( ) + ' ' + ds + ' ' +
hours _str + ':' + mins _str + ':' + ut _str ;
} else {
return hours _str + ':' + mins _str + ':' + ut _str ;
}
} ,
2017-10-03 14:35:34 +02:00
format _subscription _level : function ( level ) {
if ( level === 'c' ) {
2017-10-04 09:59:11 +02:00
return 'Community' ;
2017-10-03 14:35:34 +02:00
} else if ( level === 'b' ) {
2017-10-04 09:59:11 +02:00
return 'Basic' ;
2017-10-03 14:35:34 +02:00
} else if ( level === 's' ) {
2017-10-04 09:59:11 +02:00
return 'Standard' ;
2017-10-03 14:35:34 +02:00
} else if ( level === 'p' ) {
2017-10-04 09:59:11 +02:00
return 'Premium' ;
2017-10-03 14:35:34 +02:00
} else {
return Proxmox . Utils . noneText ;
}
} ,
2017-02-25 10:47:20 +01:00
compute _min _label _width : function ( text , width ) {
if ( width === undefined ) { width = 100 ; }
var tm = new Ext . util . TextMetrics ( ) ;
var min = tm . getWidth ( text + ':' ) ;
return min < width ? width : min ;
} ,
2017-01-30 09:45:41 +01:00
authOK : function ( ) {
return ( Proxmox . UserName !== '' ) && Ext . util . Cookies . get ( Proxmox . Setup . auth _cookie _name ) ;
} ,
authClear : function ( ) {
Ext . util . Cookies . clear ( Proxmox . Setup . auth _cookie _name ) ;
} ,
// comp.setLoading() is buggy in ExtJS 4.0.7, so we
// use el.mask() instead
setErrorMask : function ( comp , msg ) {
var el = comp . el ;
if ( ! el ) {
return ;
}
if ( ! msg ) {
el . unmask ( ) ;
} else {
if ( msg === true ) {
el . mask ( gettext ( "Loading..." ) ) ;
} else {
el . mask ( msg ) ;
}
}
} ,
2017-09-06 08:53:12 +02:00
monStoreErrors : function ( me , store , clearMaskBeforeLoad ) {
if ( clearMaskBeforeLoad ) {
me . mon ( store , 'beforeload' , function ( s , operation , eOpts ) {
Proxmox . Utils . setErrorMask ( me , false ) ;
2017-12-06 18:39:53 +01:00
} ) ;
2017-09-06 08:53:12 +02:00
} else {
me . mon ( store , 'beforeload' , function ( s , operation , eOpts ) {
if ( ! me . loadCount ) {
me . loadCount = 0 ; // make sure it is numeric
Proxmox . Utils . setErrorMask ( me , true ) ;
}
} ) ;
}
2017-01-30 09:45:41 +01:00
// only works with 'proxmox' proxy
me . mon ( store . proxy , 'afterload' , function ( proxy , request , success ) {
me . loadCount ++ ;
if ( success ) {
Proxmox . Utils . setErrorMask ( me , false ) ;
return ;
}
var msg ;
/*jslint nomen: true */
var operation = request . _operation ;
var error = operation . getError ( ) ;
if ( error . statusText ) {
msg = error . statusText + ' (' + error . status + ')' ;
} else {
msg = gettext ( 'Connection error' ) ;
}
Proxmox . Utils . setErrorMask ( me , msg ) ;
} ) ;
} ,
extractRequestError : function ( result , verbose ) {
var msg = gettext ( 'Successful' ) ;
if ( ! result . success ) {
msg = gettext ( "Unknown error" ) ;
if ( result . message ) {
msg = result . message ;
if ( result . status ) {
msg += ' (' + result . status + ')' ;
}
}
if ( verbose && Ext . isObject ( result . errors ) ) {
msg += "<br>" ;
Ext . Object . each ( result . errors , function ( prop , desc ) {
msg += "<br><b>" + Ext . htmlEncode ( prop ) + "</b>: " +
Ext . htmlEncode ( desc ) ;
} ) ;
}
}
return msg ;
} ,
// Ext.Ajax.request
API2Request : function ( reqOpts ) {
var newopts = Ext . apply ( {
waitMsg : gettext ( 'Please wait...' )
} , reqOpts ) ;
if ( ! newopts . url . match ( /^\/api2/ ) ) {
newopts . url = '/api2/extjs' + newopts . url ;
}
delete newopts . callback ;
var createWrapper = function ( successFn , callbackFn , failureFn ) {
Ext . apply ( newopts , {
success : function ( response , options ) {
if ( options . waitMsgTarget ) {
2018-01-15 14:51:24 +01:00
if ( Proxmox . Utils . toolkit === 'touch' ) {
options . waitMsgTarget . setMasked ( false ) ;
} else {
options . waitMsgTarget . setLoading ( false ) ;
}
2017-01-30 09:45:41 +01:00
}
var result = Ext . decode ( response . responseText ) ;
response . result = result ;
if ( ! result . success ) {
response . htmlStatus = Proxmox . Utils . extractRequestError ( result , true ) ;
Ext . callback ( callbackFn , options . scope , [ options , false , response ] ) ;
Ext . callback ( failureFn , options . scope , [ response , options ] ) ;
return ;
}
Ext . callback ( callbackFn , options . scope , [ options , true , response ] ) ;
Ext . callback ( successFn , options . scope , [ response , options ] ) ;
} ,
failure : function ( response , options ) {
if ( options . waitMsgTarget ) {
2018-01-15 14:51:24 +01:00
if ( Proxmox . Utils . toolkit === 'touch' ) {
options . waitMsgTarget . setMasked ( false ) ;
} else {
options . waitMsgTarget . setLoading ( false ) ;
}
2017-01-30 09:45:41 +01:00
}
response . result = { } ;
try {
response . result = Ext . decode ( response . responseText ) ;
} catch ( e ) { }
var msg = gettext ( 'Connection error' ) + ' - server offline?' ;
if ( response . aborted ) {
msg = gettext ( 'Connection error' ) + ' - aborted.' ;
} else if ( response . timedout ) {
msg = gettext ( 'Connection error' ) + ' - Timeout.' ;
} else if ( response . status && response . statusText ) {
msg = gettext ( 'Connection error' ) + ' ' + response . status + ': ' + response . statusText ;
}
response . htmlStatus = msg ;
Ext . callback ( callbackFn , options . scope , [ options , false , response ] ) ;
Ext . callback ( failureFn , options . scope , [ response , options ] ) ;
}
} ) ;
} ;
createWrapper ( reqOpts . success , reqOpts . callback , reqOpts . failure ) ;
var target = newopts . waitMsgTarget ;
if ( target ) {
2018-01-15 14:51:24 +01:00
if ( Proxmox . Utils . toolkit === 'touch' ) {
target . setMasked ( { xtype : 'loadmask' , message : newopts . waitMsg } ) ;
} else {
// Note: ExtJS bug - this does not work when component is not rendered
target . setLoading ( newopts . waitMsg ) ;
}
2017-01-30 09:45:41 +01:00
}
Ext . Ajax . request ( newopts ) ;
} ,
2017-09-21 13:05:07 +02:00
checked _command : function ( orig _cmd ) {
Proxmox . Utils . API2Request ( {
url : '/nodes/localhost/subscription' ,
method : 'GET' ,
//waitMsgTarget: me,
failure : function ( response , opts ) {
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
} ,
success : function ( response , opts ) {
var data = response . result . data ;
if ( data . status !== 'Active' ) {
Ext . Msg . show ( {
title : gettext ( 'No valid subscription' ) ,
icon : Ext . Msg . WARNING ,
msg : Proxmox . Utils . getNoSubKeyHtml ( data . url ) ,
buttons : Ext . Msg . OK ,
callback : function ( btn ) {
if ( btn !== 'ok' ) {
return ;
}
orig _cmd ( ) ;
}
} ) ;
} else {
orig _cmd ( ) ;
}
}
} ) ;
} ,
2017-01-30 13:40:51 +01:00
assemble _field _data : function ( values , data ) {
if ( Ext . isObject ( data ) ) {
Ext . Object . each ( data , function ( name , val ) {
if ( values . hasOwnProperty ( name ) ) {
var bucket = values [ name ] ;
if ( ! Ext . isArray ( bucket ) ) {
bucket = values [ name ] = [ bucket ] ;
}
if ( Ext . isArray ( val ) ) {
values [ name ] = bucket . concat ( val ) ;
} else {
bucket . push ( val ) ;
}
} else {
values [ name ] = val ;
}
} ) ;
}
} ,
dialog _title : function ( subject , create , isAdd ) {
if ( create ) {
if ( isAdd ) {
return gettext ( 'Add' ) + ': ' + subject ;
} else {
return gettext ( 'Create' ) + ': ' + subject ;
}
} else {
return gettext ( 'Edit' ) + ': ' + subject ;
}
} ,
2017-01-31 17:05:09 +01:00
network _iface _types : {
eth : gettext ( "Network Device" ) ,
bridge : 'Linux Bridge' ,
bond : 'Linux Bond' ,
OVSBridge : 'OVS Bridge' ,
OVSBond : 'OVS Bond' ,
OVSPort : 'OVS Port' ,
OVSIntPort : 'OVS IntPort'
} ,
render _network _iface _type : function ( value ) {
return Proxmox . Utils . network _iface _types [ value ] ||
Proxmox . Utils . unknownText ;
} ,
2018-01-15 14:11:02 +01:00
task _desc _table : {
diskinit : [ 'Disk' , gettext ( 'Initialize Disk with GPT' ) ] ,
vncproxy : [ 'VM/CT' , gettext ( 'Console' ) ] ,
spiceproxy : [ 'VM/CT' , gettext ( 'Console' ) + ' (Spice)' ] ,
vncshell : [ '' , gettext ( 'Shell' ) ] ,
spiceshell : [ '' , gettext ( 'Shell' ) + ' (Spice)' ] ,
qmsnapshot : [ 'VM' , gettext ( 'Snapshot' ) ] ,
qmrollback : [ 'VM' , gettext ( 'Rollback' ) ] ,
qmdelsnapshot : [ 'VM' , gettext ( 'Delete Snapshot' ) ] ,
qmcreate : [ 'VM' , gettext ( 'Create' ) ] ,
qmrestore : [ 'VM' , gettext ( 'Restore' ) ] ,
qmdestroy : [ 'VM' , gettext ( 'Destroy' ) ] ,
qmigrate : [ 'VM' , gettext ( 'Migrate' ) ] ,
qmclone : [ 'VM' , gettext ( 'Clone' ) ] ,
qmmove : [ 'VM' , gettext ( 'Move disk' ) ] ,
qmtemplate : [ 'VM' , gettext ( 'Convert to template' ) ] ,
qmstart : [ 'VM' , gettext ( 'Start' ) ] ,
qmstop : [ 'VM' , gettext ( 'Stop' ) ] ,
qmreset : [ 'VM' , gettext ( 'Reset' ) ] ,
qmshutdown : [ 'VM' , gettext ( 'Shutdown' ) ] ,
qmsuspend : [ 'VM' , gettext ( 'Suspend' ) ] ,
qmresume : [ 'VM' , gettext ( 'Resume' ) ] ,
qmconfig : [ 'VM' , gettext ( 'Configure' ) ] ,
vzsnapshot : [ 'CT' , gettext ( 'Snapshot' ) ] ,
vzrollback : [ 'CT' , gettext ( 'Rollback' ) ] ,
vzdelsnapshot : [ 'CT' , gettext ( 'Delete Snapshot' ) ] ,
vzcreate : [ 'CT' , gettext ( 'Create' ) ] ,
vzrestore : [ 'CT' , gettext ( 'Restore' ) ] ,
vzdestroy : [ 'CT' , gettext ( 'Destroy' ) ] ,
vzmigrate : [ 'CT' , gettext ( 'Migrate' ) ] ,
vzclone : [ 'CT' , gettext ( 'Clone' ) ] ,
vztemplate : [ 'CT' , gettext ( 'Convert to template' ) ] ,
vzstart : [ 'CT' , gettext ( 'Start' ) ] ,
vzstop : [ 'CT' , gettext ( 'Stop' ) ] ,
vzmount : [ 'CT' , gettext ( 'Mount' ) ] ,
vzumount : [ 'CT' , gettext ( 'Unmount' ) ] ,
vzshutdown : [ 'CT' , gettext ( 'Shutdown' ) ] ,
vzsuspend : [ 'CT' , gettext ( 'Suspend' ) ] ,
vzresume : [ 'CT' , gettext ( 'Resume' ) ] ,
hamigrate : [ 'HA' , gettext ( 'Migrate' ) ] ,
hastart : [ 'HA' , gettext ( 'Start' ) ] ,
hastop : [ 'HA' , gettext ( 'Stop' ) ] ,
srvstart : [ 'SRV' , gettext ( 'Start' ) ] ,
srvstop : [ 'SRV' , gettext ( 'Stop' ) ] ,
srvrestart : [ 'SRV' , gettext ( 'Restart' ) ] ,
srvreload : [ 'SRV' , gettext ( 'Reload' ) ] ,
cephcreatemon : [ 'Ceph Monitor' , gettext ( 'Create' ) ] ,
cephdestroymon : [ 'Ceph Monitor' , gettext ( 'Destroy' ) ] ,
cephcreateosd : [ 'Ceph OSD' , gettext ( 'Create' ) ] ,
cephdestroyosd : [ 'Ceph OSD' , gettext ( 'Destroy' ) ] ,
cephcreatepool : [ 'Ceph Pool' , gettext ( 'Create' ) ] ,
cephdestroypool : [ 'Ceph Pool' , gettext ( 'Destroy' ) ] ,
imgcopy : [ '' , gettext ( 'Copy data' ) ] ,
imgdel : [ '' , gettext ( 'Erase data' ) ] ,
download : [ '' , gettext ( 'Download' ) ] ,
vzdump : [ '' , gettext ( 'Backup' ) ] ,
aptupdate : [ '' , gettext ( 'Update package database' ) ] ,
startall : [ '' , gettext ( 'Start all VMs and Containers' ) ] ,
stopall : [ '' , gettext ( 'Stop all VMs and Containers' ) ] ,
migrateall : [ '' , gettext ( 'Migrate all VMs and Containers' ) ]
} ,
2017-01-31 12:18:29 +01:00
format _task _description : function ( type , id ) {
2018-01-15 14:11:02 +01:00
var farray = Proxmox . Utils . task _desc _table [ type ] ;
if ( ! farray ) {
var text = type ;
if ( id ) {
type += ' ' + id ;
}
return text ;
}
var prefix = farray [ 0 ] ;
var text = farray [ 1 ] ;
if ( prefix ) {
return prefix + ' ' + id + ' - ' + text ;
}
return text ;
2017-01-31 12:18:29 +01:00
} ,
2017-10-10 15:10:21 +02:00
format _size : function ( size ) {
/*jslint confusion: true */
var units = [ '' , 'Ki' , 'Mi' , 'Gi' , 'Ti' , 'Pi' , 'Ei' , 'Zi' , 'Yi' ] ;
var num = 0 ;
while ( size >= 1024 && ( ( num ++ ) + 1 ) < units . length ) {
size = size / 1024 ;
}
return size . toFixed ( ( num > 0 ) ? 2 : 0 ) + " " + units [ num ] + "B" ;
} ,
2017-01-31 12:18:29 +01:00
render _upid : function ( value , metaData , record ) {
var type = record . data . type ;
var id = record . data . id ;
return Proxmox . Utils . format _task _description ( type , id ) ;
} ,
2017-04-12 10:55:32 +02:00
render _uptime : function ( value ) {
var uptime = value ;
if ( uptime === undefined ) {
return '' ;
}
if ( uptime <= 0 ) {
return '-' ;
}
return Proxmox . Utils . format _duration _long ( uptime ) ;
} ,
2017-01-30 13:40:51 +01:00
parse _task _upid : function ( upid ) {
var task = { } ;
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]+):$/ ) ;
if ( ! res ) {
throw "unable to parse upid '" + upid + "'" ;
}
task . node = res [ 1 ] ;
task . pid = parseInt ( res [ 2 ] , 16 ) ;
task . pstart = parseInt ( res [ 3 ] , 16 ) ;
task . starttime = parseInt ( res [ 4 ] , 16 ) ;
task . type = res [ 5 ] ;
task . id = res [ 6 ] ;
task . user = res [ 7 ] ;
2017-01-31 12:18:29 +01:00
task . desc = Proxmox . Utils . format _task _description ( task . type , task . id ) ;
2017-01-30 13:40:51 +01:00
return task ;
} ,
render _timestamp : function ( value , metaData , record , rowIndex , colIndex , store ) {
var servertime = new Date ( value * 1000 ) ;
return Ext . Date . format ( servertime , 'Y-m-d H:i:s' ) ;
2017-12-11 14:30:53 +01:00
} ,
openXtermJsViewer : function ( vmtype , vmid , nodename , vmname ) {
var url = Ext . urlEncode ( {
console : vmtype , // kvm, lxc, upgrade or shell
xtermjs : 1 ,
vmid : vmid ,
vmname : vmname ,
node : nodename
} ) ;
var nw = window . open ( "?" + url , '_blank' , 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420' ) ;
nw . focus ( ) ;
2017-12-06 18:39:53 +01:00
}
2017-01-30 13:40:51 +01:00
2017-12-11 14:30:53 +01:00
} ,
2017-01-30 12:23:44 +01:00
2017-01-30 09:45:41 +01:00
singleton : true ,
constructor : function ( ) {
var me = this ;
Ext . apply ( me , me . utilities ) ;
var IPV4 _OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])" ;
var IPV4 _REGEXP = "(?:(?:" + IPV4 _OCTET + "\\.){3}" + IPV4 _OCTET + ")" ;
var IPV6 _H16 = "(?:[0-9a-fA-F]{1,4})" ;
var IPV6 _LS32 = "(?:(?:" + IPV6 _H16 + ":" + IPV6 _H16 + ")|" + IPV4 _REGEXP + ")" ;
me . IP4 _match = new RegExp ( "^(?:" + IPV4 _REGEXP + ")$" ) ;
me . IP4 _cidr _match = new RegExp ( "^(?:" + IPV4 _REGEXP + ")\/([0-9]{1,2})$" ) ;
var IPV6 _REGEXP = "(?:" +
"(?:(?:" + "(?:" + IPV6 _H16 + ":){6})" + IPV6 _LS32 + ")|" +
"(?:(?:" + "::" + "(?:" + IPV6 _H16 + ":){5})" + IPV6 _LS32 + ")|" +
"(?:(?:(?:" + IPV6 _H16 + ")?::" + "(?:" + IPV6 _H16 + ":){4})" + IPV6 _LS32 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,1}" + IPV6 _H16 + ")?::" + "(?:" + IPV6 _H16 + ":){3})" + IPV6 _LS32 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,2}" + IPV6 _H16 + ")?::" + "(?:" + IPV6 _H16 + ":){2})" + IPV6 _LS32 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,3}" + IPV6 _H16 + ")?::" + "(?:" + IPV6 _H16 + ":){1})" + IPV6 _LS32 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,4}" + IPV6 _H16 + ")?::" + ")" + IPV6 _LS32 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,5}" + IPV6 _H16 + ")?::" + ")" + IPV6 _H16 + ")|" +
"(?:(?:(?:(?:" + IPV6 _H16 + ":){0,7}" + IPV6 _H16 + ")?::" + ")" + ")" +
")" ;
me . IP6 _match = new RegExp ( "^(?:" + IPV6 _REGEXP + ")$" ) ;
me . IP6 _cidr _match = new RegExp ( "^(?:" + IPV6 _REGEXP + ")\/([0-9]{1,3})$" ) ;
me . IP6 _bracket _match = new RegExp ( "^\\[(" + IPV6 _REGEXP + ")\\]" ) ;
me . IP64 _match = new RegExp ( "^(?:" + IPV6 _REGEXP + "|" + IPV4 _REGEXP + ")$" ) ;
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])?))" ;
me . DnsName _match = new RegExp ( "^" + DnsName _REGEXP + "$" ) ;
me . HostPort _match = new RegExp ( "^(" + IPV4 _REGEXP + "|" + DnsName _REGEXP + ")(:\\d+)?$" ) ;
me . HostPortBrackets _match = new RegExp ( "^\\[(?:" + IPV6 _REGEXP + "|" + IPV4 _REGEXP + "|" + DnsName _REGEXP + ")\\](:\\d+)?$" ) ;
me . IP6 _dotnotation _match = new RegExp ( "^" + IPV6 _REGEXP + "(\\.\\d+)?$" ) ;
}
} ) ;