diff --git a/luci-app-alist/luasrc/controller/alist.lua b/luci-app-alist/luasrc/controller/alist.lua index 8ce4ad4c3..4f192ec09 100644 --- a/luci-app-alist/luasrc/controller/alist.lua +++ b/luci-app-alist/luasrc/controller/alist.lua @@ -5,17 +5,17 @@ function index() return end - local page = entry({"admin", "services", "alist"}, alias("admin", "services", "alist", "basic"), _("Alist"), 20) + local page = entry({"admin", "nas", "alist"}, alias("admin", "nas", "alist", "basic"), _("Alist"), 20) page.dependent = true page.acl_depends = { "luci-app-alist" } - entry({"admin", "services"}, firstchild(), "Services", 44).dependent = false - entry({"admin", "services", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true - entry({"admin", "services", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true - entry({"admin", "services", "alist", "alist_status"}, call("alist_status")).leaf = true - entry({"admin", "services", "alist", "get_log"}, call("get_log")).leaf = true - entry({"admin", "services", "alist", "clear_log"}, call("clear_log")).leaf = true - entry({"admin", "services", "alist", "admin_info"}, call("admin_info")).leaf = true + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false + entry({"admin", "nas", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true + entry({"admin", "nas", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true + entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).leaf = true + entry({"admin", "nas", "alist", "get_log"}, call("get_log")).leaf = true + entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true + entry({"admin", "nas", "alist", "admin_info"}, call("admin_info")).leaf = true end function alist_status() diff --git a/luci-app-alist/luasrc/view/alist/admin_info.htm b/luci-app-alist/luasrc/view/alist/admin_info.htm index 0ae272ce7..c593f2806 100644 --- a/luci-app-alist/luasrc/view/alist/admin_info.htm +++ b/luci-app-alist/luasrc/view/alist/admin_info.htm @@ -4,7 +4,7 @@ { btn.disabled = true; btn.value = '<%:Reading...%>'; - XHR.get('<%=luci.dispatcher.build_url("admin", "services", "alist", "admin_info")%>', + XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "alist", "admin_info")%>', null, function(x,rv) { diff --git a/luci-app-alist/luasrc/view/alist/alist_log.htm b/luci-app-alist/luasrc/view/alist/alist_log.htm index 14a2da423..5ec4a78b3 100644 --- a/luci-app-alist/luasrc/view/alist/alist_log.htm +++ b/luci-app-alist/luasrc/view/alist/alist_log.htm @@ -1,7 +1,7 @@ +
+ +
+ <% if container_running then %> + + +
+ +
+ +
+
+ + <% else %> + + <% end %> +
+
+ + + + diff --git a/luci-app-bmtedge/po/zh-cn/bmtedge.po b/luci-app-bmtedge/po/zh-cn/bmtedge.po new file mode 100644 index 000000000..35f040dee --- /dev/null +++ b/luci-app-bmtedge/po/zh-cn/bmtedge.po @@ -0,0 +1,36 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "BlueMountain Edge" +msgstr "蓝山云-流量宝" + +msgid "Cache path" +msgstr "缓存文件路径" + +msgid "Service Status" +msgstr "服务状态" + +msgid "BlueMountain Edge status:" +msgstr "蓝山云的状态信息如下:" + +msgid "Setup" +msgstr "安装配置" + +msgid "The following parameters will only take effect during installation or upgrade:" +msgstr "以下参数只在安装或者升级时才会生效:" + +msgid "Status" +msgstr "状态" + +msgid "BlueMountain Edge is running" +msgstr "蓝山云运行中" + +msgid "BlueMountain Edge is not running" +msgstr "蓝山云未运行" + +msgid "Open the BlueMountain Edge" +msgstr "打开蓝山云" + +msgid "UID" +msgstr "唯一标识" + diff --git a/luci-app-bmtedge/po/zh_Hans b/luci-app-bmtedge/po/zh_Hans new file mode 120000 index 000000000..41451e4a1 --- /dev/null +++ b/luci-app-bmtedge/po/zh_Hans @@ -0,0 +1 @@ +zh-cn \ No newline at end of file diff --git a/luci-app-bmtedge/root/etc/config/bmtedge b/luci-app-bmtedge/root/etc/config/bmtedge new file mode 100644 index 000000000..0ea333094 --- /dev/null +++ b/luci-app-bmtedge/root/etc/config/bmtedge @@ -0,0 +1,4 @@ +config bmtedge + option 'cache_path' '' + option 'image_name' '' + option 'uid' '' diff --git a/luci-app-bmtedge/root/etc/uci-defaults/luci-app-bmtedge b/luci-app-bmtedge/root/etc/uci-defaults/luci-app-bmtedge new file mode 100644 index 000000000..d4549a248 --- /dev/null +++ b/luci-app-bmtedge/root/etc/uci-defaults/luci-app-bmtedge @@ -0,0 +1,14 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete firewall.bmtedge + set firewall.bmtedge=rule + set firewall.bmtedge.name="bmtedge" + set firewall.bmtedge.target="ACCEPT" + set firewall.bmtedge.src="wan" + set firewall.bmtedge.dest_port="1024-65535" + set firewall.bmtedge.enabled="0" + commit firewall +EOF + +exit 0 diff --git a/luci-app-bmtedge/root/usr/libexec/istorec/bmtedge.sh b/luci-app-bmtedge/root/usr/libexec/istorec/bmtedge.sh new file mode 100755 index 000000000..53d35c4ec --- /dev/null +++ b/luci-app-bmtedge/root/usr/libexec/istorec/bmtedge.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +ACTION=${1} +shift 1 + +do_install() { + local path=`uci get bmtedge.@bmtedge[0].cache_path 2>/dev/null` + local uid=`uci get bmtedge.@bmtedge[0].uid 2>/dev/null` + local image_name=`uci get bmtedge.@bmtedge[0].image_name 2>/dev/null` + + if [ -z "$path" ]; then + echo "path is empty!" + exit 1 + fi + + [ -z "$image_name" ] && image_name="jinshanyun/jinshan-x86_64:latest" + echo "docker pull ${image_name}" + docker pull ${image_name} + docker rm -f bmtedge + + local cmd="docker run --restart=unless-stopped -d \ + --privileged \ + --network=host \ + --dns=127.0.0.1 \ + --tmpfs /run \ + --tmpfs /tmp \ + -v \"$path:/data/ksc1\" \ + -v \"$path/containerd:/var/lib/containerd\" \ + -e ksc_supplier_code=\"92101\" \ + -e ksc_datadir=\"/data/ksc1\" \ + -e ksc_machine_code=\"lsyK17032_$uid\" \ + -e ksc_refer=\"ruiyun_node\"" + + local tz="`uci get system.@system[0].zonename`" + [ -z "$tz" ] || cmd="$cmd -e TZ=$tz" + + cmd="$cmd --name bmtedge \"$image_name\"" + + echo "$cmd" + eval "$cmd" + + if [ "$?" = "0" ]; then + if [ "`uci -q get firewall.bmtedge.enabled`" = 0 ]; then + uci -q batch <<-EOF >/dev/null + set firewall.bmtedge.enabled="1" + commit firewall +EOF + /etc/init.d/firewall reload + fi + fi + + echo "Install OK!" + +} + +usage() { + echo "usage: $0 sub-command" + echo "where sub-command is one of:" + echo " install Install the bmtedge" + echo " upgrade Upgrade the bmtedge" + echo " rm/start/stop/restart Remove/Start/Stop/Restart the bmtedge" + echo " status Onething Edge status" + echo " port Onething Edge port" +} + +case ${ACTION} in + "install") + do_install + ;; + "upgrade") + do_install + ;; + "rm") + docker rm -f bmtedge + if [ "`uci -q get firewall.bmtedge.enabled`" = 1 ]; then + uci -q batch <<-EOF >/dev/null + set firewall.bmtedge.enabled="0" + commit firewall +EOF + /etc/init.d/firewall reload + fi + ;; + "start" | "stop" | "restart") + docker ${ACTION} bmtedge + ;; + "status") + docker ps --all -f 'name=bmtedge' --format '{{.State}}' + ;; + "port") + docker ps --all -f 'name=bmtedge' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://' + ;; + *) + usage + exit 1 + ;; +esac + diff --git a/luci-app-bmtedge/root/usr/share/rpcd/acl.d/luci-app-bmtedge.json b/luci-app-bmtedge/root/usr/share/rpcd/acl.d/luci-app-bmtedge.json new file mode 100644 index 000000000..c215ada0a --- /dev/null +++ b/luci-app-bmtedge/root/usr/share/rpcd/acl.d/luci-app-bmtedge.json @@ -0,0 +1,11 @@ +{ + "luci-app-bmtedge": { + "description": "Grant UCI access for luci-app-bmtedge", + "read": { + "uci": [ "bmtedge" ] + }, + "write": { + "uci": [ "bmtedge" ] + } + } +} diff --git a/luci-app-bmtedge/root/www/luci-static/bmtedge/qrcode.min.js b/luci-app-bmtedge/root/www/luci-static/bmtedge/qrcode.min.js new file mode 100644 index 000000000..993e88f39 --- /dev/null +++ b/luci-app-bmtedge/root/www/luci-static/bmtedge/qrcode.min.js @@ -0,0 +1 @@ +var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this.parsedData=[];for(var b=[],d=0,e=this.data.length;e>d;d++){var f=this.data.charCodeAt(d);f>65536?(b[0]=240|(1835008&f)>>>18,b[1]=128|(258048&f)>>>12,b[2]=128|(4032&f)>>>6,b[3]=128|63&f):f>2048?(b[0]=224|(61440&f)>>>12,b[1]=128|(4032&f)>>>6,b[2]=128|63&f):f>128?(b[0]=192|(1984&f)>>>6,b[1]=128|63&f):b[0]=f,this.parsedData=this.parsedData.concat(b)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function b(a,b){this.typeNumber=a,this.errorCorrectLevel=b,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function i(a,b){if(void 0==a.length)throw new Error(a.length+"/"+b);for(var c=0;c=f;f++){var h=0;switch(b){case d.L:h=l[f][0];break;case d.M:h=l[f][1];break;case d.Q:h=l[f][2];break;case d.H:h=l[f][3]}if(h>=e)break;c++}if(c>l.length)throw new Error("Too long data");return c}function s(a){var b=encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return b.length+(b.length!=a?3:0)}a.prototype={getLength:function(){return this.parsedData.length},write:function(a){for(var b=0,c=this.parsedData.length;c>b;b++)a.put(this.parsedData[b],8)}},b.prototype={addData:function(b){var c=new a(b);this.dataList.push(c),this.dataCache=null},isDark:function(a,b){if(0>a||this.moduleCount<=a||0>b||this.moduleCount<=b)throw new Error(a+","+b);return this.modules[a][b]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var d=0;d=7&&this.setupTypeNumber(a),null==this.dataCache&&(this.dataCache=b.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,b){for(var c=-1;7>=c;c++)if(!(-1>=a+c||this.moduleCount<=a+c))for(var d=-1;7>=d;d++)-1>=b+d||this.moduleCount<=b+d||(this.modules[a+c][b+d]=c>=0&&6>=c&&(0==d||6==d)||d>=0&&6>=d&&(0==c||6==c)||c>=2&&4>=c&&d>=2&&4>=d?!0:!1)},getBestMaskPattern:function(){for(var a=0,b=0,c=0;8>c;c++){this.makeImpl(!0,c);var d=f.getLostPoint(this);(0==c||a>d)&&(a=d,b=c)}return b},createMovieClip:function(a,b,c){var d=a.createEmptyMovieClip(b,c),e=1;this.make();for(var f=0;f=g;g++)for(var h=-2;2>=h;h++)this.modules[d+g][e+h]=-2==g||2==g||-2==h||2==h||0==g&&0==h?!0:!1}},setupTypeNumber:function(a){for(var b=f.getBCHTypeNumber(this.typeNumber),c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[Math.floor(c/3)][c%3+this.moduleCount-8-3]=d}for(var c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[c%3+this.moduleCount-8-3][Math.floor(c/3)]=d}},setupTypeInfo:function(a,b){for(var c=this.errorCorrectLevel<<3|b,d=f.getBCHTypeInfo(c),e=0;15>e;e++){var g=!a&&1==(1&d>>e);6>e?this.modules[e][8]=g:8>e?this.modules[e+1][8]=g:this.modules[this.moduleCount-15+e][8]=g}for(var e=0;15>e;e++){var g=!a&&1==(1&d>>e);8>e?this.modules[8][this.moduleCount-e-1]=g:9>e?this.modules[8][15-e-1+1]=g:this.modules[8][15-e-1]=g}this.modules[this.moduleCount-8][8]=!a},mapData:function(a,b){for(var c=-1,d=this.moduleCount-1,e=7,g=0,h=this.moduleCount-1;h>0;h-=2)for(6==h&&h--;;){for(var i=0;2>i;i++)if(null==this.modules[d][h-i]){var j=!1;g>>e));var k=f.getMask(b,d,h-i);k&&(j=!j),this.modules[d][h-i]=j,e--,-1==e&&(g++,e=7)}if(d+=c,0>d||this.moduleCount<=d){d-=c,c=-c;break}}}},b.PAD0=236,b.PAD1=17,b.createData=function(a,c,d){for(var e=j.getRSBlocks(a,c),g=new k,h=0;h8*l)throw new Error("code length overflow. ("+g.getLengthInBits()+">"+8*l+")");for(g.getLengthInBits()+4<=8*l&&g.put(0,4);0!=g.getLengthInBits()%8;)g.putBit(!1);for(;;){if(g.getLengthInBits()>=8*l)break;if(g.put(b.PAD0,8),g.getLengthInBits()>=8*l)break;g.put(b.PAD1,8)}return b.createBytes(g,e)},b.createBytes=function(a,b){for(var c=0,d=0,e=0,g=new Array(b.length),h=new Array(b.length),j=0;j=0?p.get(q):0}}for(var r=0,m=0;mm;m++)for(var j=0;jm;m++)for(var j=0;j=0;)b^=f.G15<=0;)b^=f.G18<>>=1;return b},getPatternPosition:function(a){return f.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,b,c){switch(a){case e.PATTERN000:return 0==(b+c)%2;case e.PATTERN001:return 0==b%2;case e.PATTERN010:return 0==c%3;case e.PATTERN011:return 0==(b+c)%3;case e.PATTERN100:return 0==(Math.floor(b/2)+Math.floor(c/3))%2;case e.PATTERN101:return 0==b*c%2+b*c%3;case e.PATTERN110:return 0==(b*c%2+b*c%3)%2;case e.PATTERN111:return 0==(b*c%3+(b+c)%2)%2;default:throw new Error("bad maskPattern:"+a)}},getErrorCorrectPolynomial:function(a){for(var b=new i([1],0),c=0;a>c;c++)b=b.multiply(new i([1,g.gexp(c)],0));return b},getLengthInBits:function(a,b){if(b>=1&&10>b)switch(a){case c.MODE_NUMBER:return 10;case c.MODE_ALPHA_NUM:return 9;case c.MODE_8BIT_BYTE:return 8;case c.MODE_KANJI:return 8;default:throw new Error("mode:"+a)}else if(27>b)switch(a){case c.MODE_NUMBER:return 12;case c.MODE_ALPHA_NUM:return 11;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 10;default:throw new Error("mode:"+a)}else{if(!(41>b))throw new Error("type:"+b);switch(a){case c.MODE_NUMBER:return 14;case c.MODE_ALPHA_NUM:return 13;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 12;default:throw new Error("mode:"+a)}}},getLostPoint:function(a){for(var b=a.getModuleCount(),c=0,d=0;b>d;d++)for(var e=0;b>e;e++){for(var f=0,g=a.isDark(d,e),h=-1;1>=h;h++)if(!(0>d+h||d+h>=b))for(var i=-1;1>=i;i++)0>e+i||e+i>=b||(0!=h||0!=i)&&g==a.isDark(d+h,e+i)&&f++;f>5&&(c+=3+f-5)}for(var d=0;b-1>d;d++)for(var e=0;b-1>e;e++){var j=0;a.isDark(d,e)&&j++,a.isDark(d+1,e)&&j++,a.isDark(d,e+1)&&j++,a.isDark(d+1,e+1)&&j++,(0==j||4==j)&&(c+=3)}for(var d=0;b>d;d++)for(var e=0;b-6>e;e++)a.isDark(d,e)&&!a.isDark(d,e+1)&&a.isDark(d,e+2)&&a.isDark(d,e+3)&&a.isDark(d,e+4)&&!a.isDark(d,e+5)&&a.isDark(d,e+6)&&(c+=40);for(var e=0;b>e;e++)for(var d=0;b-6>d;d++)a.isDark(d,e)&&!a.isDark(d+1,e)&&a.isDark(d+2,e)&&a.isDark(d+3,e)&&a.isDark(d+4,e)&&!a.isDark(d+5,e)&&a.isDark(d+6,e)&&(c+=40);for(var k=0,e=0;b>e;e++)for(var d=0;b>d;d++)a.isDark(d,e)&&k++;var l=Math.abs(100*k/b/b-50)/5;return c+=10*l}},g={glog:function(a){if(1>a)throw new Error("glog("+a+")");return g.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;a>=256;)a-=255;return g.EXP_TABLE[a]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},h=0;8>h;h++)g.EXP_TABLE[h]=1<h;h++)g.EXP_TABLE[h]=g.EXP_TABLE[h-4]^g.EXP_TABLE[h-5]^g.EXP_TABLE[h-6]^g.EXP_TABLE[h-8];for(var h=0;255>h;h++)g.LOG_TABLE[g.EXP_TABLE[h]]=h;i.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var b=new Array(this.getLength()+a.getLength()-1),c=0;cf;f++)for(var g=c[3*f+0],h=c[3*f+1],i=c[3*f+2],k=0;g>k;k++)e.push(new j(h,i));return e},j.getRsBlockTable=function(a,b){switch(b){case d.L:return j.RS_BLOCK_TABLE[4*(a-1)+0];case d.M:return j.RS_BLOCK_TABLE[4*(a-1)+1];case d.Q:return j.RS_BLOCK_TABLE[4*(a-1)+2];case d.H:return j.RS_BLOCK_TABLE[4*(a-1)+3];default:return void 0}},k.prototype={get:function(a){var b=Math.floor(a/8);return 1==(1&this.buffer[b]>>>7-a%8)},put:function(a,b){for(var c=0;b>c;c++)this.putBit(1==(1&a>>>b-c-1))},getLengthInBits:function(){return this.length},putBit:function(a){var b=Math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0),a&&(this.buffer[b]|=128>>>this.length%8),this.length++}};var l=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],o=function(){var a=function(a,b){this._el=a,this._htOption=b};return a.prototype.draw=function(a){function g(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)b.hasOwnProperty(d)&&c.setAttribute(d,b[d]);return c}var b=this._htOption,c=this._el,d=a.getModuleCount();Math.floor(b.width/d),Math.floor(b.height/d),this.clear();var h=g("svg",{viewBox:"0 0 "+String(d)+" "+String(d),width:"100%",height:"100%",fill:b.colorLight});h.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),c.appendChild(h),h.appendChild(g("rect",{fill:b.colorDark,width:"1",height:"1",id:"template"}));for(var i=0;d>i;i++)for(var j=0;d>j;j++)if(a.isDark(i,j)){var k=g("use",{x:String(i),y:String(j)});k.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),h.appendChild(k)}},a.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},a}(),p="svg"===document.documentElement.tagName.toLowerCase(),q=p?o:m()?function(){function a(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function d(a,b){var c=this;if(c._fFail=b,c._fSuccess=a,null===c._bSupportDataURI){var d=document.createElement("img"),e=function(){c._bSupportDataURI=!1,c._fFail&&_fFail.call(c)},f=function(){c._bSupportDataURI=!0,c._fSuccess&&c._fSuccess.call(c)};return d.onabort=e,d.onerror=e,d.onload=f,d.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",void 0}c._bSupportDataURI===!0&&c._fSuccess?c._fSuccess.call(c):c._bSupportDataURI===!1&&c._fFail&&c._fFail.call(c)}if(this._android&&this._android<=2.1){var b=1/window.devicePixelRatio,c=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(a,d,e,f,g,h,i,j){if("nodeName"in a&&/img/i.test(a.nodeName))for(var l=arguments.length-1;l>=1;l--)arguments[l]=arguments[l]*b;else"undefined"==typeof j&&(arguments[1]*=b,arguments[2]*=b,arguments[3]*=b,arguments[4]*=b);c.apply(this,arguments)}}var e=function(a,b){this._bIsPainted=!1,this._android=n(),this._htOption=b,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=b.width,this._elCanvas.height=b.height,a.appendChild(this._elCanvas),this._el=a,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return e.prototype.draw=function(a){var b=this._elImage,c=this._oContext,d=this._htOption,e=a.getModuleCount(),f=d.width/e,g=d.height/e,h=Math.round(f),i=Math.round(g);b.style.display="none",this.clear();for(var j=0;e>j;j++)for(var k=0;e>k;k++){var l=a.isDark(j,k),m=k*f,n=j*g;c.strokeStyle=l?d.colorDark:d.colorLight,c.lineWidth=1,c.fillStyle=l?d.colorDark:d.colorLight,c.fillRect(m,n,f,g),c.strokeRect(Math.floor(m)+.5,Math.floor(n)+.5,h,i),c.strokeRect(Math.ceil(m)-.5,Math.ceil(n)-.5,h,i)}this._bIsPainted=!0},e.prototype.makeImage=function(){this._bIsPainted&&d.call(this,a)},e.prototype.isPainted=function(){return this._bIsPainted},e.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},e.prototype.round=function(a){return a?Math.floor(1e3*a)/1e3:a},e}():function(){var a=function(a,b){this._el=a,this._htOption=b};return a.prototype.draw=function(a){for(var b=this._htOption,c=this._el,d=a.getModuleCount(),e=Math.floor(b.width/d),f=Math.floor(b.height/d),g=[''],h=0;d>h;h++){g.push("");for(var i=0;d>i;i++)g.push('');g.push("")}g.push("
"),c.innerHTML=g.join("");var j=c.childNodes[0],k=(b.width-j.offsetWidth)/2,l=(b.height-j.offsetHeight)/2;k>0&&l>0&&(j.style.margin=l+"px "+k+"px")},a.prototype.clear=function(){this._el.innerHTML=""},a}();QRCode=function(a,b){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:d.H},"string"==typeof b&&(b={text:b}),b)for(var c in b)this._htOption[c]=b[c];"string"==typeof a&&(a=document.getElementById(a)),this._android=n(),this._el=a,this._oQRCode=null,this._oDrawing=new q(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(a){this._oQRCode=new b(r(a,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(a),this._oQRCode.make(),this._el.title=a,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=d}(); \ No newline at end of file diff --git a/luci-app-fileassistant/htdocs/luci-static/resources/fileassistant/fb.js b/luci-app-fileassistant/htdocs/luci-static/resources/fileassistant/fb.js index 898163b82..2e3addef8 100644 --- a/luci-app-fileassistant/htdocs/luci-static/resources/fileassistant/fb.js +++ b/luci-app-fileassistant/htdocs/luci-static/resources/fileassistant/fb.js @@ -19,7 +19,7 @@ String.prototype.replaceAll = function(search, replacement) { function removePath(filename, isdir) { var c = confirm('你确定要删除 ' + filename + ' 吗?'); if (c) { - iwxhr.get('/cgi-bin/luci/admin/services/fileassistant/delete', + iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/delete', { path: concatPath(currentPath, filename), isdir: isdir @@ -44,7 +44,7 @@ String.prototype.replaceAll = function(search, replacement) { } var c = confirm('你确定要安装 ' + filename + ' 吗?'); if (c) { - iwxhr.get('/cgi-bin/luci/admin/services/fileassistant/install', + iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/install', { filepath: concatPath(currentPath, filename), isdir: isdir @@ -76,7 +76,7 @@ String.prototype.replaceAll = function(search, replacement) { newname = newname.trim(); if (newname != filename) { var newpath = concatPath(currentPath, newname); - iwxhr.get('/cgi-bin/luci/admin/services/fileassistant/rename', + iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/rename', { filepath: concatPath(currentPath, filename), newpath: newpath @@ -93,7 +93,7 @@ String.prototype.replaceAll = function(search, replacement) { function openpath(filename, dirname) { dirname = dirname || currentPath; - window.open('/cgi-bin/luci/admin/services/fileassistant/open?path=' + window.open('/cgi-bin/luci/admin/nas/fileassistant/open?path=' + encodeURIComponent(dirname) + '&filename=' + encodeURIComponent(filename)); } @@ -210,7 +210,7 @@ String.prototype.replaceAll = function(search, replacement) { opt = opt || {}; path = concatPath(path, ''); if (currentPath != path) { - iwxhr.get('/cgi-bin/luci/admin/services/fileassistant/list', + iwxhr.get('/cgi-bin/luci/admin/nas/fileassistant/list', {path: path}, function (x, res) { if (res.ec === 0) { @@ -255,7 +255,7 @@ String.prototype.replaceAll = function(search, replacement) { formData.append('upload-dir', concatPath(currentPath, '')); formData.append('upload-file', uploadinput.files[0]); var xhr = new XMLHttpRequest(); - xhr.open("POST", "/cgi-bin/luci/admin/services/fileassistant/upload", true); + xhr.open("POST", "/cgi-bin/luci/admin/nas/fileassistant/upload", true); xhr.onload = function() { if (xhr.status == 200) { var res = JSON.parse(xhr.responseText); diff --git a/luci-app-fileassistant/luasrc/controller/fileassistant.lua b/luci-app-fileassistant/luasrc/controller/fileassistant.lua index 6a9f8414e..0899edf33 100644 --- a/luci-app-fileassistant/luasrc/controller/fileassistant.lua +++ b/luci-app-fileassistant/luasrc/controller/fileassistant.lua @@ -1,32 +1,32 @@ module("luci.controller.fileassistant", package.seeall) function index() - entry({"admin", "services"}, firstchild(), _("Services") , 45).dependent = false + entry({"admin", "nas"}, firstchild(), _("NAS") , 45).dependent = false - entry({"admin", "services"}, firstchild(), "Services", 44).dependent = false + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false local page - page = entry({"admin", "services", "fileassistant"}, template("fileassistant"), _("文件助手"), 1) + page = entry({"admin", "nas", "fileassistant"}, template("fileassistant"), _("文件助手"), 1) page.i18n = "base" page.dependent = true page.acl_depends = { "luci-app-fileassistant" } - page = entry({"admin", "services", "fileassistant", "list"}, call("fileassistant_list"), nil) + page = entry({"admin", "nas", "fileassistant", "list"}, call("fileassistant_list"), nil) page.leaf = true - page = entry({"admin", "services", "fileassistant", "open"}, call("fileassistant_open"), nil) + page = entry({"admin", "nas", "fileassistant", "open"}, call("fileassistant_open"), nil) page.leaf = true - page = entry({"admin", "services", "fileassistant", "delete"}, call("fileassistant_delete"), nil) + page = entry({"admin", "nas", "fileassistant", "delete"}, call("fileassistant_delete"), nil) page.leaf = true - page = entry({"admin", "services", "fileassistant", "rename"}, call("fileassistant_rename"), nil) + page = entry({"admin", "nas", "fileassistant", "rename"}, call("fileassistant_rename"), nil) page.leaf = true - page = entry({"admin", "services", "fileassistant", "upload"}, call("fileassistant_upload"), nil) + page = entry({"admin", "nas", "fileassistant", "upload"}, call("fileassistant_upload"), nil) page.leaf = true - page = entry({"admin", "services", "fileassistant", "install"}, call("fileassistant_install"), nil) + page = entry({"admin", "nas", "fileassistant", "install"}, call("fileassistant_install"), nil) page.leaf = true end diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index 3b1f79dd0..cf94fc8fd 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.16-5 +PKG_VERSION:=1.16-6 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/passwall2/server_app.lua b/luci-app-passwall2/luasrc/passwall2/server_app.lua index 84395520d..aa3dca543 100644 --- a/luci-app-passwall2/luasrc/passwall2/server_app.lua +++ b/luci-app-passwall2/luasrc/passwall2/server_app.lua @@ -8,6 +8,7 @@ local jsonc = api.jsonc local CONFIG = "passwall2_server" local CONFIG_PATH = "/tmp/etc/" .. CONFIG +local NFT_INCLUDE_FILE = CONFIG_PATH .. "/" .. CONFIG .. ".nft" local LOG_APP_FILE = "/tmp/log/" .. CONFIG .. ".log" local TMP_BIN_PATH = CONFIG_PATH .. "/bin" local require_dir = "luci.passwall2." @@ -53,11 +54,6 @@ end local function gen_include() cmd(string.format("echo '#!/bin/sh' > /tmp/etc/%s.include", CONFIG)) - if nft_flag == "1" then - cmd("echo \"\" > " .. CONFIG_PATH .. "/" .. CONFIG .. ".nft") - local nft_cmd = "for chain in $(nft -a list chains |grep -E \"chain PSW2-SERVER\" |awk -F ' ' '{print$2}'); do\n nft list chain inet fw4 ${chain} >> " .. CONFIG_PATH .. "/" .. CONFIG .. ".nft\n done" - cmd(nft_cmd) - end local function extract_rules(n, a) local _ipt = ipt_bin if n == "6" then @@ -81,8 +77,7 @@ local function gen_include() f:write("EOT" .. "\n") f:close() else - f:write("nft -f " .. CONFIG_PATH .. "/" .. CONFIG .. ".nft\n") - f:write("nft insert rule inet fw4 input position 0 counter jump PSW2-SERVER") + f:write("nft -f " .. NFT_INCLUDE_FILE .. "\n") f:close() end end @@ -101,8 +96,11 @@ local function start() ip6t("-N PSW2-SERVER") ip6t("-I INPUT -j PSW2-SERVER") else - cmd("nft add chain inet fw4 PSW2-SERVER\n") - cmd("nft insert rule inet fw4 input position 0 counter jump PSW2-SERVER") + nft_file, err = io.open(NFT_INCLUDE_FILE, "w") + nft_file:write('#!/usr/sbin/nft -f\n') + nft_file:write('add chain inet fw4 PSW2-SERVER\n') + nft_file:write('flush chain inet fw4 PSW2-SERVER\n') + nft_file:write('insert rule inet fw4 input position 0 jump PSW2-SERVER comment "PSW2-SERVER"\n') end uci:foreach(CONFIG, "user", function(user) local id = user[".name"] @@ -189,14 +187,19 @@ local function start() ip6t(string.format('-A PSW2-SERVER -p udp --dport %s -m comment --comment "%s" -j ACCEPT', port, remarks)) end else - cmd(string.format('nft add rule inet fw4 PSW2-SERVER meta l4proto tcp tcp dport {%s} accept', port)) + nft_file:write(string.format('add rule inet fw4 PSW2-SERVER meta l4proto tcp tcp dport {%s} counter accept comment "%s"\n', port, remarks)) if udp_forward == 1 then - cmd(string.format('nft add rule inet fw4 PSW2-SERVER meta l4proto udp udp dport {%s} accept', port)) + nft_file:write(string.format('add rule inet fw4 PSW2-SERVER meta l4proto udp udp dport {%s} counter accept comment "%s"\n', port, remarks)) end end end end end) + if nft_flag == "1" then + nft_file:write("add rule inet fw4 PSW2-SERVER return\n") + nft_file:close() + cmd("nft -f " .. NFT_INCLUDE_FILE) + end gen_include() end diff --git a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh index d4cb64729..35c262e68 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh @@ -10,7 +10,7 @@ NFTSET_LANLIST6="passwall2_lanlist6" NFTSET_VPSLIST6="passwall2_vpslist6" NFTSET_WHITELIST6="passwall2_whitelist6" -FORCE_INDEX=2 +FORCE_INDEX=0 . /lib/functions/network.sh @@ -117,10 +117,8 @@ destroy_nftset() { insert_nftset() { local nftset_name="${1}"; shift local nftset_elements - for element in $@ - do - nftset_elements="$element,$nftset_elements" - done + + nftset_elements=$(echo -e $@ | sed 's/\s/, /g') [ -n "${nftset_elements}" ] && { mkdir -p $TMP_PATH2/nftset @@ -273,8 +271,8 @@ load_acl() { msg2="${msg2}所有端口" if [ -z "${is_tproxy}" ]; then - nft "add rule inet fw4 PSW2 ${_ipt_source} ip daddr $FAKE_IP $(REDIRECT $redir_port) comment \"$remarks\"" - nft "add rule inet fw4 PSW2 ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") $(REDIRECT $redir_port) comment \"$remarks\"" + nft "add rule inet fw4 PSW2_NAT ${_ipt_source} ip daddr $FAKE_IP $(REDIRECT $redir_port) comment \"$remarks\"" + nft "add rule inet fw4 PSW2_NAT ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") $(REDIRECT $redir_port) comment \"$remarks\"" else nft "add rule inet fw4 PSW2_MANGLE ip protocol tcp ${_ipt_source} ip daddr $FAKE_IP counter jump PSW2_RULE comment \"$remarks\"" nft "add rule inet fw4 PSW2_MANGLE ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") counter jump PSW2_RULE comment \"$remarks\"" @@ -358,8 +356,8 @@ load_acl() { } if [ -z "${is_tproxy}" ]; then - nft "add rule inet fw4 PSW2 ip protocol tcp ip daddr $FAKE_IP $(REDIRECT $REDIR_PORT) comment \"默认\"" - nft "add rule inet fw4 PSW2 ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") $(REDIRECT $REDIR_PORT) comment \"默认\"" + nft "add rule inet fw4 PSW2_NAT ip protocol tcp ip daddr $FAKE_IP $(REDIRECT $REDIR_PORT) comment \"默认\"" + nft "add rule inet fw4 PSW2_NAT ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") $(REDIRECT $REDIR_PORT) comment \"默认\"" else nft "add rule inet fw4 PSW2_MANGLE ip protocol tcp ip daddr $FAKE_IP counter jump PSW2_RULE comment \"默认\"" nft "add rule inet fw4 PSW2_MANGLE ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") jump PSW2_RULE comment \"默认\"" @@ -459,7 +457,7 @@ filter_node() { local ADD_INDEX=$FORCE_INDEX for _ipt in 4 6; do - [ "$_ipt" == "4" ] && _ip_type=ip4 && _set_name=$NFTSET_VPSLIST + [ "$_ipt" == "4" ] && _ip_type=ip && _set_name=$NFTSET_VPSLIST [ "$_ipt" == "6" ] && _ip_type=ip6 && _set_name=$NFTSET_VPSLIST6 nft "list chain inet fw4 $nft_output_chain" 2>/dev/null | grep -q "${address}:${port}" if [ $? -ne 0 ]; then @@ -475,8 +473,7 @@ filter_node() { dst_rule="return" msg2="直连代理" } - nft "insert rule inet fw4 $nft_output_chain position $ADD_INDEX comment \"${address}:${port}\" meta l4proto $stream $_ip_type daddr $address tcp dport $port $dst_rule" 2>/dev/null - nft "insert rule inet fw4 $nft_output_chain position $ADD_INDEX comment \"${address}:${port}\" meta l4proto $stream $_ip_type daddr $address udp dport $port $dst_rule" 2>/dev/null + nft "insert rule inet fw4 $nft_output_chain position $ADD_INDEX meta l4proto $stream $_ip_type daddr $address $stream dport $port $dst_rule comment \"${address}:${port}\"" 2>/dev/null else msg2="已配置过的节点," fi @@ -588,8 +585,8 @@ add_firewall_rule() { local tcp_proxy_way=$(config_t_get global_forwarding tcp_proxy_way redirect) if [ "$tcp_proxy_way" = "redirect" ]; then unset is_tproxy - nft_prerouting_chain="PSW2" - nft_output_chain="PSW2_OUTPUT" + nft_prerouting_chain="PSW2_NAT" + nft_output_chain="PSW2_OUTPUT_NAT" elif [ "$tcp_proxy_way" = "tproxy" ]; then is_tproxy="TPROXY" nft_prerouting_chain="PSW2_MANGLE" @@ -635,19 +632,19 @@ add_firewall_rule() { #ipv4 tcp redirect mode [ -z "${is_tproxy}" ] && { - nft "add chain inet fw4 PSW2" - nft "flush chain inet fw4 PSW2" - nft "add rule inet fw4 PSW2 ip daddr @$NFTSET_LANLIST counter return" - nft "add rule inet fw4 PSW2 ip daddr @$NFTSET_VPSLIST counter return" - nft "add rule inet fw4 PSW2 ip daddr @$NFTSET_WHITELIST counter return" - nft "add rule inet fw4 dstnat ip protocol tcp counter jump PSW2" + nft "add chain inet fw4 PSW2_NAT" + nft "flush chain inet fw4 PSW2_NAT" + nft "add rule inet fw4 PSW2_NAT ip daddr @$NFTSET_LANLIST counter return" + nft "add rule inet fw4 PSW2_NAT ip daddr @$NFTSET_VPSLIST counter return" + nft "add rule inet fw4 PSW2_NAT ip daddr @$NFTSET_WHITELIST counter return" + nft "add rule inet fw4 dstnat ip protocol tcp counter jump PSW2_NAT" - nft "add chain inet fw4 PSW2_OUTPUT" - nft "flush chain inet fw4 PSW2_OUTPUT" - nft "add rule inet fw4 PSW2_OUTPUT ip daddr @$NFTSET_LANLIST counter return" - nft "add rule inet fw4 PSW2_OUTPUT ip daddr @$NFTSET_VPSLIST counter return" - nft "add rule inet fw4 PSW2_OUTPUT ip daddr @$NFTSET_WHITELIST counter return" - nft "add rule inet fw4 PSW2_OUTPUT meta mark 0xff counter return" + nft "add chain inet fw4 PSW2_OUTPUT_NAT" + nft "flush chain inet fw4 PSW2_OUTPUT_NAT" + nft "add rule inet fw4 PSW2_OUTPUT_NAT ip daddr @$NFTSET_LANLIST counter return" + nft "add rule inet fw4 PSW2_OUTPUT_NAT ip daddr @$NFTSET_VPSLIST counter return" + nft "add rule inet fw4 PSW2_OUTPUT_NAT ip daddr @$NFTSET_WHITELIST counter return" + nft "add rule inet fw4 PSW2_OUTPUT_NAT meta mark 0xff counter return" } #icmp ipv6-icmp redirect @@ -670,7 +667,7 @@ add_firewall_rule() { WAN_IP=$(get_wan_ip) if [ -n "${WAN_IP}" ]; then - [ -n "${is_tproxy}" ] && nft "add rule inet fw4 PSW2_MANGLE ip daddr ${WAN_IP} counter return comment \"WAN_IP_RETURN\"" || nft "add rule inet fw4 PSW2 ip daddr ${WAN_IP} counter return comment \"WAN_IP_RETURN\"" + [ -n "${is_tproxy}" ] && nft "add rule inet fw4 PSW2_MANGLE ip daddr ${WAN_IP} counter return comment \"WAN_IP_RETURN\"" || nft "add rule inet fw4 PSW2_NAT ip daddr ${WAN_IP} counter return comment \"WAN_IP_RETURN\"" fi unset WAN_IP @@ -694,7 +691,7 @@ add_firewall_rule() { # jump chains [ "$PROXY_IPV6" == "1" ] && { nft "add rule inet fw4 mangle_prerouting meta nfproto {ipv6} counter jump PSW2_MANGLE_V6" - nft "add rule inet fw4 mangle_output meta nfproto {ipv6} counter jump PSW2_OUTPUT_MANGLE_V6 comment \"mangle-OUTPUT-PSW2\"" + nft "add rule inet fw4 mangle_output meta nfproto {ipv6} counter jump PSW2_OUTPUT_MANGLE_V6 comment \"PSW2_OUTPUT_MANGLE\"" WAN6_IP=$(get_wan6_ip) [ -n "${WAN6_IP}" ] && nft "add rule inet fw4 PSW2_MANGLE_V6 ip6 daddr ${WAN6_IP} counter return comment \"WAN6_IP_RETURN\"" @@ -751,15 +748,15 @@ add_firewall_rule() { } if [ -z "${is_tproxy}" ]; then - nft "add rule inet fw4 PSW2_OUTPUT ip protocol tcp ip daddr $FAKE_IP $(REDIRECT $REDIR_PORT)" - nft "add rule inet fw4 PSW2_OUTPUT ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") $(REDIRECT $REDIR_PORT)" - nft "add rule inet fw4 nat_output ip protocol tcp counter jump PSW2_OUTPUT" + nft "add rule inet fw4 PSW2_OUTPUT_NAT ip protocol tcp ip daddr $FAKE_IP $(REDIRECT $REDIR_PORT)" + nft "add rule inet fw4 PSW2_OUTPUT_NAT ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") $(REDIRECT $REDIR_PORT)" + nft "add rule inet fw4 nat_output ip protocol tcp counter jump PSW2_OUTPUT_NAT" else nft "add rule inet fw4 PSW2_OUTPUT_MANGLE ip protocol tcp ip daddr $FAKE_IP counter jump PSW2_RULE" nft "add rule inet fw4 PSW2_OUTPUT_MANGLE ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") jump PSW2_RULE" nft "add rule inet fw4 PSW2_MANGLE meta l4proto tcp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\"" nft "add rule inet fw4 PSW2_MANGLE ip protocol tcp iif lo counter return comment \"本机\"" - nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto tcp counter jump PSW2_OUTPUT_MANGLE comment \"mangle-OUTPUT-PSW2\"" + nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto tcp counter jump PSW2_OUTPUT_MANGLE comment \"PSW2_OUTPUT_MANGLE\"" fi [ "$PROXY_IPV6" == "1" ] && { @@ -793,7 +790,7 @@ add_firewall_rule() { nft "add rule inet fw4 PSW2_OUTPUT_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") jump PSW2_RULE" nft "add rule inet fw4 PSW2_MANGLE meta l4proto udp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\"" nft "add rule inet fw4 PSW2_MANGLE ip protocol udp iif lo counter return comment \"本机\"" - nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto udp counter jump PSW2_OUTPUT_MANGLE comment \"mangle-OUTPUT-PSW2\"" + nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto udp counter jump PSW2_OUTPUT_MANGLE comment \"PSW2_OUTPUT_MANGLE\"" if [ "$PROXY_IPV6_UDP" == "1" ]; then nft "add rule inet fw4 PSW2_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr $FAKE_IP_6 jump PSW2_RULE" @@ -808,8 +805,8 @@ add_firewall_rule() { done fi - nft "add rule inet fw4 mangle_output oif lo counter return comment \"mangle-OUTPUT-PSW2\"" - nft "add rule inet fw4 mangle_output meta mark 1 counter return comment \"mangle-OUTPUT-PSW2\"" + nft "add rule inet fw4 mangle_output oif lo counter return comment \"PSW2_OUTPUT_MANGLE\"" + nft "add rule inet fw4 mangle_output meta mark 1 counter return comment \"PSW2_OUTPUT_MANGLE\"" nft "add rule inet fw4 PSW2_MANGLE ip protocol udp udp dport 53 counter return" nft "add rule inet fw4 PSW2_MANGLE_V6 meta l4proto udp udp dport 53 counter return" @@ -832,14 +829,14 @@ add_firewall_rule() { } del_firewall_rule() { - for nft in "input" "forward" "dstnat" "srcnat" "nat_output" "mangle_prerouting" "mangle_output"; do - local handles=$(nft -a list chain inet fw4 ${nft} 2>/dev/null | grep -E "PSW2" | awk -F '# handle ' '{print$2}') + for nft in "forward" "dstnat" "srcnat" "nat_output" "mangle_prerouting" "mangle_output"; do + local handles=$(nft -a list chain inet fw4 ${nft} 2>/dev/null | grep -E "PSW2_" | awk -F '# handle ' '{print$2}') for handle in $handles; do nft delete rule inet fw4 ${nft} handle ${handle} 2>/dev/null done done - for handle in $(nft -a list chains | grep -E "chain PSW2" | grep -v "PSW2_RULE" | awk -F '# handle ' '{print$2}'); do + for handle in $(nft -a list chains | grep -E "chain PSW2_" | grep -v "PSW2_RULE" | awk -F '# handle ' '{print$2}'); do nft delete chain inet fw4 handle ${handle} 2>/dev/null done @@ -875,60 +872,70 @@ flush_include() { } gen_include() { - local nft_chain_file=$TMP_PATH/PSW2.nft - echo "" > $nft_chain_file - for chain in $(nft -a list chains | grep -E "chain PSW2" |awk -F ' ' '{print$2}'); do + local nft_chain_file=$TMP_PATH/PSW2_RULE.nft + local nft_set_file=$TMP_PATH/PSW2_SETS.nft + echo "#!/usr/sbin/nft -f" > $nft_chain_file + echo "#!/usr/sbin/nft -f" > $nft_set_file + for chain in $(nft -a list chains | grep -E "chain PSW2_" | awk -F ' ' '{print$2}'); do nft list chain inet fw4 ${chain} >> $nft_chain_file done + + for set_name in $(nft -a list sets | grep -E "set passwall2_" | awk -F ' ' '{print$2}'); do + nft list set inet fw4 ${set_name} >> $nft_set_file + done local __nft=" " - [ -z "${nft}" ] && { - __nft=$(cat <<- EOF - nft -f ${nft_chain_file} + __nft=$(cat <<- EOF - nft "add rule inet fw4 dstnat jump PSW2_REDIRECT" + [ -z "\$(nft list sets 2>/dev/null | grep "passwall2_")" ] && nft -f ${nft_set_file} + [ -z "\$(nft list chain inet fw4 nat_output 2>/dev/null)" ] && nft "add chain inet fw4 nat_output { type nat hook output priority -1; }" + nft -f ${nft_chain_file} - [ "$accept_icmp" == "1" ] && { - nft "add rule inet fw4 dstnat meta l4proto {icmp,icmpv6} counter jump PSW2_ICMP_REDIRECT" - nft "add rule inet fw4 nat_output meta l4proto {icmp,icmpv6} counter jump PSW2_ICMP_REDIRECT" - } + nft "add rule inet fw4 dstnat jump PSW2_REDIRECT" - [ -z "${is_tproxy}" ] && { - PR_INDEX=\$(${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2 WAN_IP_RETURN -1) - if [ \$PR_INDEX -ge 0 ]; then - WAN_IP=\$(${MY_PATH} get_wan_ip) - [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2 handle \$PR_INDEX ip daddr "\${WAN_IP}" counter return comment \"WAN_IP_RETURN\"" - fi - nft "add rule inet fw4 dstnat ip protocol tcp counter jump PSW2" - nft "add rule inet fw4 nat_output ip protocol tcp counter jump PSW2_OUTPUT" - } + [ "$accept_icmp" == "1" ] && { + nft "add rule inet fw4 dstnat meta l4proto {icmp,icmpv6} counter jump PSW2_ICMP_REDIRECT" + nft "add rule inet fw4 nat_output meta l4proto {icmp,icmpv6} counter jump PSW2_ICMP_REDIRECT" + } - [ -n "${is_tproxy}" ] && { - PR_INDEX=\$(${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2_MANGLE WAN_IP_RETURN -1) - if [ \$PR_INDEX -ge 0 ]; then - WAN_IP=\$(${MY_PATH} get_wan_ip) - [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2_MANGLE handle \$PR_INDEX ip daddr "\${WAN_IP}" counter return comment \"WAN_IP_RETURN\"" - fi - nft "add rule inet fw4 mangle_prerouting meta nfproto {ipv4} counter jump PSW2_MANGLE" - nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto tcp counter jump PSW2_OUTPUT_MANGLE comment \"mangle-OUTPUT-PSW2\"" - } - \$(${MY_PATH} insert_rule_before "inet fw4" "mangle_prerouting" "PSW2_MANGLE" "counter jump PSW2_DIVERT") + [ -z "${is_tproxy}" ] && { + PR_INDEX=\$(sh ${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2_NAT WAN_IP_RETURN -1) + if [ \$PR_INDEX -ge 0 ]; then + WAN_IP=\$(sh ${MY_PATH} get_wan_ip) + [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2_NAT handle \$PR_INDEX ip daddr "\${WAN_IP}" counter return comment \"WAN_IP_RETURN\"" + fi + nft "add rule inet fw4 dstnat ip protocol tcp counter jump PSW2_NAT" + nft "add rule inet fw4 nat_output ip protocol tcp counter jump PSW2_OUTPUT_NAT" + } - [ "$PROXY_IPV6" == "1" ] && { - PR_INDEX=\$(${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2_MANGLE_V6 WAN6_IP_RETURN -1) - if [ \$PR_INDEX -ge 0 ]; then - WAN6_IP=\$(${MY_PATH} get_wan6_ip) - [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2_MANGLE_V6 handle \$PR_INDEX ip6 daddr "\${WAN6_IP}" counter return comment \"WAN6_IP_RETURN\"" - fi - nft "add rule inet fw4 mangle_prerouting meta nfproto {ipv6} counter jump PSW2_MANGLE_V6" - nft "add rule inet fw4 mangle_output meta nfproto {ipv6} counter jump PSW2_OUTPUT_MANGLE_V6 comment \"mangle-OUTPUT-PSW2\"" - } + [ -n "${is_tproxy}" ] && { + PR_INDEX=\$(sh ${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2_MANGLE WAN_IP_RETURN -1) + if [ \$PR_INDEX -ge 0 ]; then + WAN_IP=\$(sh ${MY_PATH} get_wan_ip) + [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2_MANGLE handle \$PR_INDEX ip daddr "\${WAN_IP}" counter return comment \"WAN_IP_RETURN\"" + fi + nft "add rule inet fw4 mangle_prerouting meta nfproto {ipv4} counter jump PSW2_MANGLE" + nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto tcp counter jump PSW2_OUTPUT_MANGLE comment \"PSW2_OUTPUT_MANGLE\"" + } + \$(sh ${MY_PATH} insert_rule_before "inet fw4" "mangle_prerouting" "PSW2_MANGLE" "counter jump PSW2_DIVERT") + + [ "$UDP_NODE" != "nil" -o "$TCP_UDP" = "1" ] && nft "add rule inet fw4 mangle_output meta nfproto {ipv4} meta l4proto udp counter jump PSW2_OUTPUT_MANGLE comment \"PSW2_OUTPUT_MANGLE\"" + + [ "$PROXY_IPV6" == "1" ] && { + PR_INDEX=\$(sh ${MY_PATH} RULE_LAST_INDEX "inet fw4" PSW2_MANGLE_V6 WAN6_IP_RETURN -1) + if [ \$PR_INDEX -ge 0 ]; then + WAN6_IP=\$(sh ${MY_PATH} get_wan6_ip) + [ ! -z "\${WAN_IP}" ] && nft "replace rule inet fw4 PSW2_MANGLE_V6 handle \$PR_INDEX ip6 daddr "\${WAN6_IP}" counter return comment \"WAN6_IP_RETURN\"" + fi + nft "add rule inet fw4 mangle_prerouting meta nfproto {ipv6} counter jump PSW2_MANGLE_V6" + nft "add rule inet fw4 mangle_output meta nfproto {ipv6} counter jump PSW2_OUTPUT_MANGLE_V6 comment \"PSW2_OUTPUT_MANGLE\"" + } + + nft "add rule inet fw4 mangle_output oif lo counter return comment \"PSW2_OUTPUT_MANGLE\"" + nft "add rule inet fw4 mangle_output meta mark 1 counter return comment \"PSW2_OUTPUT_MANGLE\"" + EOF + ) - nft "add rule inet fw4 mangle_output oif lo counter return comment \"mangle-OUTPUT-PSW2\"" - nft "add rule inet fw4 mangle_output meta mark 1 counter return comment \"mangle-OUTPUT-PSW2\"" - EOF - ) - } cat <<-EOF >> $FWI ${__nft} EOF diff --git a/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua b/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua index 4e21b6522..2cb609726 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua @@ -18,6 +18,7 @@ local v2ray_asset_location = ucic:get_first(name, 'global_rules', "v2ray_locatio local geoip_api = ucic:get_first(name, 'global_rules', "geoip_url", "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest") local geosite_api = ucic:get_first(name, 'global_rules', "geosite_url", "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest") -- +local use_nft = ucic:get(name, "@global_forwarding[0]", "use_nft") or "0" local log = function(...) if arg1 then @@ -184,6 +185,10 @@ luci.sys.call("uci commit " .. name) if reboot == 1 then log("重启服务,应用新的规则。") - luci.sys.call("/usr/share/" .. name .. "/iptables.sh flush_ipset > /dev/null 2>&1 &") + if use_nft == "1" then + luci.sys.call("sh /usr/share/" .. name .. "/nftables.sh flush_nftset > /dev/null 2>&1 &") + else + luci.sys.call("sh /usr/share/" .. name .. "/iptables.sh flush_ipset > /dev/null 2>&1 &") + end end log("规则更新完毕...") diff --git a/luci-app-wxedge/Makefile b/luci-app-wxedge/Makefile index 7b3de350a..624e9cbc2 100644 --- a/luci-app-wxedge/Makefile +++ b/luci-app-wxedge/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk -PKG_VERSION:=1.1.2-20230108 +PKG_VERSION:=1.1.3-20230614 PKG_RELEASE:= LUCI_TITLE:=LuCI support for wxedge diff --git a/luci-app-wxedge/luasrc/model/cbi/wxedge.lua b/luci-app-wxedge/luasrc/model/cbi/wxedge.lua index 8d7fa4863..065d8922d 100644 --- a/luci-app-wxedge/luasrc/model/cbi/wxedge.lua +++ b/luci-app-wxedge/luasrc/model/cbi/wxedge.lua @@ -3,26 +3,9 @@ LuCI - Lua Configuration Interface ]]-- local taskd = require "luci.model.tasks" +local wxedge_model = require "luci.model.wxedge" local m, s, o -local function blocks() - local util = require "luci.util" - local jsonc = require "luci.jsonc" - local text = util.trim(util.exec("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json")) - local vals = {} - if text and text ~= "" then - local obj = jsonc.parse(text) - for _, val in pairs(obj["blockdevices"]) do - local fsize = val["fssize"] - if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then - -- fsize > 1G - vals[#vals+1] = val["mountpoint"] - end - end - end - return vals -end - m = taskd.docker_map("wxedge", "wxedge", "/usr/libexec/istorec/wxedge.sh", translate("Onething Edge"), "「网心云-容器魔方」由网心云推出的一款 docker 容器镜像软件,通过在简单安装后即可快速加入网心云共享计算生态网络,用户可根据每日的贡献量获得相应的现金收益回报。了解更多,请登录「网心云官网」") @@ -34,7 +17,17 @@ s = m:section(TypedSection, "wxedge", translate("Setup"), translate("The followi s.addremove=false s.anonymous=true -local blks = blocks() +local default_image = wxedge_model.default_image() +o = s:option(Value, "image_name", translate("Image").."*") +o.rmempty = false +o.datatype = "string" +o:value("onething1/wxedge", "onething1/wxedge") +o:value("onething1/wxedge:2.4.3", "onething1/wxedge:2.4.3") +o:value("registry.hub.docker.com/onething1/wxedge", "registry.hub.docker.com/onething1/wxedge") +o:value("registry.hub.docker.com/onething1/wxedge:2.4.3", "registry.hub.docker.com/onething1/wxedge:2.4.3") +o.default = default_image + +local blks = wxedge_model.blocks() local dir o = s:option(Value, "cache_path", translate("Cache path").."*", "请选择合适的存储位置进行安装,安装位置容量越大,收益越高。安装后请勿轻易改动") o.rmempty = false diff --git a/luci-app-wxedge/luasrc/model/wxedge.lua b/luci-app-wxedge/luasrc/model/wxedge.lua new file mode 100644 index 000000000..22f3c2f6b --- /dev/null +++ b/luci-app-wxedge/luasrc/model/wxedge.lua @@ -0,0 +1,34 @@ +local util = require "luci.util" +local jsonc = require "luci.jsonc" +local nixio = require "nixio" + +local wxedge = {} + +wxedge.blocks = function() + local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r") + local vals = {} + if f then + local ret = f:read("*all") + f:close() + local obj = jsonc.parse(ret) + for _, val in pairs(obj["blockdevices"]) do + local fsize = val["fssize"] + if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then + -- fsize > 1G + vals[#vals+1] = val["mountpoint"] + end + end + end + return vals +end + +wxedge.default_image = function() + if string.find(nixio.uname().machine, "x86_64") then + return "onething1/wxedge" + else + return "onething1/wxedge:2.4.3" + end +end + +return wxedge + diff --git a/luci-app-wxedge/root/etc/config/wxedge b/luci-app-wxedge/root/etc/config/wxedge index e026c41fe..43df2055c 100644 --- a/luci-app-wxedge/root/etc/config/wxedge +++ b/luci-app-wxedge/root/etc/config/wxedge @@ -1,2 +1,3 @@ config wxedge option 'cache_path' '' + option 'image_name' '' diff --git a/luci-app-wxedge/root/etc/uci-defaults/luci-app-wxedge b/luci-app-wxedge/root/etc/uci-defaults/luci-app-wxedge index c383ccf1e..65786c755 100644 --- a/luci-app-wxedge/root/etc/uci-defaults/luci-app-wxedge +++ b/luci-app-wxedge/root/etc/uci-defaults/luci-app-wxedge @@ -6,7 +6,7 @@ uci -q batch <<-EOF >/dev/null set firewall.wxedge.name="wxedge" set firewall.wxedge.target="ACCEPT" set firewall.wxedge.src="wan" - set firewall.wxedge.dest_port="40000-65535" + set firewall.wxedge.dest_port="1024-65535" set firewall.wxedge.enabled="0" commit firewall EOF diff --git a/luci-app-wxedge/root/usr/libexec/istorec/wxedge.sh b/luci-app-wxedge/root/usr/libexec/istorec/wxedge.sh index 55cbdd784..aa28f7ea5 100755 --- a/luci-app-wxedge/root/usr/libexec/istorec/wxedge.sh +++ b/luci-app-wxedge/root/usr/libexec/istorec/wxedge.sh @@ -3,27 +3,20 @@ ACTION=${1} shift 1 -get_image() { - IMAGE_NAME="registry.hub.docker.com/onething1/wxedge" -} - do_install() { - get_image - echo "docker pull ${IMAGE_NAME}" - docker pull ${IMAGE_NAME} - docker rm -f wxedge - - do_install_detail -} - -do_install_detail() { local path=`uci get wxedge.@wxedge[0].cache_path 2>/dev/null` + local image_name=`uci get wxedge.@wxedge[0].image_name 2>/dev/null` if [ -z "$path" ]; then echo "path is empty!" exit 1 fi + [ -z "$image_name" ] && image_name="onething1/wxedge" + echo "docker pull ${image_name}" + docker pull ${image_name} + docker rm -f wxedge + local cmd="docker run --restart=unless-stopped -d \ --privileged \ --network=host \ @@ -37,7 +30,7 @@ do_install_detail() { local tz="`uci get system.@system[0].zonename`" [ -z "$tz" ] || cmd="$cmd -e TZ=$tz" - cmd="$cmd --name wxedge \"$IMAGE_NAME\"" + cmd="$cmd --name wxedge \"$image_name\"" echo "$cmd" eval "$cmd" diff --git a/v2ray-geodata/Makefile b/v2ray-geodata/Makefile index 9f45fac36..6393cbb70 100644 --- a/v2ray-geodata/Makefile +++ b/v2ray-geodata/Makefile @@ -21,13 +21,13 @@ define Download/geoip HASH:=a3c407051f1e2bbeef98c82372cec8de3ee6d44f645eeb07699bfcaec4ea3f1b endef -GEOSITE_VER:=20230613031206 +GEOSITE_VER:=20230614081211 GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER) define Download/geosite URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/ URL_FILE:=dlc.dat FILE:=$(GEOSITE_FILE) - HASH:=1cd19fcedf30ff22df215c40e7797a36366e63e1e5cb9572c9b16789af1dde64 + HASH:=bc72217e378cf0c726cb1507126f0d5b563096c42832305523a6c4d1806c15a3 endef define Package/v2ray-geodata/template