Add package shadowsocks-client 97/head
authorZhao, Gang <gang.zhao.42@gmail.com>
Mon, 14 Jul 2014 07:31:22 +0000 (15:31 +0800)
committerZhao, Gang <gang.zhao.42@gmail.com>
Wed, 16 Jul 2014 04:03:58 +0000 (12:03 +0800)
Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
net/shadowsocks-client/Makefile [new file with mode: 0644]
net/shadowsocks-client/files/sslocal.config [new file with mode: 0644]
net/shadowsocks-client/files/sslocal.init [new file with mode: 0755]

diff --git a/net/shadowsocks-client/Makefile b/net/shadowsocks-client/Makefile
new file mode 100644 (file)
index 0000000..e4344d6
--- /dev/null
@@ -0,0 +1,39 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=shadowsocks-client
+PKG_VERSION:=0.5
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=http://github.com/zhao-gang/shadowsocks-tiny.git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=d8ef02715f40de0fb7ba0f7267d3f8260f38ba80
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Zhao, Gang <gang.zhao.42@gmail.com>
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/shadowsocks-client
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Web Servers/Proxies
+  TITLE:=shadowsocks client for router
+  URL:=https://github.com/zhao-gang/shadowsocks-tiny
+  DEPENDS:=+libopenssl
+endef
+
+define Package/shadowsocks-client/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/sslocal $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/sslocal.config $(1)/etc/config/sslocal
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/sslocal.init $(1)/etc/init.d/sslocal
+endef
+
+$(eval $(call BuildPackage,shadowsocks-client))
diff --git a/net/shadowsocks-client/files/sslocal.config b/net/shadowsocks-client/files/sslocal.config
new file mode 100644 (file)
index 0000000..28dc261
--- /dev/null
@@ -0,0 +1,7 @@
+config sslocal
+       option server_addr ''
+       option server_port ''
+       option local_addr ''
+       option local_port ''
+       option password ''
+       option method ''
diff --git a/net/shadowsocks-client/files/sslocal.init b/net/shadowsocks-client/files/sslocal.init
new file mode 100755 (executable)
index 0000000..ac845e5
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2014 Zhao, Gang <gang.zhao.42@gmail.com>
+
+START=99
+
+USE_PROCD=1
+PROG=/usr/bin/sslocal
+
+validate_section_sslocal() {
+       uci_validate_section sslocal sslocal "${1}" \
+               'server_addr:host' \
+               'server_port:port' \
+               'local_addr:host' \
+               'local_port:port' \
+               'password:string' \
+               'method:string' \
+               'log_level:range(0,7):5'
+
+       return $?
+}
+
+sslocal_instance() {
+       local server_addr server_port local_addr local_port
+       local password method log_level
+
+       validate_section_sslocal "${1}" || {
+               echo "validation failed"
+               return 1
+       }
+
+       procd_open_instance
+       procd_set_param command "$PROG"
+       procd_append_param command -s "${server_addr}" -p "${server_port}"
+       procd_append_param command -u "${local_addr}" -b "${local_port}"
+       procd_append_param command -k "${password}" -m "${method}"
+       procd_append_param command -l "${log_level}"
+       procd_set_param respawn
+       procd_close_instance
+}
+
+start_service() {
+       config_load sslocal
+
+       config_foreach sslocal_instance sslocal
+}
+
+service_triggers()
+{
+       procd_add_reload_trigger "sslocal"
+       procd_add_validation validate_section_sslocal
+}