Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Nov 2019 06:16:25 +0000 (UTC)
From:      Rodrigo Osorio <rodrigo@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r517183 - in head/net: . pichi pichi/files
Message-ID:  <201911100616.xAA6GP0g049457@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rodrigo
Date: Sun Nov 10 06:16:24 2019
New Revision: 517183
URL: https://svnweb.freebsd.org/changeset/ports/517183

Log:
  New port: net/pichi An Application Layer Proxy controlled via RESTful APIs
  
  PR:		237315
  Submitted by:	Pichi <pichi@elude.in>

Added:
  head/net/pichi/
  head/net/pichi/Makefile   (contents, props changed)
  head/net/pichi/distinfo   (contents, props changed)
  head/net/pichi/files/
  head/net/pichi/files/patch-CMakeLists.txt   (contents, props changed)
  head/net/pichi/files/patch-cmake_ProcessOptions.cmake   (contents, props changed)
  head/net/pichi/files/patch-include_config.h.in   (contents, props changed)
  head/net/pichi/files/patch-src_net_asio.cpp   (contents, props changed)
  head/net/pichi/files/pichi.in   (contents, props changed)
  head/net/pichi/pkg-descr   (contents, props changed)
  head/net/pichi/pkg-plist   (contents, props changed)
Modified:
  head/net/Makefile

Modified: head/net/Makefile
==============================================================================
--- head/net/Makefile	Sun Nov 10 06:15:47 2019	(r517182)
+++ head/net/Makefile	Sun Nov 10 06:16:24 2019	(r517183)
@@ -974,6 +974,7 @@
     SUBDIR += php74-sockets
     SUBDIR += php74-xmlrpc
     SUBDIR += phpldapadmin
+    SUBDIR += pichi
     SUBDIR += pim6-tools
     SUBDIR += pim6dd
     SUBDIR += pim6sd

Added: head/net/pichi/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/Makefile	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,74 @@
+# $FreeBSD$
+
+PORTNAME=	pichi
+DISTVERSION=	1.2.0
+CATEGORIES=	net
+
+MAINTAINER=	pichi@elude.in
+COMMENT=	Application Layer Proxy controlled via RESTful APIs
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	rapidjson>=1.1.0:devel/rapidjson
+
+USES=		cmake
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	pichi-router
+
+USE_RC_SUBR=	pichi
+PLIST_SUB=	DISTVERSION=${DISTVERSION}
+
+CMAKE_BUILD_TYPE=	MinSizeRel
+CMAKE_ARGS=		-DVERSION=${DISTVERSION}
+CMAKE_ON=		BUILD_SERVER BUILD_TEST
+CMAKE_OFF=		INSTALL_HEADERS
+INSTALL_TARGET=		install/strip
+TEST_TARGET=		test
+
+OPTIONS_DEFINE=		STATIC TLS
+OPTIONS_DEFAULT=	TLS
+OPTIONS_SUB=		yes
+
+TLS_DESC=	Enable TLS support ( requiring OpenSSL )
+TLS_CMAKE_BOOL=	ENABLE_TLS
+
+STATIC_DESC=		Build/Install static library
+STATIC_CMAKE_BOOL=	STATIC_LINK
+STATIC_BUILD_DEPENDS=	boost-libs>=1.67.0:devel/boost-libs \
+			libmaxminddb>=1.3.0:net/libmaxminddb \
+			libsodium>=1.0.12:security/libsodium \
+			mbedtls>=2.7.0:security/mbedtls
+STATIC_LIB_DEPENDS_OFF=	libboost_context.so:devel/boost-libs \
+			libboost_filesystem.so:devel/boost-libs \
+			libboost_program_options.so:devel/boost-libs \
+			libboost_system.so:devel/boost-libs \
+			libmaxminddb.so:net/libmaxminddb \
+			libmbedcrypto.so:security/mbedtls \
+			libmbedtls.so:security/mbedtls \
+			libmbedx509.so:security/mbedtls \
+			libsodium.so:security/libsodium
+
+.include <bsd.port.options.mk>
+
+.if ! ${PORT_OPTIONS:MSTATIC}
+USE_LDCONFIG=	yes
+.endif
+
+.if ${PORT_OPTIONS:MTLS}
+.if ${PORT_OPTIONS:MSTATIC}
+USES+=		ssl:build
+.else
+USES+=		ssl
+.endif
+.endif
+
+post-install:
+	${MKDIR} ${STAGEDIR}${ETCDIR}
+	${INSTALL_DATA} ${WRKSRC}/test/geo.mmdb ${STAGEDIR}${ETCDIR}/geo.mmdb
+	${INSTALL_DATA} ${WRKSRC}/server/pichi.json.default ${STAGEDIR}${ETCDIR}/pichi.json.sample
+	${MKDIR} ${STAGEDIR}${PREFIX}/include
+	${INSTALL_DATA} ${WRKSRC}/include/pichi.h ${STAGEDIR}${PREFIX}/include/pichi.h
+
+.include <bsd.port.mk>

