<commit_before>-- Copyright 2017 <NAME> <<EMAIL>>
-- Licensed to the public under the Apache License 2.0.

local _up = getfenv(3)
local ut = require("luci.util")
local ds = require("luci.dispatcher")
local nw = require("luci.model.network")
nw.init()
module("luci.model.shadowsocks-libev", function(m)
	setmetatable(m, {__index=function (self, k)
		local tb = _up
		return rawget(self, k) or _up[k]
	end})
end)

function values_actions(o)
	for _, a in ipairs(actions) do
		o:value(a)
	end
end

function values_redir(o, xmode)
	o.map.uci.foreach("shadowsocks-libev", "ss_redir", function(sdata)
		local sname = sdata[".name"]
		local mode = sdata["mode"]
		if mode and mode:find(xmode) then
			local desc = "%s - %s" % {sname, mode}
			o:value(sname, desc)
		end
	end)
end

function values_serverlist(o)
	o.map.uci.foreach("shadowsocks-libev", "server", function(sdata)
		local sname = sdata[".name"]
		local server = sdata["server"]
		local server_port = sdata["server_port"]
		if server and server_port then
			local desc = "%s - %s:%s" % {sname, sdata["server"], sdata["server_port"]}
			o:value(sname, desc)
		end
	end)
end

function values_ipaddr(o)
	local keys, vals = {}, {}
	for _, v in ipairs(nw:get_interfaces()) do
		for _, a in ipairs(v:ipaddrs()) do
			o:value(a:host():string(), '%s (%s)' %{ a:host(), v:shortname() })
		end
	end
end

function options_client(s, tab)
	local o<commit_msg>luci-app-shadowsocks-libev: assume ss-redir has default mode tcp_only<commit_after>-- Copyright 2017 <NAME> <<EMAIL>>
-- Licensed to the public under the Apache License 2.0.

local _up = getfenv(3)
local ut = require("luci.util")
local ds = require("luci.dispatcher")
local nw = require("luci.model.network")
nw.init()
module("luci.model.shadowsocks-libev", function(m)
	setmetatable(m, {__index=function (self, k)
		local tb = _up
		return rawget(self, k) or _up[k]
	end})
end)

function values_actions(o)
	for _, a in ipairs(actions) do
		o:value(a)
	end
end

function values_redir(o, xmode)
	o.map.uci.foreach("shadowsocks-libev", "ss_redir", function(sdata)
		local sname = sdata[".name"]
		local mode = sdata["mode"] or "tcp_only"
		if mode and mode:find(xmode) then
			local desc = "%s - %s" % {sname, mode}
			o:value(sname, desc)
		end
	end)
end

function values_serverlist(o)
	o.map.uci.foreach("shadowsocks-libev", "server", function(sdata)
		local sname = sdata[".name"]
		local server = sdata["server"]
		local server_port = sdata["server_port"]
		if server and server_port then
			local desc = "%s - %s:%s" % {sname, sdata["server"], sdata["server_port"]}
			o:value(sname, desc)
		end
	end)
end

function values_ipaddr(o)
	local keys, vals = {}, {}
	for _, v in ipairs(nw:get_interfaces()) do
		for _, a in ipairs(v:ipaddrs()) do
			o:value(a:host():string(), '%s (%s)' %{ a:host(), v:shortname() })
		end
	end
end

function options_client(s, tab)
	local o
{'fraction_non_alphanumeric': 0.1592334494773519, 'fraction_numerical': 0.004878048780487805, 'mean_word_length': 4.574757281553398, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6002125', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1104, 'n_words': 287}