mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-31 23:35:13 +08:00
update 2026-07-24 18:11:38
This commit is contained in:
1 parent
2cae7975b1
commit
75e8d52691
25 files changed
+131
-259
No files matched your search
@@ -103,8 +103,11 @@ return baseclass.extend({
|
|||||||
|
|
||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
for(let offset = 0; offset < bytes.length; offset += chunkSize) {
|
for(let offset = 0; offset < bytes.length; offset += chunkSize) {
|
||||||
const chunkBytes = bytes.slice(offset, Math.min(offset + chunkSize, bytes.length));
|
const chunkStart = offset;
|
||||||
const chunk = decoder.decode(chunkBytes);
|
const chunkEnd = Math.min(offset + chunkSize, bytes.length);
|
||||||
|
const isLastChunk = chunkEnd === bytes.length;
|
||||||
|
const chunkBytes = bytes.slice(chunkStart, chunkEnd);
|
||||||
|
const chunk = decoder.decode(chunkBytes, { stream: !isLastChunk });
|
||||||
const append = offset > 0;
|
const append = offset > 0;
|
||||||
promise = promise.then(() => callFileWrite(path, chunk, append, mode));
|
promise = promise.then(() => callFileWrite(path, chunk, append, mode));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,11 @@ return baseclass.extend({
|
|||||||
|
|
||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
for(let offset = 0; offset < bytes.length; offset += chunkSize) {
|
for(let offset = 0; offset < bytes.length; offset += chunkSize) {
|
||||||
const chunkBytes = bytes.slice(offset, Math.min(offset + chunkSize, bytes.length));
|
const chunkStart = offset;
|
||||||
const chunk = decoder.decode(chunkBytes);
|
const chunkEnd = Math.min(offset + chunkSize, bytes.length);
|
||||||
|
const isLastChunk = chunkEnd === bytes.length;
|
||||||
|
const chunkBytes = bytes.slice(chunkStart, chunkEnd);
|
||||||
|
const chunk = decoder.decode(chunkBytes, { stream: !isLastChunk });
|
||||||
const append = offset > 0;
|
const append = offset > 0;
|
||||||
promise = promise.then(() => callFileWrite(path, chunk, append, mode));
|
promise = promise.then(() => callFileWrite(path, chunk, append, mode));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# Copyright (C) 2020 Gyj1109
|
|
||||||
# 适配 OpenWrt 25.12 修改版
|
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
|
|
||||||
PKG_NAME:=luci-app-syncthing
|
|
||||||
PKG_VERSION:=1.0
|
|
||||||
PKG_RELEASE:=3
|
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI support for Syncthing
|
|
||||||
LUCI_PKGARCH:=all
|
|
||||||
# 适配 25.12:确保安装了 syncthing 后,LuCI 界面能正确拉起
|
|
||||||
LUCI_DEPENDS:=+syncthing
|
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
|
||||||
|
|
||||||
# 明确定义配置文件的归属,这对 25.12 的 apk 管理器非常重要
|
|
||||||
define Package/$(PKG_NAME)/conffiles
|
|
||||||
/etc/config/syncthing
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# luci-app-syncthing
|
|
||||||
在Potat0000源码基础上进行了汉化优化,官方openwrt23.05.3编译后可使用
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
module("luci.controller.syncthing", package.seeall)
|
|
||||||
|
|
||||||
function index()
|
|
||||||
if not nixio.fs.access("/etc/config/syncthing") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
entry({"admin", "services", "syncthing"}, cbi("syncthing"), _("文件同步"), 10).dependent = true
|
|
||||||
entry({"admin", "services", "syncthing", "status"}, call("act_status")).leaf = true
|
|
||||||
end
|
|
||||||
|
|
||||||
function act_status()
|
|
||||||
local e = {}
|
|
||||||
e.running = luci.sys.call("pgrep syncthing >/dev/null") == 0
|
|
||||||
luci.http.prepare_content("application/json")
|
|
||||||
luci.http.write_json(e)
|
|
||||||
end
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
require("nixio.fs")
|
|
||||||
|
|
||||||
m = Map("syncthing", translate("Syncthing同步工具"))
|
|
||||||
|
|
||||||
m:section(SimpleSection).template = "syncthing/syncthing_status"
|
|
||||||
|
|
||||||
s = m:section(TypedSection, "syncthing")
|
|
||||||
|
|
||||||
s.anonymous = true
|
|
||||||
|
|
||||||
o = s:option(Flag, "enabled", translate("启用"))
|
|
||||||
o.default = 0
|
|
||||||
o.rmempty = false
|
|
||||||
|
|
||||||
gui_address = s:option(Value, "gui_address", translate("GUI访问地址"))
|
|
||||||
gui_address.description = translate("使用0.0.0.0以监控所有访问。")
|
|
||||||
gui_address.default = "http://0.0.0.0:8384"
|
|
||||||
gui_address.placeholder = "http://0.0.0.0:8384"
|
|
||||||
gui_address.rmempty = false
|
|
||||||
|
|
||||||
home = s:option(Value, "home", translate("配置文件目录"))
|
|
||||||
home.description = translate("只有保存在/etc/syncthing中的配置会自动备份!")
|
|
||||||
home.default = "/etc/syncthing"
|
|
||||||
home.placeholder = "/etc/syncthing"
|
|
||||||
home.rmempty = false
|
|
||||||
|
|
||||||
user = s:option(ListValue, "user", translate("用户"))
|
|
||||||
user.description = translate("默认是syncthing,但这可能会导致权限被拒绝。Syncthing官方不建议以root身份运行。")
|
|
||||||
user:value("", translate("syncthing"))
|
|
||||||
for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do
|
|
||||||
user:value(u)
|
|
||||||
end
|
|
||||||
|
|
||||||
macprocs = s:option(Value, "macprocs", translate("线程限制"))
|
|
||||||
macprocs.description = translate("0表示匹配CPU数量(默认),>0表示显式指定并发数。")
|
|
||||||
macprocs.default = "0"
|
|
||||||
macprocs.placeholder = "0"
|
|
||||||
macprocs.datatype = "range(0,32)"
|
|
||||||
macprocs.rmempty = false
|
|
||||||
|
|
||||||
nice = s:option(Value, "nice", translate("优先级"))
|
|
||||||
nice.description = translate("显式指定优先级值。0是最高,19是最低。(暂时不允许设置负值)")
|
|
||||||
nice.default = "19"
|
|
||||||
nice.placeholder = "19"
|
|
||||||
nice.datatype = "range(0,19)"
|
|
||||||
nice.rmempty = false
|
|
||||||
|
|
||||||
return m
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<script type="text/javascript">//<![CDATA[
|
|
||||||
XHR.poll(1, '<%=url([[admin]], [[services]], [[syncthing]], [[status]])%>', null,
|
|
||||||
function (x, data) {
|
|
||||||
var tb = document.getElementById('syncthing_status');
|
|
||||||
if (data && tb) {
|
|
||||||
if (data.running) {
|
|
||||||
var links = '<em><b><font color="green">Syncthing <%:运行中%></font></b></em><input class="btn cbi-button mar-10" type="button" value="<%:打开Syncthing页面%>" onclick="openwebui();" />';
|
|
||||||
tb.innerHTML = links;
|
|
||||||
} else {
|
|
||||||
tb.innerHTML = '<em><b><font color="red">Syncthing <%:未运行%></font></b></em>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function openwebui(){
|
|
||||||
var url = window.location.host+":<%=luci.sys.exec("uci -q get syncthing.syncthing.gui_address"):match(":[0-9]+"):gsub(":", "")%>";
|
|
||||||
window.open('http://'+url,'target','');
|
|
||||||
}
|
|
||||||
//]]>
|
|
||||||
</script>
|
|
||||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
|
||||||
<fieldset class="cbi-section">
|
|
||||||
<p id="syncthing_status">
|
|
||||||
<em><%:正在收集数据...%></em>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
touch /etc/config/syncthing
|
|
||||||
|
|
||||||
uci -q batch <<-EOF >/dev/null
|
|
||||||
delete ucitrack.@syncthing[-1]
|
|
||||||
add ucitrack syncthing
|
|
||||||
set ucitrack.@syncthing[-1].exec='/etc/init.d/syncthing stop && /etc/init.d/syncthing start'
|
|
||||||
commit ucitrack
|
|
||||||
EOF
|
|
||||||
# remove LuCI cache
|
|
||||||
rm -f /tmp/luci*
|
|
||||||
exit 0
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"luci-app-syncthing": {
|
|
||||||
"description": "Grant UCI access for luci-app-syncthing",
|
|
||||||
"read": {
|
|
||||||
"uci": [ "syncthing" ]
|
|
||||||
},
|
|
||||||
"write": {
|
|
||||||
"uci": [ "syncthing" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
## 自定义后端与luci共享session
|
||||||
|
|
||||||
|
### 主要流程:
|
||||||
|
```
|
||||||
|
1. nginx转发/cgi-bin/luci/istorenext/开头的请求到自定义后端
|
||||||
|
|
||||||
|
2. 如果自定义后端返回403,则下一步。否则直接透传,回到步骤1。
|
||||||
|
|
||||||
|
3. nginx渲染登录界面,登录URL参数会加上istorenextlogin=1。用户登录时会用POST请求
|
||||||
|
|
||||||
|
4. 当nginx收到POST的请求且istorenextlogin=1就转发给luci
|
||||||
|
|
||||||
|
5. luci登录失败的话,会返回403,回到步骤3;luci登录成功的话会原地重定向,URL中还是有istorenextlogin=1,但是变成GET请求,到下一步
|
||||||
|
|
||||||
|
6. nginx收到GET请求且istorenextlogin=1就再次重定向到没有istorenextlogin=1的URL,回到步骤1,由于已经登录且cookie共享,自定义后端就不会再返回403,除非session过期了
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
`./root-demo` 文件夹下包含一个自定义后端的 demo。demo判断登录则渲染200页面,没登录就403。
|
||||||
+9
-5
@@ -22,15 +22,19 @@ define KernelPackage/oaf/description
|
|||||||
open appfilter kernel module
|
open appfilter kernel module
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
KCFLAGS := -Wno-error=missing-prototypes \
|
||||||
EXTRA_CFLAGS:=-Wno-declaration-after-statement -Wno-strict-prototypes -Wno-unused-variable -Wno-implicit-fallthrough -Wno-missing-braces -Wno-parentheses -Wno-format -Wno-missing-prototypes -Wno-missing-declarations
|
-Wno-error=missing-declarations \
|
||||||
|
-Wno-error=unused-variable \
|
||||||
|
-Wno-error=declaration-after-statement \
|
||||||
|
-Wno-error=implicit-fallthrough \
|
||||||
|
-Wno-error=missing-braces \
|
||||||
|
-Wno-error=parentheses \
|
||||||
|
-Wno-error=format
|
||||||
|
|
||||||
MAKE_OPTS:= \
|
MAKE_OPTS:= \
|
||||||
$(KERNEL_MAKE_FLAGS) \
|
$(KERNEL_MAKE_FLAGS) \
|
||||||
M="$(PKG_BUILD_DIR)" \
|
M="$(PKG_BUILD_DIR)" \
|
||||||
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
|
KCFLAGS="$(KCFLAGS)" \
|
||||||
$(EXTRA_KCONFIG)
|
$(EXTRA_KCONFIG)
|
||||||
|
|
||||||
define Build/Compile
|
define Build/Compile
|
||||||
|
|||||||
+6
-9
@@ -34,9 +34,6 @@ DEFINE_RWLOCK(af_client_lock);
|
|||||||
u32 total_client = 0;
|
u32 total_client = 0;
|
||||||
struct list_head af_client_list_table[MAX_AF_CLIENT_HASH_SIZE];
|
struct list_head af_client_list_table[MAX_AF_CLIENT_HASH_SIZE];
|
||||||
|
|
||||||
int af_send_msg_to_user(char *pbuf, uint16_t len);
|
|
||||||
extern char *ipv6_to_str(const struct in6_addr *addr, char *str);
|
|
||||||
|
|
||||||
static void init_client_timer(af_client_info_t *client);
|
static void init_client_timer(af_client_info_t *client);
|
||||||
static void stop_client_timer(af_client_info_t *client);
|
static void stop_client_timer(af_client_info_t *client);
|
||||||
|
|
||||||
@@ -94,7 +91,7 @@ void af_client_list_reset_report_num(void)
|
|||||||
AF_CLIENT_UNLOCK_W();
|
AF_CLIENT_UNLOCK_W();
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_mac_hash_code(unsigned char *mac)
|
static int get_mac_hash_code(unsigned char *mac)
|
||||||
{
|
{
|
||||||
if (!mac)
|
if (!mac)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -222,7 +219,7 @@ void check_client_expire(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_EXPIRED_VISIT_INFO_COUNT 10
|
#define MAX_EXPIRED_VISIT_INFO_COUNT 10
|
||||||
void flush_expired_visit_info(af_client_info_t *node)
|
static void flush_expired_visit_info(af_client_info_t *node)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -259,7 +256,7 @@ void flush_expired_visit_info(af_client_info_t *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int __af_visit_info_report(af_client_info_t *node)
|
static int __af_visit_info_report(af_client_info_t *node)
|
||||||
{
|
{
|
||||||
unsigned char mac_str[32] = {0};
|
unsigned char mac_str[32] = {0};
|
||||||
unsigned char ip_str[32] = {0};
|
unsigned char ip_str[32] = {0};
|
||||||
@@ -270,6 +267,8 @@ int __af_visit_info_report(af_client_info_t *node)
|
|||||||
cJSON *visit_info_array = NULL;
|
cJSON *visit_info_array = NULL;
|
||||||
cJSON *root_obj = NULL;
|
cJSON *root_obj = NULL;
|
||||||
|
|
||||||
|
flush_expired_visit_info(node);
|
||||||
|
|
||||||
root_obj = cJSON_CreateObject();
|
root_obj = cJSON_CreateObject();
|
||||||
if (!root_obj)
|
if (!root_obj)
|
||||||
{
|
{
|
||||||
@@ -331,7 +330,7 @@ static inline int get_packet_dir(struct net_device *in)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void af_update_client_status(af_client_info_t *node)
|
static void af_update_client_status(af_client_info_t *node)
|
||||||
{
|
{
|
||||||
if (node->last_flow.down_bytes > 0){
|
if (node->last_flow.down_bytes > 0){
|
||||||
node->period_flow.down_bytes += (node->flow.down_bytes - node->last_flow.down_bytes);
|
node->period_flow.down_bytes += (node->flow.down_bytes - node->last_flow.down_bytes);
|
||||||
@@ -471,8 +470,6 @@ static u_int32_t af_client_hook2(unsigned int hook,
|
|||||||
int (*okfn)(struct sk_buff *))
|
int (*okfn)(struct sk_buff *))
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
struct ethhdr *ethhdr = NULL;
|
|
||||||
unsigned char smac[ETH_ALEN];
|
|
||||||
af_client_info_t *nfc = NULL;
|
af_client_info_t *nfc = NULL;
|
||||||
int pkt_dir = 0;
|
int pkt_dir = 0;
|
||||||
struct iphdr *iph = NULL;
|
struct iphdr *iph = NULL;
|
||||||
|
|||||||
+10
-13
@@ -20,12 +20,11 @@
|
|||||||
#include <linux/sysctl.h>
|
#include <linux/sysctl.h>
|
||||||
#include "af_utils.h"
|
#include "af_utils.h"
|
||||||
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "af_log.h"
|
#include "af_log.h"
|
||||||
#include "af_client.h"
|
#include "af_client.h"
|
||||||
extern char *ipv6_to_str(const struct in6_addr *addr, char *str);
|
#include "af_client_fs.h"
|
||||||
|
extern struct list_head af_client_list_table[MAX_AF_CLIENT_HASH_SIZE];
|
||||||
extern struct list_head af_client_list_table[MAX_AF_CLIENT_HASH_SIZE];
|
|
||||||
struct af_client_iter_state
|
struct af_client_iter_state
|
||||||
{
|
{
|
||||||
unsigned int bucket;
|
unsigned int bucket;
|
||||||
@@ -183,13 +182,11 @@ static const struct proc_ops af_client_fops = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int af_visiting_seq_show(struct seq_file *s, void *v)
|
static int af_visiting_seq_show(struct seq_file *s, void *v)
|
||||||
{
|
{
|
||||||
unsigned char mac_str[32] = {0};
|
unsigned char mac_str[32] = {0};
|
||||||
unsigned char ip_str[32] = {0};
|
static int index = 0;
|
||||||
static int index = 0;
|
af_client_info_t *node = (af_client_info_t *)v;
|
||||||
int i;
|
|
||||||
af_client_info_t *node = (af_client_info_t *)v;
|
|
||||||
if (v == SEQ_START_TOKEN)
|
if (v == SEQ_START_TOKEN)
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@ clean
|
|||||||
"op":3,
|
"op":3,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
int af_config_handle(char *config, unsigned int len)
|
static int af_config_handle(char *config, unsigned int len)
|
||||||
{
|
{
|
||||||
cJSON *config_obj = NULL;
|
cJSON *config_obj = NULL;
|
||||||
cJSON *cmd_obj = NULL;
|
cJSON *cmd_obj = NULL;
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ static const struct proc_ops af_conn_fops = {
|
|||||||
|
|
||||||
#define AF_CONN_PROC_STR "af_conn"
|
#define AF_CONN_PROC_STR "af_conn"
|
||||||
|
|
||||||
int af_conn_init_procfs(void)
|
static int af_conn_init_procfs(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *pde;
|
struct proc_dir_entry *pde;
|
||||||
struct net *net = &init_net;
|
struct net *net = &init_net;
|
||||||
@@ -278,7 +278,7 @@ int af_conn_init_procfs(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void af_conn_remove_procfs(void)
|
static void af_conn_remove_procfs(void)
|
||||||
{
|
{
|
||||||
struct net *net = &init_net;
|
struct net *net = &init_net;
|
||||||
remove_proc_entry(AF_CONN_PROC_STR, net->proc_net);
|
remove_proc_entry(AF_CONN_PROC_STR, net->proc_net);
|
||||||
|
|||||||
+2
-2
@@ -138,16 +138,16 @@ static struct ctl_table oaf_table[] = {
|
|||||||
};
|
};
|
||||||
#define OAF_SYS_PROC_DIR "oaf"
|
#define OAF_SYS_PROC_DIR "oaf"
|
||||||
|
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
|
||||||
static struct ctl_table oaf_root_table[] = {
|
static struct ctl_table oaf_root_table[] = {
|
||||||
{
|
{
|
||||||
.procname = OAF_SYS_PROC_DIR,
|
.procname = OAF_SYS_PROC_DIR,
|
||||||
.mode = 0555,
|
.mode = 0555,
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
|
|
||||||
.child = oaf_table,
|
.child = oaf_table,
|
||||||
#endif
|
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
static struct ctl_table_header *oaf_table_header;
|
static struct ctl_table_header *oaf_table_header;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "app_filter.h"
|
#include "app_filter.h"
|
||||||
#include "af_utils.h"
|
#include "af_utils.h"
|
||||||
#include "af_log.h"
|
#include "af_log.h"
|
||||||
|
#include "af_config.h"
|
||||||
|
#include "af_rule_config.h"
|
||||||
|
|
||||||
#define AF_MAX_APP_TYPE_NUM 32
|
#define AF_MAX_APP_TYPE_NUM 32
|
||||||
#define AF_MAX_APP_NUM 512
|
#define AF_MAX_APP_NUM 512
|
||||||
@@ -21,26 +23,8 @@ extern u_int32_t g_update_jiffies;
|
|||||||
|
|
||||||
char g_app_id_array[AF_MAX_APP_TYPE_NUM][AF_MAX_APP_NUM] = {0};
|
char g_app_id_array[AF_MAX_APP_TYPE_NUM][AF_MAX_APP_NUM] = {0};
|
||||||
|
|
||||||
void af_show_app_status(void)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
for (i = 0; i < AF_MAX_APP_TYPE_NUM; i++)
|
|
||||||
{
|
|
||||||
for (j = 0; j < AF_MAX_APP_NUM; j++)
|
|
||||||
{
|
|
||||||
af_rule_read_lock();
|
|
||||||
if (g_app_id_array[i][j] == AF_TRUE)
|
|
||||||
{
|
|
||||||
AF_DEBUG("%d, %d\n", i, j);
|
|
||||||
}
|
|
||||||
af_rule_read_unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AF_DEBUG("\n\n\n");
|
static int af_change_app_status(cJSON *data_obj, int status)
|
||||||
}
|
|
||||||
|
|
||||||
int af_change_app_status(cJSON *data_obj, int status)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int id;
|
int id;
|
||||||
@@ -113,4 +97,4 @@ int af_config_clean_appid(cJSON *data)
|
|||||||
{
|
{
|
||||||
af_init_app_status();
|
af_init_app_status();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "af_utils.h"
|
#include "af_utils.h"
|
||||||
#include "af_log.h"
|
#include "af_log.h"
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
#include "af_config.h"
|
||||||
#include "af_whitelist_config.h"
|
#include "af_whitelist_config.h"
|
||||||
#include "af_user_config.h"
|
#include "af_user_config.h"
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ af_mac_node_t *af_mac_add(unsigned char *mac)
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_user_match_enable(void)
|
static __maybe_unused int is_user_match_enable(void)
|
||||||
{
|
{
|
||||||
return total_mac > 0;
|
return total_mac > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-8
@@ -83,7 +83,7 @@ void dump_str(char *name, unsigned char *p, int len)
|
|||||||
strncpy(buf, p, len);
|
strncpy(buf, p, len);
|
||||||
printk("[%s]\n", buf);
|
printk("[%s]\n", buf);
|
||||||
}
|
}
|
||||||
int isprint_char(unsigned char c)
|
static int isprint_char(unsigned char c)
|
||||||
{
|
{
|
||||||
if (c >= 0x20 && c <= 0x7e)
|
if (c >= 0x20 && c <= 0x7e)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -279,12 +279,14 @@ static int k_vsscanf(const char *buf, const char *fmt, va_list args)
|
|||||||
case 'X':
|
case 'X':
|
||||||
base = 16;
|
base = 16;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
base = 0;
|
base = 0;
|
||||||
case 'd':
|
fallthrough;
|
||||||
is_sign = 1;
|
case 'd':
|
||||||
case 'u':
|
is_sign = 1;
|
||||||
break;
|
fallthrough;
|
||||||
|
case 'u':
|
||||||
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
if (*str++ != '%')
|
if (*str++ != '%')
|
||||||
return num;
|
return num;
|
||||||
@@ -399,4 +401,4 @@ int mac_to_hex(u8 *mac, u8 *mac_hex)
|
|||||||
mac_hex[i] = mac_tmp[i];
|
mac_hex[i] = mac_tmp[i];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+40
-46
@@ -80,8 +80,8 @@ int hash_mac(unsigned char *mac)
|
|||||||
return ((mac[0] ^ mac[1]) + (mac[2] ^ mac[3]) + (mac[4] ^ mac[5])) % MAX_AF_MAC_HASH_SIZE;
|
return ((mac[0] ^ mac[1]) + (mac[2] ^ mac[3]) + (mac[4] ^ mac[5])) % MAX_AF_MAC_HASH_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __add_app_feature(char *feature, int appid, char *name, int proto, int src_port,
|
static int __add_app_feature(char *feature, int appid, char *name, int proto, int src_port,
|
||||||
port_info_t dport_info, char *host_url, char *request_url, char *dict, char *search_str, int ignore)
|
port_info_t dport_info, char *host_url, char *request_url, char *dict, char *search_str, int ignore)
|
||||||
{
|
{
|
||||||
af_feature_node_t *node = NULL;
|
af_feature_node_t *node = NULL;
|
||||||
char *p = dict;
|
char *p = dict;
|
||||||
@@ -149,7 +149,7 @@ int __add_app_feature(char *feature, int appid, char *name, int proto, int src_p
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int validate_range_value(char *range_str)
|
static int validate_range_value(char *range_str)
|
||||||
{
|
{
|
||||||
if (!range_str)
|
if (!range_str)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -170,7 +170,7 @@ int validate_range_value(char *range_str)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_range_value(char *range_str, range_value_t *range)
|
static int parse_range_value(char *range_str, range_value_t *range)
|
||||||
{
|
{
|
||||||
char pure_range[128] = {0};
|
char pure_range[128] = {0};
|
||||||
if (!validate_range_value(range_str))
|
if (!validate_range_value(range_str))
|
||||||
@@ -207,7 +207,7 @@ int parse_range_value(char *range_str, range_value_t *range)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_port_info(char *port_str, port_info_t *info)
|
static int parse_port_info(char *port_str, port_info_t *info)
|
||||||
{
|
{
|
||||||
char *p = port_str;
|
char *p = port_str;
|
||||||
char *begin = port_str;
|
char *begin = port_str;
|
||||||
@@ -239,7 +239,7 @@ int parse_port_info(char *port_str, port_info_t *info)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_match_port(port_info_t *info, int port)
|
static int af_match_port(port_info_t *info, int port)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int with_not = 0;
|
int with_not = 0;
|
||||||
@@ -276,7 +276,7 @@ int af_match_port(port_info_t *info, int port)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//[tcp;;443;baidu.com;;]
|
//[tcp;;443;baidu.com;;]
|
||||||
int add_app_feature(int appid, char *name, char *feature)
|
static int add_app_feature(int appid, char *name, char *feature)
|
||||||
{
|
{
|
||||||
char proto_str[16] = {0};
|
char proto_str[16] = {0};
|
||||||
char src_port_str[16] = {0};
|
char src_port_str[16] = {0};
|
||||||
@@ -287,7 +287,6 @@ int add_app_feature(int appid, char *name, char *feature)
|
|||||||
char dict[128] = {0};
|
char dict[128] = {0};
|
||||||
int proto = IPPROTO_TCP;
|
int proto = IPPROTO_TCP;
|
||||||
int param_num = 0;
|
int param_num = 0;
|
||||||
int dst_port = 0;
|
|
||||||
int src_port = 0;
|
int src_port = 0;
|
||||||
char tmp_buf[128] = {0};
|
char tmp_buf[128] = {0};
|
||||||
int ignore = 0;
|
int ignore = 0;
|
||||||
@@ -373,7 +372,7 @@ int add_app_feature(int appid, char *name, char *feature)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void af_init_feature(char *feature_str)
|
static void af_init_feature(char *feature_str)
|
||||||
{
|
{
|
||||||
int app_id;
|
int app_id;
|
||||||
char app_name[128] = {0};
|
char app_name[128] = {0};
|
||||||
@@ -420,7 +419,7 @@ void af_init_feature(char *feature_str)
|
|||||||
if (*p == ',')
|
if (*p == ',')
|
||||||
{
|
{
|
||||||
if (p - begin > MAX_FEATURE_STR_LEN){
|
if (p - begin > MAX_FEATURE_STR_LEN){
|
||||||
printk("error, feature len error %d\n", p - len);
|
printk("error, feature len error %d\n", (int)(p - begin));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memcpy((char *)feature, begin, p - begin);
|
memcpy((char *)feature, begin, p - begin);
|
||||||
@@ -433,7 +432,7 @@ void af_init_feature(char *feature_str)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (p - begin > MAX_FEATURE_STR_LEN){
|
if (p - begin > MAX_FEATURE_STR_LEN){
|
||||||
printk("error, feature len error %d\n", p - len);
|
printk("error, feature len error %d\n", (int)(p - begin));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
memcpy((char *)feature, begin, p - begin);
|
memcpy((char *)feature, begin, p - begin);
|
||||||
@@ -447,7 +446,7 @@ void af_init_feature(char *feature_str)
|
|||||||
kfree(feature_buf);
|
kfree(feature_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_feature_buf_from_file(char **config_buf)
|
static void load_feature_buf_from_file(char **config_buf)
|
||||||
{
|
{
|
||||||
struct inode *inode = NULL;
|
struct inode *inode = NULL;
|
||||||
struct file *fp = NULL;
|
struct file *fp = NULL;
|
||||||
@@ -494,7 +493,7 @@ void load_feature_buf_from_file(char **config_buf)
|
|||||||
filp_close(fp, NULL);
|
filp_close(fp, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_feature_config(void)
|
static __maybe_unused int load_feature_config(void)
|
||||||
{
|
{
|
||||||
char *feature_buf = NULL;
|
char *feature_buf = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
@@ -553,7 +552,7 @@ static void af_clean_feature_list(void)
|
|||||||
feature_list_write_unlock();
|
feature_list_write_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void af_add_feature_msg_handle(char *data, int len)
|
static void af_add_feature_msg_handle(char *data, int len)
|
||||||
{
|
{
|
||||||
char feature[MAX_FEATURE_LINE_LEN] = {0};
|
char feature[MAX_FEATURE_LINE_LEN] = {0};
|
||||||
if (len <= 0 || len >= MAX_FEATURE_LINE_LEN){
|
if (len <= 0 || len >= MAX_FEATURE_LINE_LEN){
|
||||||
@@ -603,13 +602,12 @@ static unsigned char *read_skb(struct sk_buff *skb, unsigned int from, unsigned
|
|||||||
return msg_buf;
|
return msg_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_flow_proto(struct sk_buff *skb, flow_info_t *flow)
|
static int parse_flow_proto(struct sk_buff *skb, flow_info_t *flow)
|
||||||
{
|
{
|
||||||
unsigned char *ipp;
|
unsigned char *ipp;
|
||||||
int ipp_len;
|
int ipp_len;
|
||||||
struct tcphdr *tcph = NULL;
|
struct tcphdr *tcph = NULL;
|
||||||
struct udphdr *udph = NULL;
|
struct udphdr *udph = NULL;
|
||||||
struct nf_conn *ct = NULL;
|
|
||||||
struct iphdr *iph = NULL;
|
struct iphdr *iph = NULL;
|
||||||
struct ipv6hdr *ip6h = NULL;
|
struct ipv6hdr *ip6h = NULL;
|
||||||
if (!skb)
|
if (!skb)
|
||||||
@@ -660,7 +658,7 @@ int parse_flow_proto(struct sk_buff *skb, flow_info_t *flow)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_domain(char *h, int len)
|
static int check_domain(char *h, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
@@ -676,7 +674,7 @@ int check_domain(char *h, int len)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dpi_https_proto(flow_info_t *flow)
|
static int dpi_https_proto(flow_info_t *flow)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
short url_len = 0;
|
short url_len = 0;
|
||||||
@@ -732,7 +730,7 @@ int dpi_https_proto(flow_info_t *flow)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dpi_http_proto(flow_info_t *flow)
|
static void dpi_http_proto(flow_info_t *flow)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
@@ -868,7 +866,7 @@ static void dump_flow_info(flow_info_t *flow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *k_memstr(char *data, char *str, int size)
|
static char *k_memstr(char *data, char *str, int size)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char len = strlen(str);
|
char len = strlen(str);
|
||||||
@@ -880,7 +878,7 @@ char *k_memstr(char *data, char *str, int size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_match_by_pos(flow_info_t *flow, af_feature_node_t *node)
|
static int af_match_by_pos(flow_info_t *flow, af_feature_node_t *node)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
@@ -927,7 +925,7 @@ int af_match_by_pos(flow_info_t *flow, af_feature_node_t *node)
|
|||||||
return AF_FALSE;
|
return AF_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_match_by_url(flow_info_t *flow, af_feature_node_t *node)
|
static int af_match_by_url(flow_info_t *flow, af_feature_node_t *node)
|
||||||
{
|
{
|
||||||
char reg_url_buf[MAX_URL_MATCH_LEN] = {0};
|
char reg_url_buf[MAX_URL_MATCH_LEN] = {0};
|
||||||
|
|
||||||
@@ -973,7 +971,7 @@ int af_match_by_url(flow_info_t *flow, af_feature_node_t *node)
|
|||||||
return AF_FALSE;
|
return AF_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_match_one(flow_info_t *flow, af_feature_node_t *node)
|
static int af_match_one(flow_info_t *flow, af_feature_node_t *node)
|
||||||
{
|
{
|
||||||
int ret = AF_FALSE;
|
int ret = AF_FALSE;
|
||||||
if (!flow || !node)
|
if (!flow || !node)
|
||||||
@@ -1017,7 +1015,7 @@ int af_match_one(flow_info_t *flow, af_feature_node_t *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int af_match_quic(flow_info_t *flow)
|
static int af_match_quic(flow_info_t *flow)
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
unsigned char first_byte;
|
unsigned char first_byte;
|
||||||
@@ -1055,7 +1053,7 @@ int af_match_quic(flow_info_t *flow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int match_feature(flow_info_t *flow)
|
static int match_feature(flow_info_t *flow)
|
||||||
{
|
{
|
||||||
af_feature_node_t *n, *node;
|
af_feature_node_t *n, *node;
|
||||||
|
|
||||||
@@ -1080,7 +1078,7 @@ int match_feature(flow_info_t *flow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int match_app_filter_user(af_client_info_t *client){
|
static int match_app_filter_user(af_client_info_t *client){
|
||||||
if (!g_user_mode){ // auto mode
|
if (!g_user_mode){ // auto mode
|
||||||
if (af_whitelist_mac_find(client->mac)){
|
if (af_whitelist_mac_find(client->mac)){
|
||||||
AF_LMT_DEBUG("match whitelist mac = " MAC_FMT "\n", MAC_ARRAY(client->mac));
|
AF_LMT_DEBUG("match whitelist mac = " MAC_FMT "\n", MAC_ARRAY(client->mac));
|
||||||
@@ -1095,7 +1093,7 @@ int match_app_filter_user(af_client_info_t *client){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int match_app_filter_rule(int appid, af_client_info_t *client)
|
static int match_app_filter_rule(int appid, af_client_info_t *client)
|
||||||
{
|
{
|
||||||
if (!match_app_filter_user(client))
|
if (!match_app_filter_user(client))
|
||||||
return AF_FALSE;
|
return AF_FALSE;
|
||||||
@@ -1136,7 +1134,7 @@ static int af_get_visit_index(af_client_info_t *node, int app_id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_update_client_app_info(af_client_info_t *node, int app_id, int drop)
|
static int af_update_client_app_info(af_client_info_t *node, int app_id, int drop)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
if (!node)
|
if (!node)
|
||||||
@@ -1159,7 +1157,7 @@ int af_update_client_app_info(af_client_info_t *node, int app_id, int drop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int af_send_msg_to_user(char *pbuf, uint16_t len);
|
int af_send_msg_to_user(char *pbuf, uint16_t len);
|
||||||
int af_match_bcast_packet(flow_info_t *f)
|
static __maybe_unused int af_match_bcast_packet(flow_info_t *f)
|
||||||
{
|
{
|
||||||
if (!f)
|
if (!f)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1168,7 +1166,7 @@ int af_match_bcast_packet(flow_info_t *f)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int af_match_local_packet(flow_info_t *f)
|
static int af_match_local_packet(flow_info_t *f)
|
||||||
{
|
{
|
||||||
if (!f)
|
if (!f)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1179,7 +1177,7 @@ int af_match_local_packet(flow_info_t *f)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int update_url_visiting_info(af_client_info_t *client, flow_info_t *flow)
|
static int update_url_visiting_info(af_client_info_t *client, flow_info_t *flow)
|
||||||
{
|
{
|
||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
@@ -1204,7 +1202,7 @@ int update_url_visiting_info(af_client_info_t *client, flow_info_t *flow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int dpi_main(struct sk_buff *skb, flow_info_t *flow)
|
static int dpi_main(struct sk_buff *skb, flow_info_t *flow)
|
||||||
{
|
{
|
||||||
dpi_http_proto(flow);
|
dpi_http_proto(flow);
|
||||||
dpi_https_proto(flow);
|
dpi_https_proto(flow);
|
||||||
@@ -1213,7 +1211,7 @@ int dpi_main(struct sk_buff *skb, flow_info_t *flow)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void af_get_smac(struct sk_buff *skb, u_int8_t *smac)
|
static void af_get_smac(struct sk_buff *skb, u_int8_t *smac)
|
||||||
{
|
{
|
||||||
struct ethhdr *ethhdr = NULL;
|
struct ethhdr *ethhdr = NULL;
|
||||||
ethhdr = eth_hdr(skb);
|
ethhdr = eth_hdr(skb);
|
||||||
@@ -1222,16 +1220,16 @@ void af_get_smac(struct sk_buff *skb, u_int8_t *smac)
|
|||||||
else
|
else
|
||||||
memcpy(smac, &skb->cb[40], ETH_ALEN);
|
memcpy(smac, &skb->cb[40], ETH_ALEN);
|
||||||
}
|
}
|
||||||
int is_ipv4_broadcast(uint32_t ip)
|
static int is_ipv4_broadcast(uint32_t ip)
|
||||||
{
|
{
|
||||||
return (ip & 0x00FFFFFF) == 0x00FFFFFF;
|
return (ip & 0x00FFFFFF) == 0x00FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_ipv4_multicast(uint32_t ip)
|
static int is_ipv4_multicast(uint32_t ip)
|
||||||
{
|
{
|
||||||
return (ip & 0xF0000000) == 0xE0000000;
|
return (ip & 0xF0000000) == 0xE0000000;
|
||||||
}
|
}
|
||||||
int af_check_bcast_ip(flow_info_t *f)
|
static int af_check_bcast_ip(flow_info_t *f)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (0 == f->src || 0 == f->dst)
|
if (0 == f->src || 0 == f->dst)
|
||||||
@@ -1252,9 +1250,8 @@ int af_check_bcast_ip(flow_info_t *f)
|
|||||||
action: 0: accept, 1: drop
|
action: 0: accept, 1: drop
|
||||||
return: 0: no change, 1: change
|
return: 0: no change, 1: change
|
||||||
*/
|
*/
|
||||||
u_int32_t check_app_action_changed(int action, u_int32_t app_id, af_client_info_t *client)
|
static u_int32_t check_app_action_changed(int action, u_int32_t app_id, af_client_info_t *client)
|
||||||
{
|
{
|
||||||
u_int8_t drop = 0;
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
u_int32_t max_jiffies = 30 * HZ;
|
u_int32_t max_jiffies = 30 * HZ;
|
||||||
u_int32_t interval_jiffies = jiffies - g_update_jiffies;
|
u_int32_t interval_jiffies = jiffies - g_update_jiffies;
|
||||||
@@ -1273,7 +1270,7 @@ u_int32_t check_app_action_changed(int action, u_int32_t app_id, af_client_info_
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t app_filter_hook_bypass_handle(struct sk_buff *skb, struct net_device *dev)
|
static u_int32_t app_filter_hook_bypass_handle(struct sk_buff *skb, struct net_device *dev)
|
||||||
{
|
{
|
||||||
flow_info_t flow;
|
flow_info_t flow;
|
||||||
af_conn_t *conn;
|
af_conn_t *conn;
|
||||||
@@ -1446,18 +1443,16 @@ EXIT:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int32_t app_filter_hook_gateway_handle(struct sk_buff *skb, struct net_device *dev)
|
static u_int32_t app_filter_hook_gateway_handle(struct sk_buff *skb, struct net_device *dev)
|
||||||
{
|
{
|
||||||
unsigned long long total_packets = 0;
|
unsigned long long total_packets = 0;
|
||||||
flow_info_t flow;
|
flow_info_t flow;
|
||||||
u_int8_t smac[ETH_ALEN];
|
|
||||||
enum ip_conntrack_info ctinfo;
|
enum ip_conntrack_info ctinfo;
|
||||||
struct nf_conn *ct = NULL;
|
struct nf_conn *ct = NULL;
|
||||||
struct nf_conn_acct *acct;
|
struct nf_conn_acct *acct;
|
||||||
af_client_info_t *client = NULL;
|
af_client_info_t *client = NULL;
|
||||||
u_int32_t ret = NF_ACCEPT;
|
u_int32_t ret = NF_ACCEPT;
|
||||||
u_int32_t app_id = 0;
|
u_int32_t app_id = 0;
|
||||||
u_int8_t drop = 0;
|
|
||||||
u_int8_t malloc_data = 0;
|
u_int8_t malloc_data = 0;
|
||||||
|
|
||||||
if (!strstr(dev->name, g_lan_ifname))
|
if (!strstr(dev->name, g_lan_ifname))
|
||||||
@@ -1776,7 +1771,7 @@ static void oaf_timer_func(unsigned long ptr)
|
|||||||
mod_timer(&oaf_timer, jiffies + OAF_TIMER_INTERVAL * HZ);
|
mod_timer(&oaf_timer, jiffies + OAF_TIMER_INTERVAL * HZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_oaf_timer(void)
|
static void init_oaf_timer(void)
|
||||||
{
|
{
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
||||||
timer_setup(&oaf_timer, oaf_timer_func, 0);
|
timer_setup(&oaf_timer, oaf_timer_func, 0);
|
||||||
@@ -1787,7 +1782,7 @@ void init_oaf_timer(void)
|
|||||||
AF_INFO("init oaf timer...ok");
|
AF_INFO("init oaf timer...ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fini_oaf_timer(void)
|
static void fini_oaf_timer(void)
|
||||||
{
|
{
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 16, 0)
|
||||||
del_timer_sync(&oaf_timer);
|
del_timer_sync(&oaf_timer);
|
||||||
@@ -1891,7 +1886,7 @@ static void oaf_msg_rcv(struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int netlink_oaf_init(void)
|
static int netlink_oaf_init(void)
|
||||||
{
|
{
|
||||||
struct netlink_kernel_cfg nl_cfg = {0};
|
struct netlink_kernel_cfg nl_cfg = {0};
|
||||||
nl_cfg.input = oaf_msg_rcv;
|
nl_cfg.input = oaf_msg_rcv;
|
||||||
@@ -1958,4 +1953,3 @@ static void app_filter_fini(void)
|
|||||||
|
|
||||||
module_init(app_filter_init);
|
module_init(app_filter_init);
|
||||||
module_exit(app_filter_fini);
|
module_exit(app_filter_fini);
|
||||||
|
|
||||||
@@ -172,5 +172,7 @@ typedef struct flow_info{
|
|||||||
|
|
||||||
int regexp_match(char *reg, char *text);
|
int regexp_match(char *reg, char *text);
|
||||||
int hash_mac(unsigned char *mac);
|
int hash_mac(unsigned char *mac);
|
||||||
|
char *ipv6_to_str(const struct in6_addr *addr, char *str);
|
||||||
|
int af_send_msg_to_user(char *pbuf, uint16_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -171,7 +171,9 @@ static const char *parse_string(cJSON *item,const char *str)
|
|||||||
|
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||||
|
fallthrough;
|
||||||
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||||
|
fallthrough;
|
||||||
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
||||||
}
|
}
|
||||||
ptr2+=len;ptr+=4;
|
ptr2+=len;ptr+=4;
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ extern cJSON *cJSON_CreateObject(void);
|
|||||||
extern void cJSON_Minify(char *json);
|
extern void cJSON_Minify(char *json);
|
||||||
// These utilities create an Array of count items.
|
// These utilities create an Array of count items.
|
||||||
extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
|
extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
|
||||||
|
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||||
|
|
||||||
// Append item to the specified array/object.
|
// Append item to the specified array/object.
|
||||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||||
|
|||||||
+8
-7
@@ -18,6 +18,8 @@ typedef struct RE{
|
|||||||
int match_longest = 0;
|
int match_longest = 0;
|
||||||
char *match_first = NULL;
|
char *match_first = NULL;
|
||||||
|
|
||||||
|
int regexp_match(char *reg, char *text);
|
||||||
|
|
||||||
|
|
||||||
static void * getmem(size_t size)
|
static void * getmem(size_t size)
|
||||||
{
|
{
|
||||||
@@ -221,10 +223,9 @@ static int matchques(RE *cur, RE *regexp, char *text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int (*matchfun[TYPENUM][2])(RE *, RE *, char *) = {
|
static int (*matchfun[TYPENUM][2])(RE *, RE *, char *) = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
[STAR] = { matchstar, matchstar_l },
|
||||||
matchstar, matchstar_l,
|
[PLUS] = { matchplus, matchplus_l },
|
||||||
matchplus, matchplus_l,
|
[QUES] = { matchques, matchques },
|
||||||
matchques, matchques,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int matchhere(RE *regexp, char *text)
|
static int matchhere(RE *regexp, char *text)
|
||||||
@@ -261,7 +262,7 @@ int regexp_match(char *reg, char *text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if(ret = matchhere(regexp, text))
|
if ((ret = matchhere(regexp, text)))
|
||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -273,7 +274,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEST_reg_func(char *reg, char * str, int ret)
|
static __maybe_unused void TEST_reg_func(char *reg, char * str, int ret)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ret != regexp_match(reg, str)) {
|
if (ret != regexp_match(reg, str)) {
|
||||||
@@ -293,7 +294,7 @@ void TEST_reg_func(char *reg, char * str, int ret)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEST_regexp(void)
|
static __maybe_unused void TEST_regexp(void)
|
||||||
{
|
{
|
||||||
TEST_reg_func(".*baidu.com$", "www.baidu.com", 1);
|
TEST_reg_func(".*baidu.com$", "www.baidu.com", 1);
|
||||||
TEST_reg_func("^sina.com", "www.sina.com.cn", 0);
|
TEST_reg_func("^sina.com", "www.sina.com.cn", 0);
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ define Download/geoip
|
|||||||
HASH:=b71d1999439dde2de2d2b6844a2befa50c50211ff739785c005ca7c230a17d6a
|
HASH:=b71d1999439dde2de2d2b6844a2befa50c50211ff739785c005ca7c230a17d6a
|
||||||
endef
|
endef
|
||||||
|
|
||||||
GEOSITE_VER:=20260721145917
|
GEOSITE_VER:=20260724024523
|
||||||
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
|
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
|
||||||
define Download/geosite
|
define Download/geosite
|
||||||
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
|
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
|
||||||
URL_FILE:=dlc.dat
|
URL_FILE:=dlc.dat
|
||||||
FILE:=$(GEOSITE_FILE)
|
FILE:=$(GEOSITE_FILE)
|
||||||
HASH:=0d14a73927ac45e727e382c8b53fcfafe05667a146b14bffa4a4c341b3ca6889
|
HASH:=3c2de6ed0b21dab8883a39a9a54d940ac2fd2e6e0c460dfb6ee6c0075ed81b7f
|
||||||
endef
|
endef
|
||||||
|
|
||||||
GEOSITE_IRAN_VER:=202607130116
|
GEOSITE_IRAN_VER:=202607130116
|
||||||
|
|||||||
Reference in new issue
Block a user