diff --git a/gost/Makefile b/gost/Makefile new file mode 100644 index 000000000..419b55b01 --- /dev/null +++ b/gost/Makefile @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: GPL-3.0-only +# +# Copyright (C) 2021 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=gost +PKG_VERSION:=2.11.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/ginuerzh/gost/tar.gz/v$(PKG_VERSION)? +PKG_HASH:=skip + +PKG_LICENSE:=MIT +PKG_LICENSE_FILE:=LICENSE +PKG_MAINTAINER:=Tianling Shen + +PKG_CONFIG_DEPENDS:= \ + CONFIG_GOST_COMPRESS_GOPROXY \ + CONFIG_GOST_COMPRESS_UPX + +PKG_BUILD_DEPENDS:=golang/host +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +GO_PKG:=github.com/ginuerzh/gost +GO_PKG_BUILD_PKG:=github.com/ginuerzh/gost/cmd/gost +GO_PKG_LDFLAGS:=-s -w + +include $(INCLUDE_DIR)/package.mk +include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk + +define Package/gost + SECTION:=net + CATEGORY:=Network + TITLE:=GO Simple Tunnel + URL:=https://github.com/ginuerzh/gost + DEPENDS:=$(GO_ARCH_DEPENDS) +endef + +define Package/gost/description + A simple security tunnel written in Golang +endef + +define Package/gost/config +config GOST_COMPRESS_GOPROXY + bool "Compiling with GOPROXY proxy" + default n + +config GOST_COMPRESS_UPX + bool "Compress executable files with UPX" + depends on !mips64 + default n +endef + +ifeq ($(CONFIG_GOST_COMPRESS_GOPROXY),y) + export GO111MODULE=on + export GOPROXY=https://goproxy.bj.bcebos.com +endif + +define Build/Compile + $(call GoPackage/Build/Compile) +ifeq ($(CONFIG_GOST_COMPRESS_UPX),y) + $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/gost +endif +endef + +define Package/gost/install + $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) + + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gost $(1)/usr/bin/gost + + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) $(CURDIR)/files/gost.config $(1)/etc/config/gost + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) $(CURDIR)/files/gost.init $(1)/etc/init.d/gost +endef + +$(eval $(call GoBinPackage,gost)) +$(eval $(call BuildPackage,gost)) diff --git a/gost/files/gost.config b/gost/files/gost.config new file mode 100644 index 000000000..6bea71967 --- /dev/null +++ b/gost/files/gost.config @@ -0,0 +1,5 @@ + +config gost + option enable '0' + option run_command '' + diff --git a/gost/files/gost.init b/gost/files/gost.init new file mode 100755 index 000000000..fbb836ca2 --- /dev/null +++ b/gost/files/gost.init @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common +# Created By ImmortalWrt +# https://github.com/project-openwrt + +START=90 +STOP=10 + +enable="$(uci get gost.@gost[0].enable)" +run_command="$(uci get gost.@gost[0].run_command)" + +start() +{ + stop + + [ "${enable}" -ne "1" ] && exit 0 + /usr/bin/gost ${run_command} & +} + +stop() +{ + killall -9 "gost" > "/dev/null" 2>&1 +} diff --git a/luci-app-gost/Makefile b/luci-app-gost/Makefile new file mode 100644 index 000000000..2c674d816 --- /dev/null +++ b/luci-app-gost/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2020 Openwrt.org +# +# This is a free software, use it under GNU General Public License v3.0. +# +# Created By ImmortalWrt +# https://github.com/project-openwrt + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-gost +PKG_VERSION:=1.0 +PKG_RELEASE:=1 +LUCI_TITLE:=LuCI support for Gost +LUCI_DEPENDS:=+gost +LUCI_PKGARCH:=all + +PKG_MAINTAINER:=ImmortalWrt + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-gost/luasrc/controller/gost.lua b/luci-app-gost/luasrc/controller/gost.lua new file mode 100644 index 000000000..37f8af1f1 --- /dev/null +++ b/luci-app-gost/luasrc/controller/gost.lua @@ -0,0 +1,24 @@ +-- This is a free software, use it under GNU General Public License v3.0. +-- Created By ImmortalWrt +-- https://github.com/immortalwrt + +module("luci.controller.gost", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/gost") then + return + end + + local page + page = entry({"admin", "services", "gost"}, cbi("gost"), _("Gost"), 100) + page.dependent = true + page.acl_depends = { "luci-app-gost" } + entry({"admin", "services", "gost", "status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep gost >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-gost/luasrc/model/cbi/gost.lua b/luci-app-gost/luasrc/model/cbi/gost.lua new file mode 100644 index 000000000..116bd0dc9 --- /dev/null +++ b/luci-app-gost/luasrc/model/cbi/gost.lua @@ -0,0 +1,20 @@ +-- Created By ImmortalWrt +-- https://github.com/immortalwrt + +mp = Map("gost", translate("Gost")) +mp.description = translate("A simple security tunnel written in Golang.") + +mp:section(SimpleSection).template = "gost/gost_status" + +s = mp:section(TypedSection, "gost") +s.anonymous=true +s.addremove=false + +enable = s:option(Flag, "enable", translate("Enable")) +enable.default = 0 +enable.rmempty = false + +run_command = s:option(Value, "run_command", translate("Command")) +run_command.rmempty = false + +return mp diff --git a/luci-app-gost/luasrc/view/gost/gost_status.htm b/luci-app-gost/luasrc/view/gost/gost_status.htm new file mode 100644 index 000000000..3f279c9ef --- /dev/null +++ b/luci-app-gost/luasrc/view/gost/gost_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
diff --git a/luci-app-gost/po/zh-cn b/luci-app-gost/po/zh-cn new file mode 120000 index 000000000..8d69574dd --- /dev/null +++ b/luci-app-gost/po/zh-cn @@ -0,0 +1 @@ +zh_Hans \ No newline at end of file diff --git a/luci-app-gost/po/zh_Hans/gost.po b/luci-app-gost/po/zh_Hans/gost.po new file mode 100644 index 000000000..9ccabdeca --- /dev/null +++ b/luci-app-gost/po/zh_Hans/gost.po @@ -0,0 +1,17 @@ +msgid "Gost" +msgstr "Gost" + +msgid "A simple security tunnel written in Golang." +msgstr "GO语言实现的安全隧道。" + +msgid "RUNNING" +msgstr "运行中" + +msgid "NOT RUNNING" +msgstr "未运行" + +msgid "Enable" +msgstr "启用" + +msgid "Command" +msgstr "命令" diff --git a/luci-app-gost/root/etc/uci-defaults/gost b/luci-app-gost/root/etc/uci-defaults/gost new file mode 100755 index 000000000..e1ddf16fa --- /dev/null +++ b/luci-app-gost/root/etc/uci-defaults/gost @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@gost[-1] + add ucitrack gost + set ucitrack.@gost[-1].init=gost + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/luci-app-gost/root/usr/share/rpcd/acl.d/luci-app-gost.json b/luci-app-gost/root/usr/share/rpcd/acl.d/luci-app-gost.json new file mode 100644 index 000000000..f5adf7e5c --- /dev/null +++ b/luci-app-gost/root/usr/share/rpcd/acl.d/luci-app-gost.json @@ -0,0 +1,11 @@ +{ + "luci-app-gost": { + "description": "Grant UCI access for luci-app-gost", + "read": { + "uci": [ "gost" ] + }, + "write": { + "uci": [ "gost" ] + } + } +}