-
Notifications
You must be signed in to change notification settings - Fork 60
/
Makefile
119 lines (104 loc) · 4.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#
# Copyright (C) 2015 wongsyrone
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=pcap-dnsproxy
PKG_VERSION:=0.4.4.2
PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/chengr28/Pcap_DNSProxy.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=a6fdb660e9f185dd16d3c68d6343c1e43bfbab35
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_USE_MIPS16:=0
PKG_MAINTAINER:=Chengr28 <[email protected]>
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
TARGET_CFLAGS += $(FPIC)
CMAKE_OPTIONS += \
-DPLATFORM_OPENWRT=ON \
$(if $(CONFIG_PACKAGE_pcap-dnsproxy_libsodium),-DENABLE_LIBSODIUM=ON,-DENABLE_LIBSODIUM=OFF) \
$(if $(CONFIG_PACKAGE_pcap-dnsproxy_libpcap),-DENABLE_PCAP=ON,-DENABLE_PCAP=OFF)
# Port 53 leads to dnsmasq startup failure.
define Package/pcap-dnsproxy/config
if PACKAGE_pcap-dnsproxy
config PACKAGE_pcap-dnsproxy_libsodium
bool "Build with libsodium support.(Recommanded)"
default y
config PACKAGE_pcap-dnsproxy_libpcap
bool "Build with libpcap support.(Strongly recommanded)"
default y
config PACKAGE_pcap-dnsproxy_KeyPairGenerator
bool "Ship KeyPairGenerator."
default n
config PCAP_DNSPROXY_LISTENPORT
int "Change default Listen Port, can NOT be 53"
default 1053
endif
endef
# Note: GCC 4.6 and 4.8 dont have complete C++11 support
# Please use GCC 4.9 or higher to compile
# uclibcxx is uClibc++, which stands for C++ library for embedded systems.
# libstdcpp is shipped by GCC project, which usually takes more space than uClibc++.
# but it has more useful features we need, i.e. full regular expression support.
define Package/pcap-dnsproxy
SECTION:=net
CATEGORY:=Network
TITLE:=A local DNS server based on LibPcap
URL:=https://github.com/chengr28/Pcap_DNSProxy
DEPENDS:=+libpthread +libstdcpp \
+PACKAGE_pcap-dnsproxy_libpcap:libpcap \
+PACKAGE_pcap-dnsproxy_libsodium:libsodium \
@GCC_VERSION_4_6:BROKEN
endef
define Package/pcap-dnsproxy/conffiles
/etc/pcap-dnsproxy/Config.conf
/etc/pcap-dnsproxy/Hosts.conf
/etc/pcap-dnsproxy/IPFilter.conf
/etc/pcap-dnsproxy/Routing.txt
/etc/pcap-dnsproxy/WhiteList.txt
endef
define Package/pcap-dnsproxy/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Be sure to set configuration file(s) before rebooting your router."
/etc/init.d/pcap-dnsproxy enable
fi
exit 0
endef
# Stop and disable service(removing rc.d symlink) before removing
define Package/pcap-dnsproxy/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Stopping service and removing rc.d symlink for pcap-dnsproxy"
/etc/init.d/pcap-dnsproxy stop
/etc/init.d/pcap-dnsproxy disable
fi
exit 0
endef
define Package/pcap-dnsproxy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(if $(CONFIG_PACKAGE_pcap-dnsproxy_KeyPairGenerator),$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/KeyPairGenerator $(1)/usr/sbin/KeyPairGenerator)
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/Pcap_DNSProxy $(1)/usr/sbin/Pcap_DNSProxy
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/pcap-dnsproxy.config $(1)/etc/config/pcap-dnsproxy
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/pcap-dnsproxy.init $(1)/etc/init.d/pcap-dnsproxy
$(INSTALL_DIR) $(1)/etc/pcap-dnsproxy
$(SED) 's,Listen Port = 53,Listen Port = $(CONFIG_PCAP_DNSPROXY_LISTENPORT),g' $(PKG_BUILD_DIR)/Source/ExampleConfig/Config.ini
$(SED) 's,Log Maximum Size = 8MB,Log Maximum Size = 50KB,g' $(PKG_BUILD_DIR)/Source/ExampleConfig/Config.ini
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/ExampleConfig/Config.ini $(1)/etc/pcap-dnsproxy/Config.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/ExampleConfig/Hosts.ini $(1)/etc/pcap-dnsproxy/Hosts.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/ExampleConfig/IPFilter.ini $(1)/etc/pcap-dnsproxy/IPFilter.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/ExampleConfig/Routing.txt $(1)/etc/pcap-dnsproxy/Routing.txt
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/ExampleConfig/WhiteList.txt $(1)/etc/pcap-dnsproxy/WhiteList.txt
endef
$(eval $(call BuildPackage,pcap-dnsproxy))