mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-09-14 20:34:19 +08:00
2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
var U=Object.defineProperty;var B=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var O=(c,u,a)=>u in c?U(c,u,{enumerable:!0,configurable:!0,writable:!0,value:a}):c[u]=a,L=(c,u)=>{for(var a in u||(u={}))H.call(u,a)&&O(c,a,u[a]);if(B)for(var a of B(u))Q.call(u,a)&&O(c,a,u[a]);return c};var D=(c,u,a)=>new Promise((d,l)=>{var P=w=>{try{x(a.next(w))}catch(I){l(I)}},m=w=>{try{x(a.throw(w))}catch(I){l(I)}},x=w=>w.done?d(w.value):Promise.resolve(w.value).then(P,m);x((a=a.apply(c,u)).next())});import{_ as W,d as J,r as S,x as K,P as X,o as k,c as C,f as p,w as g,j as R,F as z,Q as j,s as T,h as V,t as Y,g as Z,i as N,T as $}from"./index.js";var ee=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},G={exports:{}};(function(c){(function(u){const a="(0?\\d+|0x[a-f0-9]+)",d={fourOctet:new RegExp(`^${a}\\.${a}\\.${a}\\.${a}$`,"i"),threeOctet:new RegExp(`^${a}\\.${a}\\.${a}$`,"i"),twoOctet:new RegExp(`^${a}\\.${a}$`,"i"),longValue:new RegExp(`^${a}$`,"i")},l=new RegExp("^0[0-7]+$","i"),P=new RegExp("^0x[a-f0-9]+$","i"),m="%[0-9a-z]{1,}",x="(?:[0-9a-f]+::?)+",w={zoneIndex:new RegExp(m,"i"),native:new RegExp(`^(::)?(${x})?([0-9a-f]+)?(::)?(${m})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${a}\\.${a}\\.${a}\\.${a}(${m})?)$`,"i"),transitional:new RegExp(`^((?:${x})|(?:::)(?:${x})?)${a}\\.${a}\\.${a}\\.${a}(${m})?$`,"i")};function I(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r=0,n=-1,o=(e.match(w.zoneIndex)||[])[0],s,h;for(o&&(o=o.substring(1),e=e.replace(/%.+$/,""));(n=e.indexOf(":",n+1))>=0;)r++;if(e.substr(0,2)==="::"&&r--,e.substr(-2,2)==="::"&&r--,r>t)return null;for(h=t-r,s=":";h--;)s+="0:";return e=e.replace("::",s),e[0]===":"&&(e=e.slice(1)),e[e.length-1]===":"&&(e=e.slice(0,-1)),t=function(){const A=e.split(":"),_=[];for(let M=0;M<A.length;M++)_.push(parseInt(A[M],16));return _}(),{parts:t,zoneId:o}}function f(e,t,r,n){if(e.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let o=0,s;for(;n>0;){if(s=r-n,s<0&&(s=0),e[o]>>s!==t[o]>>s)return!1;n-=r,o+=1}return!0}function v(e){if(P.test(e))return parseInt(e,16);if(e[0]==="0"&&!isNaN(parseInt(e[1],10))){if(l.test(e))return parseInt(e,8);throw new Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function b(e,t){for(;e.length<t;)e=`0${e}`;return e}const i={};i.IPv4=function(){function e(t){if(t.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let r,n;for(r=0;r<t.length;r++)if(n=t[r],!(0<=n&&n<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=t}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return"ipv4"},e.prototype.match=function(t,r){let n;if(r===void 0&&(n=t,t=n[0],r=n[1]),t.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,t.octets,8,r)},e.prototype.prefixLengthFromSubnetMask=function(){let t=0,r=!1;const n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let o,s,h;for(o=3;o>=0;o-=1)if(s=this.octets[o],s in n){if(h=n[s],r&&h!==0)return null;h!==8&&(r=!0),t+=h}else return null;return 32-t},e.prototype.range=function(){return i.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return i.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),i.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),o=[];let s=0;for(;s<4;)o.push(parseInt(r[s],10)|parseInt(n[s],10)^255),s++;return new this(o)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},i.IPv4.isIPv4=function(e){return this.parser(e)!==null},i.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(t){return!1}},i.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch(t){return!1}},i.IPv4.isValidFourPartDecimal=function(e){return!!(i.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},i.IPv4.networkAddressFromCIDR=function(e){let t,r,n,o,s;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),o=[],r=0;r<4;)o.push(parseInt(n[r],10)&parseInt(s[r],10)),r++;return new this(o)}catch(h){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},i.IPv4.parse=function(e){const t=this.parser(e);if(t===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},i.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const r=parseInt(t[2]);if(r>=0&&r<=32){const n=[this.parse(t[1]),r];return Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},i.IPv4.parser=function(e){let t,r,n;if(t=e.match(d.fourOctet))return function(){const o=t.slice(1,6),s=[];for(let h=0;h<o.length;h++)r=o[h],s.push(v(r));return s}();if(t=e.match(d.longValue)){if(n=v(t[1]),n>4294967295||n<0)throw new Error("ipaddr: address outside defined range");return function(){const o=[];let s;for(s=0;s<=24;s+=8)o.push(n>>s&255);return o}().reverse()}else return(t=e.match(d.twoOctet))?function(){const o=t.slice(1,4),s=[];if(n=v(o[1]),n>16777215||n<0)throw new Error("ipaddr: address outside defined range");return s.push(v(o[0])),s.push(n>>16&255),s.push(n>>8&255),s.push(n&255),s}():(t=e.match(d.threeOctet))?function(){const o=t.slice(1,5),s=[];if(n=v(o[2]),n>65535||n<0)throw new Error("ipaddr: address outside defined range");return s.push(v(o[0])),s.push(v(o[1])),s.push(n>>8&255),s.push(n&255),s}():null},i.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r<n;)t[r]=255,r++;return n<4&&(t[n]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},i.IPv6=function(){function e(t,r){let n,o;if(t.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(t[n]<<8|t[n+1]);else if(t.length===8)this.parts=t;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(n=0;n<this.parts.length;n++)if(o=this.parts[n],!(0<=o&&o<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");r&&(this.zoneId=r)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[new e([100,65435,0,0,0,0,0,0]),96],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32]]},e.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},e.prototype.kind=function(){return"ipv6"},e.prototype.match=function(t,r){let n;if(r===void 0&&(n=t,t=n[0],r=n[1]),t.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,t.parts,16,r)},e.prototype.prefixLengthFromSubnetMask=function(){let t=0,r=!1;const n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let o,s;for(let h=7;h>=0;h-=1)if(o=this.parts[h],o in n){if(s=n[o],r&&s!==0)return null;s!==16&&(r=!0),t+=s}else return null;return 128-t},e.prototype.range=function(){return i.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let t;const r=[],n=this.parts;for(let o=0;o<n.length;o++)t=n[o],r.push(t>>8),r.push(t&255);return r},e.prototype.toFixedLengthString=function(){const t=function(){const n=[];for(let o=0;o<this.parts.length;o++)n.push(b(this.parts[o].toString(16),4));return n}.call(this).join(":");let r="";return this.zoneId&&(r=`%${this.zoneId}`),t+r},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const t=this.parts.slice(-2),r=t[0],n=t[1];return new i.IPv4([r>>8,r&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){const t=function(){const n=[];for(let o=0;o<this.parts.length;o++)n.push(this.parts[o].toString(16));return n}.call(this).join(":");let r="";return this.zoneId&&(r=`%${this.zoneId}`),t+r},e.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,r=this.toNormalizedString();let n=0,o=-1,s;for(;s=t.exec(r);)s[0].length>o&&(n=s.index,o=s[0].length);return o<0?r:`${r.substring(0,n)}::${r.substring(n+o)}`},e.prototype.toString=function(){return this.toRFC5952String()},e}(),i.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),o=[];let s=0;for(;s<16;)o.push(parseInt(r[s],10)|parseInt(n[s],10)^255),s++;return new this(o)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},i.IPv6.isIPv6=function(e){return this.parser(e)!==null},i.IPv6.isValid=function(e){if(typeof e=="string"&&e.indexOf(":")===-1)return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(t){return!1}},i.IPv6.isValidCIDR=function(e){if(typeof e=="string"&&e.indexOf(":")===-1)return!1;try{return this.parseCIDR(e),!0}catch(t){return!1}},i.IPv6.networkAddressFromCIDR=function(e){let t,r,n,o,s;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),o=[],r=0;r<16;)o.push(parseInt(n[r],10)&parseInt(s[r],10)),r++;return new this(o)}catch(h){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${h})`)}},i.IPv6.parse=function(e){const t=this.parser(e);if(t.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},i.IPv6.parseCIDR=function(e){let t,r,n;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return n=[this.parse(r[1]),t],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},i.IPv6.parser=function(e){let t,r,n,o,s,h;if(n=e.match(w.deprecatedTransitional))return this.parser(`::ffff:${n[1]}`);if(w.native.test(e))return I(e,8);if((n=e.match(w.transitional))&&(h=n[6]||"",t=n[1],n[1].endsWith("::")||(t=t.slice(0,-1)),t=I(t+h,6),t.parts)){for(s=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<s.length;r++)if(o=s[r],!(0<=o&&o<=255))return null;return t.parts.push(s[0]<<8|s[1]),t.parts.push(s[2]<<8|s[3]),{parts:t.parts,zoneId:t.zoneId}}return null},i.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r<n;)t[r]=255,r++;return n<16&&(t[n]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},i.fromByteArray=function(e){const t=e.length;if(t===4)return new i.IPv4(e);if(t===16)return new i.IPv6(e);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},i.isValid=function(e){return i.IPv6.isValid(e)||i.IPv4.isValid(e)},i.isValidCIDR=function(e){return i.IPv6.isValidCIDR(e)||i.IPv4.isValidCIDR(e)},i.parse=function(e){if(i.IPv6.isValid(e))return i.IPv6.parse(e);if(i.IPv4.isValid(e))return i.IPv4.parse(e);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},i.parseCIDR=function(e){try{return i.IPv6.parseCIDR(e)}catch(t){try{return i.IPv4.parseCIDR(e)}catch(r){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},i.process=function(e){const t=this.parse(e);return t.kind()==="ipv6"&&t.isIPv4MappedAddress()?t.toIPv4Address():t},i.subnetMatch=function(e,t,r){let n,o,s,h;r==null&&(r="unicast");for(o in t)if(Object.prototype.hasOwnProperty.call(t,o)){for(s=t[o],s[0]&&!(s[0]instanceof Array)&&(s=[s]),n=0;n<s.length;n++)if(h=s[n],e.kind()===h[0].kind()&&e.match.apply(e,h))return o}return r},c.exports?c.exports=i:u.ipaddr=i})(ee)})(G);var F=G.exports;const te=c=>F.isValid(c),y=c=>{const u=F.IPv4.parse(c).toByteArray();return u[0]<<24|u[1]<<16|u[2]<<8|u[3]},q=c=>F.fromByteArray([c>>24&255,c>>16&255,c>>8&255,c&255]).toString(),ne=c=>{if(!F.IPv4.isIPv4(c))return!1;let u=0,a=y(c);for(let d=31;d>=0&&(a&1<<d)!=0;d--)u=u+(1<<d);return(~u&a)==0},re=(c,u,a,d)=>{let l=y(c)&y(u),P=y(a),m=y(d),w=~y(u);return P<m&&P>l+1&&m<l+w},se=(c,u)=>{let a=y(u),d=y(c)&a,l=~a,P;return l>=105?(P=d|l-5,d=d|100):l>=3?(P=d|l-1,d=d|2):(d=d|1,P=d),[q(d),q(P)]};var E={isValidMask:ne,isValidIP:te,isValidMaskRange:re,calcMaskRange:se};const oe=p("div",{class:"label-name"},[p("span",null,"\u5185\u7F51\u5730\u5740")],-1),ie={class:"label-value"},ae=p("div",{class:"label-name"},[p("span",null,"\u5B50\u7F51\u63A9\u7801")],-1),ue={class:"label-value"},le=p("div",{class:"label-name"},[p("span",null,"DHCP\u670D\u52A1")],-1),de={class:"label-value"},ce={class:"label-flex"},pe=p("div",{class:"label-name"},[p("span",null,"IP\u6C60\u8D77\u59CB\u5730\u5740")],-1),fe={class:"label-value"},he=p("div",{class:"label-name"},[p("span",null,"IP\u6C60\u7ED3\u675F\u5730\u5740")],-1),Ie={class:"label-value"},ve={class:"label-btns"},we=["disabled"],Pe={key:2,class:"label-msg"},me=J({__name:"index",setup(c){return D(this,null,function*(){let u,a;const d=S(""),l=K({lanIp:"",netMask:"255.255.255.0",enableDhcp:!1,dhcpStart:"",dhcpEnd:""}),P=S(!1),m=S(!1),x=()=>D(this,null,function*(){P.value=!0;const I=yield N.Guide.GetLan.GET();if(I.data){const{result:f}=I.data;f&&(l.lanIp=f.lanIp,l.netMask=f.netMask,m.value=f.enableDhcp||!1,l.dhcpStart=f.dhcpStart,l.dhcpEnd=f.dhcpEnd,f.lanIp,location.hostname)}P.value=!1});[u,a]=X(()=>x()),yield u,a();const w=()=>D(this,null,function*(){const I=L({},l);if(!E.isValidIP(I.lanIp)){$.Error("IPv4\u5730\u5740\u683C\u5F0F\u9519\u8BEF");return}if(!E.isValidMask(I.netMask)){$.Error("IPv4\u5B50\u7F51\u63A9\u7801\u683C\u5F0F\u9519\u8BEF");return}if(I.enableDhcp&&!E.isValidIP(I.dhcpStart)||!E.isValidIP(I.dhcpEnd)||!E.isValidMaskRange(I.lanIp,I.netMask,I.dhcpStart,I.dhcpEnd)){$.Error("DHCP\u7684IP\u6C60\u683C\u5F0F\u9519\u8BEF\u6216\u8D85\u51FA\u5B50\u7F51\u8303\u56F4");return}const f=$.Loading("\u6B63\u5728\u914D\u7F6E,\u8BF7\u7A0D\u7B49\u2026");let v=!1;try{const b=yield N.Guide.LanIp.POST(I);if(b.data){const{result:i,success:e,error:t}=b.data;if(t){d.value=t;return}(e||0)==0&&(v=!0)}}catch(b){d.value=b}finally{f.Close()}v&&(d.value=`\u66F4\u65B0\u6210\u529F,\u8BF7\u8FDB\u5165 ${I.lanIp} \u8DEF\u7531\u5668\u5730\u5740`)});return(I,f)=>(k(),C("form",{class:"form-container",onSubmit:Z(w,["prevent"])},[oe,p("div",ie,[g(p("input",{type:"text",placeholder:"192.168.100.1","onUpdate:modelValue":f[0]||(f[0]=v=>l.lanIp=v),required:""},null,512),[[R,l.lanIp,void 0,{trim:!0}]])]),ae,p("div",ue,[g(p("input",{type:"text",placeholder:"255.255.255.0","onUpdate:modelValue":f[1]||(f[1]=v=>l.netMask=v),required:""},null,512),[[R,l.netMask,void 0,{trim:!0}]])]),m.value?(k(),C(z,{key:0},[le,p("div",de,[p("div",ce,[p("label",null,[g(p("input",{type:"radio",value:!1,"onUpdate:modelValue":f[2]||(f[2]=v=>l.enableDhcp=v)},null,512),[[j,l.enableDhcp]]),T("\u4FDD\u6301DHCP")]),p("label",null,[g(p("input",{type:"radio",value:!0,"onUpdate:modelValue":f[3]||(f[3]=v=>l.enableDhcp=v)},null,512),[[j,l.enableDhcp]]),T("\u4FEE\u6539DHCP")])])])],64)):V("v-if",!0),l.enableDhcp?(k(),C(z,{key:1},[pe,p("div",fe,[g(p("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":f[4]||(f[4]=v=>l.dhcpStart=v),required:""},null,512),[[R,l.dhcpStart,void 0,{trim:!0}]])]),he,p("div",Ie,[g(p("input",{type:"text",placeholder:"192.168.100.100","onUpdate:modelValue":f[5]||(f[5]=v=>l.dhcpEnd=v),required:""},null,512),[[R,l.dhcpEnd,void 0,{trim:!0}]])])],64)):V("v-if",!0),p("div",ve,[p("button",{class:"sumbit",disabled:P.value},"\u4FDD\u5B58",8,we)]),d.value?(k(),C("div",Pe,[p("span",null,Y(d.value),1)])):V("v-if",!0)],32))})}});var be=W(me,[]);export{be as default};
|