This package adds the mac-telnet server, client, ping and discovery utilities. See https://github.com/aouyar/MAC-Telnet for details. This package uses the fork from https://github.com/jow-/MAC-Telnet as source, the code there has a number of bugfixes and results in smaller binaries since most core functionality has been ported to libubox facilities provided by OpenWrt. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>lilik-openwrt-22.03
@ -0,0 +1,71 @@ | |||||
# | |||||
# Copyright (C) 2014 OpenWrt.org | |||||
# | |||||
include $(TOPDIR)/rules.mk | |||||
PKG_NAME:=mac-telnet | |||||
PKG_VERSION:=2014-09-03 | |||||
PKG_RELEASE:=$(PKG_SOURCE_VERSION) | |||||
PKG_SOURCE_PROTO:=git | |||||
PKG_SOURCE_URL:=https://github.com/jow-/MAC-Telnet.git | |||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) | |||||
PKG_SOURCE_VERSION:=9a8bf5c242c6b0336c2f257aa67d2240454ba4b0 | |||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz | |||||
PKG_LICENSE:=GPL-2.0+ | |||||
PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org> | |||||
include $(INCLUDE_DIR)/package.mk | |||||
TARGET_CFLAGS += -ffunction-sections -fdata-sections $(if $(CONFIG_MACTELNET_PLAIN_SUPPORT),-DTELNET_SUPPORT) | |||||
TARGET_LDFLAGS += -Wl,--gc-sections | |||||
# 1: name | |||||
# 2: executable | |||||
define BuildPlugin | |||||
define Package/mac-telnet-$(1) | |||||
SECTION:=net | |||||
CATEGORY:=Network | |||||
DEPENDS:=+libubox | |||||
TITLE:=MAC-Telnet / MAC-SSH $(1) | |||||
URL:=https://github.com/jow-/MAC-Telnet | |||||
endef | |||||
define Package/mac-telnet-$(1)/description | |||||
Open source MAC Telnet client and server utilities for connecting to | |||||
Mikrotik RouterOS routers and Linux machines via MAC address. | |||||
endef | |||||
define Package/mac-telnet-$(1)/install | |||||
$(INSTALL_DIR) $$(1)/usr/sbin | |||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(2) $$(1)/usr/sbin/ | |||||
$(call Package/mac-telnet-$(1)/install-extra) | |||||
endef | |||||
$$(eval $$(call BuildPackage,mac-telnet-$(1))) | |||||
endef | |||||
define Package/mac-telnet-server/config | |||||
config MACTELNET_PLAIN_SUPPORT | |||||
bool "Include support for plain telnet connections" | |||||
depends on PACKAGE_mac-telnet-server | |||||
default y | |||||
help | |||||
Disable this option to only support SSH logins to the | |||||
MAC-Telnet server. | |||||
endef | |||||
define Package/mac-telnet-server/install-extra | |||||
$(INSTALL_DIR) $$(1)/etc/init.d | |||||
$(INSTALL_BIN) ./files/mactelnet.init $$(1)/etc/init.d/mactelnet | |||||
$(INSTALL_DIR) $$(1)/etc/config | |||||
$(INSTALL_DATE) ./files/mactelnet.config $$(1)/etc/config/mactelnet | |||||
endef | |||||
$(eval $(call BuildPlugin,server,mactelnetd)) | |||||
$(eval $(call BuildPlugin,client,mactelnet)) | |||||
$(eval $(call BuildPlugin,ping,macping)) | |||||
$(eval $(call BuildPlugin,discover,mndp)) |
@ -0,0 +1,9 @@ | |||||
# Global settings for MAC-Telnet daemon | |||||
config mactelnetd | |||||
option sshmode '0' | |||||
list interface 'lan' | |||||
# Define a MAC-Telnet login, multiple login sections allowed | |||||
config login | |||||
option username 'root' | |||||
option password 'secret' |
@ -0,0 +1,80 @@ | |||||
#!/bin/sh /etc/rc.common | |||||
# Copyright (C) 2014 OpenWrt.org | |||||
START=60 | |||||
USE_PROCD=1 | |||||
PROG=/usr/sbin/mactelnetd | |||||
USERS=/var/etc/mactelnetd.users | |||||
SSHMODE=0 | |||||
add_account() { | |||||
local cfg="$1" | |||||
local user pass | |||||
[ $SSHMODE -eq 0 ] || { | |||||
[ -n "$already_warned" ] || { | |||||
echo "mactelnet.$cfg: login sections ignored in SSH mode" >&1 | |||||
already_warned=1 | |||||
} | |||||
return | |||||
} | |||||
config_get username "$cfg" username | |||||
config_get password "$cfg" password | |||||
[ -n "$username" ] || { | |||||
echo "mactelnet.$cfg: username missing" >&2 | |||||
return | |||||
} | |||||
[ -n "$password" ] || { | |||||
echo "mactelnet.$cfg: password missing" >&2 | |||||
return | |||||
} | |||||
echo "$username:$password" >> $USERS | |||||
} | |||||
add_interface() { | |||||
local iface="$1" | |||||
local device | |||||
[ -n "$iface" ] || return | |||||
if network_get_physdev device "$iface"; then | |||||
procd_append_param command -i "$device" | |||||
fi | |||||
procd_add_reload_interface_trigger "$iface" | |||||
} | |||||
add_globals() { | |||||
local cfg="$1" | |||||
config_get_bool SSHMODE "$cfg" sshmode 0 | |||||
[ $SSHMODE -eq 0 ] || procd_append_param command -S | |||||
config_list_foreach "$cfg" interface add_interface | |||||
} | |||||
start_service() { | |||||
. /lib/functions/network.sh | |||||
procd_open_instance | |||||
procd_add_reload_trigger mactelnet | |||||
procd_set_param command "$PROG" -f | |||||
config_load mactelnet | |||||
config_foreach add_globals mactelnetd | |||||
[ $SSHMODE -eq 1 ] || { | |||||
rm -f $USERS | |||||
config_foreach add_account login | |||||
} | |||||
procd_close_instance | |||||
} | |||||