Added: head/net/pichi/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/distinfo	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1554899633
+SHA256 (pichi-router-pichi-1.2.0_GH0.tar.gz) = 8965077371f2dbf49a63659d686470c191c2c21c47a32f44b3b8bb2d72968043
+SIZE (pichi-router-pichi-1.2.0_GH0.tar.gz) = 1841049

Added: head/net/pichi/files/patch-CMakeLists.txt
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/files/patch-CMakeLists.txt	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,17 @@
+--- CMakeLists.txt.orig	2019-04-14 16:29:43 UTC
++++ CMakeLists.txt
+@@ -19,6 +19,14 @@ find_package(MaxmindDB 1.3.0 REQUIRED)
+ find_package(Rapidjson 1.1.0 REQUIRED)
+ find_package(Threads REQUIRED)
+ 
++if (Boost_VERSION_STRING VERSION_LESS "1.70.0")
++  set(RESOLVER_CONSTRUCTED_FROM_EXECUTOR OFF)
++else (Boost_VERSION_STRING VERSION_LESS "1.70.0")
++  set(RESOLVER_CONSTRUCTED_FROM_EXECUTOR ON)
++endif (Boost_VERSION_STRING VERSION_LESS "1.70.0")
++
++configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${CMAKE_BINARY_DIR}/include/config.h)
++
+ include_directories(
+   ${CMAKE_SOURCE_DIR}/include
+   ${CMAKE_BINARY_DIR}/include

Added: head/net/pichi/files/patch-cmake_ProcessOptions.cmake
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/files/patch-cmake_ProcessOptions.cmake	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,8 @@
+--- cmake/ProcessOptions.cmake.orig	2019-04-14 16:29:43 UTC
++++ cmake/ProcessOptions.cmake
+@@ -83,5 +83,3 @@ if (BUILD_SERVER)
+   check_function_exists("setsid" HAS_SETSID)
+   check_function_exists("close" HAS_CLOSE)
+ endif (BUILD_SERVER)
+-
+-configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${CMAKE_BINARY_DIR}/include/config.h)

Added: head/net/pichi/files/patch-include_config.h.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/files/patch-include_config.h.in	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,11 @@
+--- include/config.h.in.orig	2019-04-14 16:29:43 UTC
++++ include/config.h.in
+@@ -13,6 +13,8 @@
+ #cmakedefine HAS_SETSID
+ #cmakedefine HAS_CLOSE
+ 
++#cmakedefine RESOLVER_CONSTRUCTED_FROM_EXECUTOR
++
+ #cmakedefine CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
+ 
+ #ifdef CMAKE_INSTALL_PREFIX

