直接通过官方ss代码库安装的ss, 只有一个可执行的sslocal, 也没找到对应的luci-app, 所以就自己写了一个. 因为/etc/init.d/sslocal 和 /etc/config/sslocal是现成的, 所以只需要写 controller 和 cbi model 就可以了.
1. 创建 /usr/lib/lua/luci/controller/admin/sslocal.lua
module("luci.controller.admin.sslocal", package.seeall) function index()
entry({"admin", "network", "sslocal"}, cbi("admin_network/sslocal"), _("Shadowsocks Local"), )
end
2. 创建 /usr/lib/lua/luci/model/cbi/admin_network/sslocal.lua
--[[
Shadowsocks LuCI Configuration Page Customized by RockBB
]]-- local m, s, o, e local fs = require "nixio.fs" local state_msg = ""
local sslocal_on = (luci.sys.call("pidof sslocal > /dev/null") == )
if sslocal_on then
state_msg = "<br><font color=\"green\">" .. translate("sslocal Running") .. "</font>"
else
state_msg = "<br>" .. translate("sslocal off")
end m = Map("sslocal", translate("Shadowsocks Local"), translate("Shadowsocks is an encrypted proxy designed to protect your Internet traffic.") .. " - " .. state_msg) --[[
config sslocal
option server_addr 'aa.bb.cc'
option server_port '8189'
option local_addr '0.0.0.0'
option local_port '1080'
option password 'some.phrase'
option method 'aes-256-cfb'
]] s = m:section(TypedSection, "sslocal", translate("Setting"))
s.addremove = false
s.anonymous = true -- ---------------------------------------------------
o = s:option(Value, "server_addr", translate("Server Address"))
o.datatype = "host"
o.rmempty = false o = s:option(Value, "server_port", translate("Server Port"))
o.datatype = "port"
o.rmempty = false o = s:option(Value, "local_addr", translate("Local Address"))
o.datatype = "ipaddr"
o.rmempty = false o = s:option(Value, "local_port", translate("Local Port"))
o.datatype = "range(1,65535)"
o.rmempty = false o = s:option(Value, "password", translate("Password"))
o.password = true o = s:option(ListValue, "method", translate("Encryption Method"))
o:value("table")
o:value("rc4")
o:value("rc4-md5")
o:value("aes-128-cfb")
o:value("aes-192-cfb")
o:value("aes-256-cfb")
o:value("bf-cfb")
o:value("cast5-cfb")
o:value("des-cfb")
o:value("camellia-128-cfb")
o:value("camellia-192-cfb")
o:value("camellia-256-cfb")
o:value("idea-cfb")
o:value("rc2-cfb")
o:value("seed-cfb")
o:value("salsa20")
o:value("chacha20") local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/sslocal restart")
end return m