Skip to content

Commit

Permalink
daed: initial package
Browse files Browse the repository at this point in the history
daed, a modern dashboard for dae.

Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Jun 25, 2023
1 parent d37fb8e commit 5e4ecc2
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 0 deletions.
158 changes: 158 additions & 0 deletions net/daed/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 ImmortalWrt.org

include $(TOPDIR)/rules.mk

PKG_NAME:=daed
PKG_VERSION:=0.1.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/daeuniverse/daed.git
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_MIRROR_HASH:=7e8b17effbad702cc36e5876a2616619c4fe8a67c85de4dec9d6a5c13373e20b

PKG_LICENSE:=AGPL-3.0-only MIT
PKG_LICENSE_FILES:=LICENSE wing/LICENSE
PKG_MAINTAINER:=Tianling Shen <[email protected]>

PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing
PKG_BUILD_DEPENDS:=golang/host bpf-headers
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16

GO_PKG:=github.com/daeuniverse/dae-wing
GO_PKG_LDFLAGS:= \
-X '$(GO_PKG)/db.AppDescription=$(PKG_NAME) is a integration solution of dae, API and UI.'
GO_PKG_LDFLAGS_X:= \
$(GO_PKG)/db.AppName=$(PKG_NAME) \
$(GO_PKG)/db.AppVersion=$(PKG_VERSION)
GO_PKG_TAGS:=embedallowed

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/bpf.mk
include ../../lang/golang/golang-package.mk

TAR_CMD=$(HOST_TAR) -C $(BUILD_DIR)/ $(TAR_OPTIONS)

define Package/daed/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
URL:=https://github.com/daeuniverse/daed
endef

define Package/daed
$(call Package/daed/Default)
TITLE:=A Modern Dashboard For dae
# 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
endef

define Package/daed-geoip
$(call Package/daed/Default)
TITLE:=geoip for daed
DEPENDS:=+daed +v2ray-geoip
endef

define Package/daed-geosite
$(call Package/daed/Default)
TITLE:=geosite for daed
DEPENDS:=+daed +v2ray-geosite
endef

define Package/daed/description
daed is a backend of dae, provides a method to bundle arbitrary
frontend, dae and geodata into one binary.
endef

define Package/daed/conffiles
/etc/daed/wing.db
/etc/config/daed
endef

WEB_FILE:=$(PKG_NAME)-web-$(PKG_VERSION).zip
define Download/daed-web
URL:=https://github.com/daeuniverse/daed/releases/download/v$(PKG_VERSION)
URL_FILE:=web.zip
FILE:=$(WEB_FILE)
HASH:=99a60c0fbfe889b6d49df7b9bf117c208c03d1bb5d27b05bff2f661c63856396
endef

define Build/Prepare
$(call Build/Prepare/Default)

( \
mkdir -p $(PKG_BUILD_DIR)/webrender ; \
unzip -q -d $(PKG_BUILD_DIR)/webrender/ $(DL_DIR)/$(WEB_FILE) ; \
find $(PKG_BUILD_DIR)/webrender/web -type f -size +4k ! -name "*.gz" ! -name "*.woff" ! -name "*.woff2" -exec sh -c '\
gzip -9 -k "{}"; \
if [ "$$$$(stat -c %s {})" -lt "$$$$(stat -c %s {}.gz)" ]; then \
rm {}.gz; \
else \
rm {}; \
fi' \
";" ; \
)
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

ifneq ($(CONFIG_USE_MUSL),)
TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
endif

define Build/Compile
( \
pushd $(PKG_BUILD_DIR) ; \
$(GO_GENERAL_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_VARS) \
go generate ./... ; \
cd dae-core ; \
$(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 control/control.go ; \
popd ; \
$(call GoPackage/Build/Compile) ; \
)
endef

define Package/daed/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dae-wing $(1)/usr/bin/daed

$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(CURDIR)/files/daed.config $(1)/etc/config/daed

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(CURDIR)/files/daed.init $(1)/etc/init.d/daed
endef

define Package/daed-geoip/install
$(INSTALL_DIR) $(1)/usr/share/daed
$(LN) ../v2ray/geoip.dat $(1)/usr/share/daed/geoip.dat
endef

define Package/daed-geosite/install
$(INSTALL_DIR) $(1)/usr/share/daed
$(LN) ../v2ray/geosite.dat $(1)/usr/share/daed/geosite.dat
endef

$(eval $(call Download,daed-web))
$(eval $(call GoBinPackage,daed))
$(eval $(call BuildPackage,daed))
$(eval $(call BuildPackage,daed-geoip))
$(eval $(call BuildPackage,daed-geosite))
5 changes: 5 additions & 0 deletions net/daed/files/daed.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

config daed 'config'
option enabled '0'
option listen_addr '0.0.0.0:2023'

36 changes: 36 additions & 0 deletions net/daed/files/daed.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2023 Tianling Shen <[email protected]>

USE_PROCD=1
START=99

CONF="daed"
PROG="/usr/bin/daed"

start_service() {
config_load "$CONF"

local enabled
config_get_bool enabled "config" "enabled" "0"
[ "$enabled" -eq "1" ] || return 1

local listen_addr
config_get listen_addr "config" "listen_addr" "0.0.0.0:2023"

procd_open_instance "$CONF"
procd_set_param command "$PROG" run
procd_append_param command --config "/etc/daed/"
procd_append_param command --listen "$listen_addr"

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
}

service_triggers() {
procd_add_reload_trigger "$CONF"
}
7 changes: 7 additions & 0 deletions net/daed/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

case "$1" in
"daed")
daed --version | grep "$PKG_VERSION"
;;
esac

0 comments on commit 5e4ecc2

Please sign in to comment.