-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from coolsnowwolf/master
同步上游
- Loading branch information
Showing
38 changed files
with
3,441 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adupdate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Copyright 2016-2017 Xingwang Liao <[email protected]> | ||
# Licensed to the public under the Apache License 2.0. | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=luci-app-kcptun | ||
PKG_VERSION:=1.4.3 | ||
PKG_RELEASE:=1 | ||
|
||
PKG_LICENSE:=Apache-2.0 | ||
PKG_MAINTAINER:=Xingwang Liao <[email protected]> | ||
|
||
LUCI_TITLE:=LuCI support for Kcptun | ||
LUCI_DEPENDS:=+jshn +wget +luci-lib-jsonc | ||
LUCI_PKGARCH:=all | ||
|
||
define Package/$(PKG_NAME)/conffiles | ||
/etc/config/kcptun | ||
endef | ||
|
||
include $(TOPDIR)/feeds/luci/luci.mk | ||
|
||
define Package/$(PKG_NAME)/postinst | ||
#!/bin/sh | ||
if [ -z "$${IPKG_INSTROOT}" ]; then | ||
( . /etc/uci-defaults/40_luci-kcptun ) && rm -f /etc/uci-defaults/40_luci-kcptun | ||
fi | ||
chmod 755 $${IPKG_INSTROOT}/etc/init.d/kcptun >/dev/null 2>&1 | ||
$${IPKG_INSTROOT}/etc/init.d/kcptun enable >/dev/null 2>&1 | ||
exit 0 | ||
endef | ||
|
||
# call BuildPackage - OpenWrt buildroot signature |
120 changes: 120 additions & 0 deletions
120
package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
-- Copyright 2016-2017 Xingwang Liao <[email protected]> | ||
-- Licensed to the public under the Apache License 2.0. | ||
|
||
module("luci.controller.kcptun", package.seeall) | ||
|
||
local http = require "luci.http" | ||
local kcp = require "luci.model.kcptun" | ||
|
||
function index() | ||
if not nixio.fs.access("/etc/config/kcptun") then | ||
return | ||
end | ||
|
||
entry({"admin", "services", "kcptun"}, | ||
firstchild(), _("Kcptun Client")).dependent = false | ||
|
||
entry({"admin", "services", "kcptun", "settings"}, | ||
cbi("kcptun/settings"), _("Settings"), 1) | ||
|
||
entry({"admin", "services", "kcptun", "servers"}, | ||
arcombine(cbi("kcptun/servers"), cbi("kcptun/servers-detail")), | ||
_("Server Manage"), 2).leaf = true | ||
|
||
entry({"admin", "services", "kcptun", "log"}, | ||
template("kcptun/log_view"), _("Log"), 3) | ||
|
||
entry({"admin", "services", "kcptun", "status"}, call("action_status")) | ||
|
||
entry({"admin", "services", "kcptun", "check"}, call("action_check")).leaf = true | ||
|
||
entry({"admin", "services", "kcptun", "update"}, call("action_update")).leaf = true | ||
|
||
entry({"admin", "services", "kcptun", "log", "data"}, call("action_log_data")) | ||
|
||
entry({"admin", "services", "kcptun", "log", "clear"}, call("action_log_clear")).leaf = true | ||
end | ||
|
||
local function http_write_json(content) | ||
http.prepare_content("application/json") | ||
http.write_json(content or { code = 1 }) | ||
end | ||
|
||
function action_status() | ||
local client_file = kcp.get_config_option("client_file") | ||
|
||
http_write_json({ | ||
client = kcp.is_running(client_file) | ||
}) | ||
end | ||
|
||
function action_check(type) | ||
local json = nil | ||
if type == "kcptun" then | ||
json = kcp.check_kcptun(http.formvalue("arch")) | ||
elseif type == "luci" then | ||
json = kcp.check_luci() | ||
else | ||
http.status(500, "Bad address") | ||
return | ||
end | ||
|
||
http_write_json(json) | ||
end | ||
|
||
function action_update(type) | ||
local json = nil | ||
if type == "kcptun" then | ||
local task = http.formvalue("task") | ||
if task == "extract" then | ||
json = kcp.extract_kcptun(http.formvalue("file"), http.formvalue("subfix")) | ||
elseif task == "move" then | ||
json = kcp.move_kcptun(http.formvalue("file")) | ||
else | ||
json = kcp.download_kcptun(http.formvalue("url")) | ||
end | ||
elseif type == "luci" then | ||
json = kcp.update_luci(http.formvalue("url"), http.formvalue("save")) | ||
else | ||
http.status(500, "Bad address") | ||
return | ||
end | ||
|
||
http_write_json(json) | ||
end | ||
|
||
function action_log_data() | ||
local util = require "luci.util" | ||
|
||
local log_data = { } | ||
|
||
local enable_logging = kcp.get_config_option("enable_logging", "0") == "1" | ||
|
||
if enable_logging then | ||
local client_log_file = kcp.get_current_log_file("client") | ||
log_data.client = util.trim( | ||
util.exec("tail -n 50 %s 2>/dev/null | sed 'x;1!H;$!d;x'" % client_log_file)) | ||
end | ||
|
||
log_data.syslog = util.trim( | ||
util.exec("logread | grep kcptun | tail -n 50 | sed 'x;1!H;$!d;x'")) | ||
|
||
http_write_json(log_data) | ||
end | ||
|
||
function action_log_clear(type) | ||
if type and type ~= "" then | ||
local log_file = kcp.get_current_log_file(type) | ||
|
||
local fs = require "nixio.fs" | ||
|
||
if fs.access(log_file) then | ||
fs.writefile(log_file, "") | ||
else | ||
http.status(404, "Not found") | ||
return | ||
end | ||
end | ||
|
||
http_write_json({ code = 0 }) | ||
end |
Oops, something went wrong.