Added: head/net/pichi/files/patch-src_net_asio.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/files/patch-src_net_asio.cpp	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,17 @@
+--- src/net/asio.cpp.orig	2019-04-14 16:29:43 UTC
++++ src/net/asio.cpp
+@@ -79,8 +79,12 @@ void connect(Endpoint const& endpoint, Socket& s, Yiel
+   else
+ #endif // BUILD_TEST
+     asio::async_connect(s,
+-                        tcp::resolver{s.get_executor().context()}.async_resolve(
+-                            endpoint.host_, endpoint.port_, yield),
++                        tcp::resolver{s.get_executor()
++#ifndef RESOLVER_CONSTRUCTED_FROM_EXECUTOR
++                                          .context()
++#endif // RESOLVER_CONSTRUCTED_FROM_EXECUTOR
++                        }
++                            .async_resolve(endpoint.host_, endpoint.port_, yield),
+                         yield);
+ }
+ 

Added: head/net/pichi/files/pichi.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/files/pichi.in	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: pichi
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+get_pid()
+{
+  ps -o "pid=" -p "$(cat ${pid_file} 2>/dev/null)" 2>/dev/null
+}
+
+pichi_start()
+{
+  pid="$(get_pid)"
+  if [ -n "${pid}" ]; then
+    echo "${name} is running with pid ${pid}"
+    exit 1
+  fi
+  if [ -z "${pichi_port}" ]; then
+    echo "pichi_port is not set"
+    exit 1
+  fi
+  "${command}" -u nobody --group daemon -d -g "${pichi_mmdb}" -p "${pichi_port}" -l "${pichi_bind}" --json "${pichi_conf}"
+  if ! get_pid >/dev/null 2>&1; then
+    echo "Failed to start ${name}"
+    exit 1
+  fi
+}
+
+# Main
+. /etc/rc.subr
+
+load_rc_config "${name}"
+
+name="pichi"
+rcvar="${name}_enable"
+prefix="%%PREFIX%%"
+command="${prefix}/bin/${name}"
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+restart_cmd="${name}_restart"
+status_cmd="${name}_status"
+extra_commands="reload"
+reload_cmd="${name}_reload"
+pid_file="${prefix}/var/run/${name}.pid"
+
+: ${pichi_enable:="NO"}
+: ${pichi_bind:="::1"}
+: ${pichi_port:="21127"}
+: ${pichi_conf:="${prefix}/etc/${name}/pichi.json"}
+: ${pichi_mmdb:="${prefix}/etc/${name}/geo.mmdb"}
+
+pichi_stop()
+{
+  pid=$(get_pid)
+  if [ -n "${pid}" ]; then
+    kill ${pid}
+  fi
+}
+
+pichi_restart()
+{
+  pichi_stop
+  pichi_start
+}
+
+pichi_reload()
+{
+  pid=$(get_pid)
+  if [ -n "${pid}" ]; then
+    kill -HUP ${pid}
+  fi
+}
+
+pichi_status()
+{
+  pid=$(get_pid)
+  if [ -n "${pid}" ]; then
+    echo "${name} is running with PID ${pid}"
+  else
+    echo "${name} is not running"
+  fi
+}
+
+run_rc_command "$1"

Added: head/net/pichi/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/pkg-descr	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,6 @@
+Pichi is an application layer proxy, which can be fully controlled via
+RESTful APIs. It supports HTTP/SOCKS5/Shadowsocks.
+
+The core feature of pichi is the dynamic, flexible route controlling.
+
+WWW: https://github.com/pichi-router/pichi

Added: head/net/pichi/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/pichi/pkg-plist	Sun Nov 10 06:16:24 2019	(r517183)
@@ -0,0 +1,7 @@
+bin/pichi
+include/pichi.h
+@sample etc/pichi/pichi.json.sample
+etc/pichi/geo.mmdb
+%%NO_STATIC%%lib/libpichi.so.%%DISTVERSION%%
+%%NO_STATIC%%lib/libpichi.so
+%%STATIC%%lib/libpichi.a



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911100616.xAA6GP0g049457>