Skip to content

Instantly share code, notes, and snippets.

@pkern
Last active December 4, 2023 15:58
Show Gist options
  • Save pkern/5497c63f16bfa261ba9131dbfd64e69e to your computer and use it in GitHub Desktop.
Save pkern/5497c63f16bfa261ba9131dbfd64e69e to your computer and use it in GitHub Desktop.
OpenWRT package for sniproxy
include $(TOPDIR)/rules.mk
PKG_NAME:=sniproxy
PKG_VERSION:=0.6.0
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/dlundquist/sniproxy/archive/
PKG_SOURCE:=$(PKG_VERSION).tar.gz
PKG_MD5SUM:=bcfb5d1efe045b8b356a4229f2339f02
PKG_MAINTAINER:=Philipp Kern <pkern@debian.org>
include $(INCLUDE_DIR)/package.mk
define Package/sniproxy
SECTION:=net
CATEGORY:=Network
TITLE:=Transparent TLS and HTTP layer 4 proxy with SNI support
URL:=https://github.com/dlundquist/sniproxy
DEPENDS:=+libev +libpcre
endef
define Package/sniproxy/description
Transparent TLS and HTTP layer 4 proxy with SNI support
Proxies incoming HTTP and TLS connections based on the hostname contained in
the initial request of the TCP session. This enables HTTPS name-based virtual
hosting to separate backend servers without installing the private key on the
proxy machine.
endef
define Build/Configure
( cd $(PKG_BUILD_DIR) && ./autogen.sh )
$(call Build/Configure/Default)
endef
TARGET_CFLAGS+=-std=c99
PKG_INSTALL:=1
define Package/sniproxy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/$(PKG_NAME) $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/sniproxy.init $(1)/etc/init.d/sniproxy
endef
define Package/sniproxy/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Enabling rc.d symlink for $(PKG_NAME)"
/etc/init.d/$(PKG_NAME) enable
fi
exit 0
endef
define Package/sniproxy/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Removing rc.d symlink for $(PKG_NAME)"
/etc/init.d/$(PKG_NAME) disable
fi
exit 0
endef
$(eval $(call BuildPackage,sniproxy))
#!/bin/sh /etc/rc.common
START=80
APP=sniproxy
SERVICE_WRITE_PID=1
SERVICE_DAEMONIZE=1
start() {
service_start /usr/sbin/$APP
}
stop() {
service_stop /usr/sbin/$APP
}
@rikka0w0
Copy link

It compiles on Openwrt 22.03.2, but when I install the generated package on my Openwrt router (DIR 853 A1, MT7621), it failed with "Segmentation Fault". The configuration that I used was tested on my PC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment