dae: copied from immortalwrt
This commit is contained in:
commit
6c536e3c19
4 changed files with 197 additions and 0 deletions
127
net/dae/Makefile
Normal file
127
net/dae/Makefile
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=dae
|
||||||
|
PKG_VERSION:=0.5.1
|
||||||
|
PKG_RELEASE:=3
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip
|
||||||
|
PKG_SOURCE_URL:=https://github.com/daeuniverse/dae/releases/download/v$(PKG_VERSION)/dae-full-src.zip?
|
||||||
|
PKG_HASH:=aad00888f7f3e8fae916297fede68d067894b5534148d261122bde2e7bba0b98
|
||||||
|
|
||||||
|
PKG_LICENSE:=AGPL-3.0-only
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host bpf-headers
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_BUILD_FLAGS:=no-mips16
|
||||||
|
|
||||||
|
GO_PKG:=github.com/daeuniverse/dae
|
||||||
|
GO_PKG_LDFLAGS_X:= \
|
||||||
|
$(GO_PKG)/cmd.Version=$(PKG_VERSION) \
|
||||||
|
$(GO_PKG)/common/consts.MaxMatchSetLen_=64
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/bpf.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
UNZIP_CMD:=unzip -q -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
|
||||||
|
|
||||||
|
define Package/dae/Default
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Web Servers/Proxies
|
||||||
|
URL:=https://github.com/daeuniverse/dae
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae
|
||||||
|
$(call Package/dae/Default)
|
||||||
|
TITLE:=A lightweight and high-performance transparent proxy solution
|
||||||
|
# You need enable KERNEL_DEBUG_INFO_BTF and KERNEL_BPF_EVENTS
|
||||||
|
DEPENDS:=$(GO_ARCH_DEPENDS) $(BPF_DEPENDS) \
|
||||||
|
+ca-bundle +kmod-sched-core +kmod-sched-bpf +kmod-xdp-sockets-diag \
|
||||||
|
+kmod-veth
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae-geoip
|
||||||
|
$(call Package/dae/Default)
|
||||||
|
TITLE:=geoip for dae
|
||||||
|
DEPENDS:=+dae +v2ray-geoip
|
||||||
|
PKGARCH:=all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae-geosite
|
||||||
|
$(call Package/dae/Default)
|
||||||
|
TITLE:=geosite for dae
|
||||||
|
DEPENDS:=+dae +v2ray-geosite
|
||||||
|
PKGARCH:=all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae/description
|
||||||
|
dae, means goose, is a lightweight and high-performance transparent
|
||||||
|
proxy solution.
|
||||||
|
|
||||||
|
In order to improve the traffic diversion performance as much as possible,
|
||||||
|
dae runs the transparent proxy and traffic diversion suite in the linux
|
||||||
|
kernel by eBPF. Therefore, we have the opportunity to make the direct
|
||||||
|
traffic bypass the forwarding by proxy application and achieve true direct
|
||||||
|
traffic through. Under such a magic trick, there is almost no performance
|
||||||
|
loss and additional resource consumption for direct traffic.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae/conffiles
|
||||||
|
/etc/dae/config.dae
|
||||||
|
/etc/config/dae
|
||||||
|
endef
|
||||||
|
|
||||||
|
DAE_CFLAGS:= \
|
||||||
|
-O2 -Wall -Werror \
|
||||||
|
-DMAX_MATCH_SET_LEN=64 \
|
||||||
|
-I$(BPF_HEADERS_DIR)/tools/lib \
|
||||||
|
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
( \
|
||||||
|
$(GO_GENERAL_BUILD_CONFIG_VARS) \
|
||||||
|
$(GO_PKG_BUILD_CONFIG_VARS) \
|
||||||
|
$(GO_PKG_BUILD_VARS) \
|
||||||
|
BPF_CLANG="$(CLANG)" \
|
||||||
|
BPF_STRIP_FLAG="-strip=$(LLVM_STRIP)" \
|
||||||
|
BPF_CFLAGS="$(DAE_CFLAGS)" \
|
||||||
|
BPF_TARGET="bpfel,bpfeb" \
|
||||||
|
go generate $(PKG_BUILD_DIR)/control/control.go ; \
|
||||||
|
$(call GoPackage/Build/Compile) ; \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae/install
|
||||||
|
$(call GoPackage/Package/Install/Bin,$(1))
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/dae/
|
||||||
|
$(INSTALL_CONF) $(PKG_BUILD_DIR)/example.dae $(1)/etc/dae/
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_CONF) $(CURDIR)/files/dae.config $(1)/etc/config/dae
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) $(CURDIR)/files/dae.init $(1)/etc/init.d/dae
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae-geoip/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/dae
|
||||||
|
$(LN) ../v2ray/geoip.dat $(1)/usr/share/dae/geoip.dat
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/dae-geosite/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/dae
|
||||||
|
$(LN) ../v2ray/geosite.dat $(1)/usr/share/dae/geosite.dat
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,dae))
|
||||||
|
$(eval $(call BuildPackage,dae))
|
||||||
|
$(eval $(call BuildPackage,dae-geoip))
|
||||||
|
$(eval $(call BuildPackage,dae-geosite))
|
7
net/dae/files/dae.config
Normal file
7
net/dae/files/dae.config
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
config dae 'config'
|
||||||
|
option enabled '0'
|
||||||
|
option config_file '/etc/dae/config.dae'
|
||||||
|
option log_maxbackups '1'
|
||||||
|
option log_maxsize '1'
|
||||||
|
|
56
net/dae/files/dae.init
Normal file
56
net/dae/files/dae.init
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
START=99
|
||||||
|
|
||||||
|
extra_command "hot_reload" "Hot-reload service"
|
||||||
|
|
||||||
|
CONF="dae"
|
||||||
|
PROG="/usr/bin/dae"
|
||||||
|
LOG_DIR="/var/log/dae"
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
config_load "$CONF"
|
||||||
|
|
||||||
|
local enabled
|
||||||
|
config_get_bool enabled "config" "enabled" "0"
|
||||||
|
[ "$enabled" -eq "1" ] || return 1
|
||||||
|
|
||||||
|
local config_file
|
||||||
|
config_get config_file "config" "config_file" "/etc/dae/config.dae"
|
||||||
|
|
||||||
|
"$PROG" validate -c "$config_file" || return 1
|
||||||
|
|
||||||
|
local log_maxbackups log_maxsize
|
||||||
|
config_get log_maxbackups "config" "log_maxbackups" "1"
|
||||||
|
config_get log_maxsize "config" "log_maxsize" "1"
|
||||||
|
|
||||||
|
procd_open_instance "$CONF"
|
||||||
|
procd_set_param command "$PROG" run
|
||||||
|
procd_append_param command --config "$config_file"
|
||||||
|
procd_append_param command --disable-timestamp
|
||||||
|
procd_append_param command --logfile "$LOG_DIR/dae.log"
|
||||||
|
procd_append_param command --logfile-maxbackups "$log_maxbackups"
|
||||||
|
procd_append_param command --logfile-maxsize "$log_maxsize"
|
||||||
|
|
||||||
|
procd_set_param limits core="unlimited"
|
||||||
|
procd_set_param limits nofile="1000000 1000000"
|
||||||
|
procd_set_param respawn
|
||||||
|
# procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
rm -rf "$LOG_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "$CONF"
|
||||||
|
}
|
||||||
|
|
||||||
|
hot_reload() {
|
||||||
|
"$PROG" reload "$(cat /var/run/dae.pid)"
|
||||||
|
}
|
7
net/dae/test.sh
Normal file
7
net/dae/test.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"dae")
|
||||||
|
dae --version | grep "$PKG_VERSION"
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in a new issue