start:hello_world

This commit is contained in:
dichgrem
2025-09-17 20:35:00 +08:00
parent fab38dcc54
commit 248529bd17
14 changed files with 279 additions and 0 deletions

66
nyn/Makefile Normal file
View File

@@ -0,0 +1,66 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=nyn
PKG_VERSION:=0.0.3
PKG_RELEASE:=1
PKG_MAINTAINER:=Dichgrem <brcefy@gmail.com>
PKG_LICENSE:=MIT
include $(INCLUDE_DIR)/package.mk
define Package/nyn
SECTION:=net
CATEGORY:=Network
TITLE:=NYN 802.1x Authentication Client
URL:=https://github.com/diredocks/nyn
DEPENDS:=+libpcap
endef
define Package/nyn/description
A 802.1x authentication client for OpenWrt routers.
Cross-compiled with musl toolchain for optimal compatibility.
endef
define Package/nyn/conffiles
/etc/config/nyn
/etc/nyn/config.toml
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/nyn/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/nyn
# Install precompiled binary based on architecture
$(if $(CONFIG_TARGET_x86_64),$(INSTALL_BIN) ./files/bin/nyn-x86_64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_armvirt_64),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_bcm27xx_bcm2711),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_ath79_generic),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_ramips_mt7621),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_mediatek_mt7622),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_rockchip_armv8),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
# Fallback - try to detect architecture
$(if $(findstring arm,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-armv7 $(1)/usr/bin/nyn)
$(if $(findstring aarch64,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(findstring mips,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(findstring x86_64,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-x86_64 $(1)/usr/bin/nyn)
$(if $(findstring i386,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-i686 $(1)/usr/bin/nyn)
$(INSTALL_BIN) ./files/usr/bin/nyn-device-info $(1)/usr/bin/
$(INSTALL_CONF) ./files/etc/config/nyn $(1)/etc/config/
$(INSTALL_CONF) ./files/etc/nyn/config.toml $(1)/etc/nyn/
$(INSTALL_BIN) ./files/etc/init.d/nyn $(1)/etc/init.d/
endef
$(eval $(call BuildPackage,nyn))

BIN
nyn/files/bin/nyn-aarch64 Normal file

Binary file not shown.

BIN
nyn/files/bin/nyn-armv7 Normal file

Binary file not shown.

BIN
nyn/files/bin/nyn-i686 Normal file

Binary file not shown.

BIN
nyn/files/bin/nyn-mips64 Normal file

Binary file not shown.

BIN
nyn/files/bin/nyn-riscv64 Normal file

Binary file not shown.

BIN
nyn/files/bin/nyn-x86_64 Normal file

Binary file not shown.

16
nyn/files/etc/config/nyn Normal file
View File

@@ -0,0 +1,16 @@
config general 'general'
option enabled '0'
option timeout '1'
option retry '5'
option schedule_callback '0'
config crypto 'crypto'
option win_ver 'r70393861'
option client_key 'Oly5D62FaE94W7'
option client_version ''
config auth 'auth'
option user ''
option password ''
option device 'eth0'
option hardware_description ''

41
nyn/files/etc/init.d/nyn Normal file
View File

@@ -0,0 +1,41 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
CONFIG=/etc/nyn/config.toml
start_service() {
generate_config
procd_open_instance
procd_set_param command /usr/bin/nyn -config "$CONFIG"
procd_set_param respawn
procd_close_instance
}
stop_service() {
procd_kill nyn
}
generate_config() {
mkdir -p /etc/nyn
cat >"$CONFIG" <<EOF
# Auto-generated by UCI
[general]
timeout = $(uci -q get nyn.general.timeout)
retry = $(uci -q get nyn.general.retry)
schedule_callback = $([ "$(uci -q get nyn.general.schedule_callback)" = "1" ] && echo "true" || echo "false")
[crypto]
win_ver = "$(uci -q get nyn.crypto.win_ver)"
client_key = "$(uci -q get nyn.crypto.client_key)"
[[auth]]
user = "$(uci -q get nyn.auth.user)"
password = "$(uci -q get nyn.auth.password)"
device = "$(uci -q get nyn.auth.device)"
EOF
}

View File

@@ -0,0 +1,18 @@
# Default configuration for NYN 802.1x client
# This file will be generated by UCI system
[general]
timeout = 1
retry = 5
schedule_callback = false
[crypto]
win_ver = "r70393861"
client_key = "Oly5D62FaE94W7"
# client_version = ""
[[auth]]
user = ""
password = ""
device = "eth0"
# hardware_description = ""

View File

@@ -0,0 +1,29 @@
#!/bin/sh
# /usr/bin/nyn-device-info
# Helper script to get device information for NYN configuration
echo "Available network devices:"
echo "=========================="
if command -v nyn >/dev/null 2>&1; then
nyn -mode info 2>/dev/null | grep -E "(Found|device|hardware_description)" | while read line; do
echo "$line"
done
else
echo "NYN binary not found. Showing available network interfaces:"
for dev in /sys/class/net/*; do
if [ -d "$dev" ]; then
iface=$(basename "$dev")
if [ "$iface" != "lo" ]; then
echo "Device: $iface"
if [ -f "$dev/address" ]; then
echo " MAC: $(cat "$dev/address")"
fi
if [ -f "$dev/operstate" ]; then
echo " State: $(cat "$dev/operstate")"
fi
echo ""
fi
fi
done
fi