diff --git a/UnblockNeteaseMusic-Go/Makefile b/UnblockNeteaseMusic-Go/Makefile deleted file mode 100644 index 0bf6c3180..000000000 --- a/UnblockNeteaseMusic-Go/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -# SPDX-Identifier-License: GPL-3.0-only -# -# Copyright (C) 2021 ImmortalWrt.org - -include $(TOPDIR)/rules.mk - -PKG_NAME:=UnblockNeteaseMusic-Go -PKG_VERSION:=0.2.13 -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://codeload.github.com/cnsilvan/UnblockNeteaseMusic/tar.gz/$(PKG_VERSION)? -PKG_HASH:=skip - -PKG_LICENSE:=GPL-3.0 -PKG_LICENSE_FILE:=LICENSE -PKG_MAINTAINER:=Tianling Shen - -PKG_CONFIG_DEPENDS:= \ - CONFIG_UNBLOCKNETEASEMUSIC_GO_COMPRESS_GOPROXY \ - CONFIG_UNBLOCKNETEASEMUSIC_GO_COMPRESS_UPX - -PKG_BUILD_DIR:=$(BUILD_DIR)/$(firstword $(subst -, ,$(PKG_NAME)))-$(PKG_VERSION) -PKG_BUILD_DEPENDS:=golang/host -PKG_BUILD_PARALLEL:=1 -PKG_USE_MIPS16:=0 - -GO_PKG:=github.com/cnsilvan/UnblockNeteaseMusic -GO_PKG_BUILD_PKG:=$$(GO_PKG) -GO_PKG_LDFLAGS:=-s -w -COMPILE_TIME:= $(shell TZ=UTC-8 date '+%Y-%m-%d %H:%M:%S') -GO_PKG_LDFLAGS+= \ - -X '$(GO_PKG)/version.Version=$(PKG_VERSION)' \ - -X '$(GO_PKG)/version.BuildTime=$(COMPILE_TIME)' \ - -X '$(GO_PKG)/version.ExGoVersionInfo=$(GO_ARM) $(GO_MIPS)$(GO_MIPS64)' - -include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk - -define Package/UnblockNeteaseMusic-Go/config -config UNBLOCKNETEASEMUSIC_GO_COMPRESS_GOPROXY - bool "Compiling with GOPROXY proxy" - default n - -config UNBLOCKNETEASEMUSIC_GO_COMPRESS_UPX - bool "Compress executable files with UPX" - depends on !mips64 - default n -endef - -ifeq ($(CONFIG_UNBLOCKNETEASEMUSIC_GO_COMPRESS_GOPROXY),y) - export GO111MODULE=on - export GOPROXY=https://goproxy.io -endif - -define Package/UnblockNeteaseMusic-Go - SECTION:=multimedia - CATEGORY:=Multimedia - TITLE:=Revive Netease Cloud Music (Golang) - URL:=https://github.com/cnsilvan/UnblockNeteaseMusic - DEPENDS:=$(GO_ARCH_DEPENDS) -endef - -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)/UnblockNeteaseMusic -endif -endef - -define Package/UnblockNeteaseMusic-Go/install - $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) - - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/UnblockNeteaseMusic $(1)/usr/bin/UnblockNeteaseMusic - - $(INSTALL_DIR) $(1)/usr/share/UnblockNeteaseMusicGo - $(CP) ./files/* $(1)/usr/share/UnblockNeteaseMusicGo/ - -endef - -$(eval $(call GoBinPackage,UnblockNeteaseMusic-Go)) -$(eval $(call BuildPackage,UnblockNeteaseMusic-Go)) diff --git a/UnblockNeteaseMusic-Go/files/ca.crt b/UnblockNeteaseMusic-Go/files/ca.crt deleted file mode 100644 index bea3f7b04..000000000 --- a/UnblockNeteaseMusic-Go/files/ca.crt +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICIjCCAaigAwIBAgIUTc9HQDej5hLCQ74u436a5yE4MDcwCgYIKoZIzj0EAwMw -SDELMAkGA1UEBhMCQ04xJDAiBgNVBAMMG1VuYmxvY2tOZXRlYXNlTXVzaWMgUm9v -dCBDQTETMBEGA1UECgwKMTcxNTE3MzMyOTAeFw0yMTA0MzAwNzIzMDJaFw0yNjA0 -MjkwNzIzMDJaMEgxCzAJBgNVBAYTAkNOMSQwIgYDVQQDDBtVbmJsb2NrTmV0ZWFz -ZU11c2ljIFJvb3QgQ0ExEzARBgNVBAoMCjE3MTUxNzMzMjkwdjAQBgcqhkjOPQIB -BgUrgQQAIgNiAASIyI7lYgGlq49qWtY1O2/XNDeowYf7W/Z+l7C14bphxAJ9jSDo -tLwbFPWy5VPENc0rB0/yeHA2z7LU67POL2gGgp+17y7scLkkBk3Q7wRMETrtP44Z -ITBstZ0wzVyyQEKjUzBRMB0GA1UdDgQWBBQ2F7+t8cPHJaWuCD8RHTSdLugKYzAf -BgNVHSMEGDAWgBQ2F7+t8cPHJaWuCD8RHTSdLugKYzAPBgNVHRMBAf8EBTADAQH/ -MAoGCCqGSM49BAMDA2gAMGUCMQDqaRX2e01e0U+f0As/KUKDhmG5ElkK5CjYK9jk -kXLNGFXJLGta6CDvjtMLBPc20qkCMBvDs+JnJKVBEJNZVsRBBs+v2YxNU/u2aYJa -dMwXuFveSDWOS7mBeRztX/geEggiSw== ------END CERTIFICATE----- diff --git a/UnblockNeteaseMusic-Go/files/server.crt b/UnblockNeteaseMusic-Go/files/server.crt deleted file mode 100644 index 73e2fa6ec..000000000 --- a/UnblockNeteaseMusic-Go/files/server.crt +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICRDCCAcqgAwIBAgIUeVqRrT2mHG5Mc8JD+ErphiAmlgkwCgYIKoZIzj0EAwMw -SDELMAkGA1UEBhMCQ04xJDAiBgNVBAMMG1VuYmxvY2tOZXRlYXNlTXVzaWMgUm9v -dCBDQTETMBEGA1UECgwKMTcxNTE3MzMyOTAeFw0yMTA0MzAwNzIzMDJaFw0yMjA0 -MzAwNzIzMDJaMHsxCzAJBgNVBAYTAkNOMREwDwYDVQQHDAhIYW5nemhvdTEsMCoG -A1UECgwjTmV0RWFzZSAoSGFuZ3pob3UpIE5ldHdvcmsgQ28uLCBMdGQxETAPBgNV -BAsMCElUIERlcHQuMRgwFgYDVQQDDA8qLm11c2ljLjE2My5jb20wdjAQBgcqhkjO -PQIBBgUrgQQAIgNiAAQTPyU9RQ1pAFMLmozi+c4pEC1rrxAlPGwO9Em+qV+a5qLW -gQjjsJeabMqJ/UQ7hDtdKVxWuXiAjMiDcXwL63I71MZKPTAEKXdCmNQwb4kXvRUn -oOR4r7BMxEpGlf0CULWjQjBAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMCkGA1UdEQQi -MCCCDW11c2ljLjE2My5jb22CDyoubXVzaWMuMTYzLmNvbTAKBggqhkjOPQQDAwNo -ADBlAjEAs5bdgnNP/DiK919RiWscC0kyuY0ugG1C8m8F2Yod4MI3oTyrkVcag21o -NSzm802uAjBoPuKEbjjFP4ics0BQdICiVd6WCVAsE69FnlmqRteAJqxvdKGpVLi+ -Qi3arfomrrc= ------END CERTIFICATE----- diff --git a/UnblockNeteaseMusic-Go/files/server.key b/UnblockNeteaseMusic-Go/files/server.key deleted file mode 100644 index 6bd769c11..000000000 --- a/UnblockNeteaseMusic-Go/files/server.key +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN EC PARAMETERS----- -BgUrgQQAIg== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MIGkAgEBBDBfW3twxGaQmMzP9p0/UU5EvHFVCbBw4piVFJ+pm/uFY6CKZkC5LGMa -Uc9vn/KiewGgBwYFK4EEACKhZANiAAQTPyU9RQ1pAFMLmozi+c4pEC1rrxAlPGwO -9Em+qV+a5qLWgQjjsJeabMqJ/UQ7hDtdKVxWuXiAjMiDcXwL63I71MZKPTAEKXdC -mNQwb4kXvRUnoOR4r7BMxEpGlf0CULU= ------END EC PRIVATE KEY----- \ No newline at end of file diff --git a/UnblockNeteaseMusic/Makefile b/UnblockNeteaseMusic/Makefile deleted file mode 100644 index aa2babc55..000000000 --- a/UnblockNeteaseMusic/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# SPDX-Identifier-License: GPL-3.0-only -# -# Copyright (C) 2021 ImmortalWrt.org - -include $(TOPDIR)/rules.mk - -PKG_NAME:=UnblockNeteaseMusic -PKG_BASE_VERSION:=0.27.0-rc.4 -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/UnblockNeteaseMusic/server.git -PKG_SOURCE_DATE:=2021-12-21 -PKG_SOURCE_VERSION:=54b7a60b07a85dea3b52a5d9f1ada456aba12609 -PKG_MIRROR_HASH:=skip - -PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION)) - -PKG_LICENSE:=LGPL-3.0-only -PKG_LICENSE_FILE:=LICENSE -PKG_MAINTAINER:=Tianling Shen - -include $(INCLUDE_DIR)/package.mk - -define Package/UnblockNeteaseMusic - SECTION:=multimedia - CATEGORY:=Multimedia - TITLE:=Revive Netease Cloud Music (NodeJS) - URL:=https://github.com/nondanee/UnblockNeteaseMusic - DEPENDS:=+node - PKGARCH:=all -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - xzcat $(DL_DIR)/$(PKG_SOURCE) | $(TAR) -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Build/Configure - echo -e $(PKG_BASE_VERSION) > $(PKG_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/core_ver - echo -e $(PKG_SOURCE_VERSION) > $(PKG_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/local_ver -endef - -define Build/Compile -endef - -define Package/UnblockNeteaseMusic/install - $(INSTALL_DIR) $(1)/usr/share/UnblockNeteaseMusic - $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/* $(1)/usr/share/UnblockNeteaseMusic -endef - -$(eval $(call BuildPackage,UnblockNeteaseMusic)) diff --git a/amule/Makefile b/amule/Makefile deleted file mode 100644 index 5d555c41d..000000000 --- a/amule/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -# -# Copyright (C) 2007-2009 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=aMule -PKG_VERSION:=2.3.3 -PKG_RELEASE:=3 -PKG_REV=4b87b20 - - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REV).tar.bz2 -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=$(PKG_REV) -PKG_SOURCE_URL:=https://github.com/amule-project/amule.git -PKG_MIRROR_HASH:=skip - -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) -PKG_BUILD_DEPENDS:=libgd libcryptopp - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/nls.mk - -define Package/amule/config -config AMULE_CRYPTOPP_STATIC_LINKING - bool "Link libcryptopp statically" - default n -endef - -define Package/amule - SUBMENU:=P2P - SECTION:=net - CATEGORY:=Network - TITLE:=A multi-platform eMule-like ed2k client - URL:=http://www.amule.org/ - DEPENDS:=+libpng +libpthread +libncurses +libreadline +libwxbase +libupnp +libbfd \ - $(ICONV_DEPENDS) $(INTL_DEPENDS) +!AMULE_CRYPTOPP_STATIC_LINKING:libcryptopp -endef - -CONFIGURE_ARGS+= \ - --disable-static \ - --disable-rpath \ - --with-gnu-ld \ - --disable-ccache \ - --disable-optimize \ - --disable-profile \ - --disable-monolithic \ - --enable-amule-daemon \ - --enable-amulecmd \ - --enable-webserver \ - --disable-amule-gui \ - --disable-cas \ - --disable-wxcas \ - --disable-ed2k \ - --disable-alc \ - --disable-alcc \ - --disable-fileview \ - --disable-plasmamule \ - --without-wxdebug \ - --enable-dlp \ - --enable-upnp \ - --with-zlib="$(STAGING_DIR)/usr" \ - --with-gdlib-prefix="$(STAGING_DIR)/usr" \ - --with-libpng-prefix="$(STAGING_DIR)/usr" \ - --with-wx-prefix="$(STAGING_DIR)/usr" \ - --with-crypto-prefix="$(STAGING_DIR)/usr" \ - --with-libiconv-prefix="$(ICONV_PREFIX)" \ - --with-libintl-prefix="$(INTL_PREFIX)" \ - --with-libupnp-prefix="$(STAGING_DIR)/usr" \ - --without-x \ - --disable-debug - -TARGET_LDFLAGS += -liconv - - -define Build/Configure - cd $(PKG_BUILD_DIR) && sh ./autogen.sh - $(call Build/Configure/Default) -endef - -ifeq ($(CONFIG_AMULE_CRYPTOPP_STATIC_LINKING),y) - SED_CMD:=sed -else - SED_CMD:=true -endif - -define Build/Compile - $(SED_CMD) -i 's;^CRYPTOPP_LIBS.*;CRYPTOPP_LIBS \= "$(STAGING_DIR)/usr/lib/libcryptopp.a";g' \ - $(PKG_BUILD_DIR)/src/Makefile - $(MAKE) -C $(PKG_BUILD_DIR) \ - HOSTCC="$(HOSTCC)" \ - DESTDIR="$(PKG_INSTALL_DIR)" \ - all -endef - -define Package/amule/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_DIR) $(1)/usr/share/amule/webserver - $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/amule{cmd,d} $(1)/usr/bin/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/webserver/src/amuleweb $(1)/usr/bin/ - $(CP) $(PKG_BUILD_DIR)/src/webserver/default $(1)/usr/share/amule/webserver - -endef - -$(eval $(call BuildPackage,amule)) diff --git a/amule/patches/0001-fix-API-mismatch-with-crypto-6.0.0.patch b/amule/patches/0001-fix-API-mismatch-with-crypto-6.0.0.patch deleted file mode 100644 index 84f64f8b9..000000000 --- a/amule/patches/0001-fix-API-mismatch-with-crypto-6.0.0.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 46ecaeadff4c07b8fd98cf41e27605895328ce0a Mon Sep 17 00:00:00 2001 -From: W_Y_CPP <383152993@qq.com> -Date: Thu, 2 Dec 2021 00:46:12 -0800 -Subject: [PATCH] fix API mismatch with crypto++ 6.0.0 - ---- - src/ClientCreditsList.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp -index d61e8d4..b02e162 100644 ---- a/src/ClientCreditsList.cpp -+++ b/src/ClientCreditsList.cpp -@@ -312,7 +312,7 @@ void CClientCreditsList::InitalizeCrypting() - // calculate and store public key - CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(*static_cast(m_pSignkey)); - CryptoPP::ArraySink asink(m_abyMyPublicKey, 80); -- pubkey.DEREncode(asink); -+ pubkey.GetMaterial().Save(asink); - m_nMyPublicKeyLen = asink.TotalPutLength(); - asink.MessageEnd(); - } catch (const CryptoPP::Exception& e) { --- -2.17.1 - diff --git a/amule/patches/0002-fix-byte-type-error.patch b/amule/patches/0002-fix-byte-type-error.patch deleted file mode 100644 index da60d22ac..000000000 --- a/amule/patches/0002-fix-byte-type-error.patch +++ /dev/null @@ -1,2285 +0,0 @@ -From 3817cad41242b0cf376e6e69da22f32ae8f32355 Mon Sep 17 00:00:00 2001 -From: W_Y_CPP <383152993@qq.com> -Date: Thu, 2 Dec 2021 00:51:00 -0800 -Subject: [PATCH] fix byte type error - ---- - src/BarShader.cpp | 2 +- - src/BaseClient.cpp | 28 +++++++++--------- - src/BitVector.h | 2 +- - src/ClientCredits.cpp | 4 +-- - src/ClientCredits.h | 8 +++--- - src/ClientCreditsList.cpp | 14 ++++----- - src/ClientCreditsList.h | 8 +++--- - src/ClientList.cpp | 2 +- - src/ClientTCPSocket.cpp | 8 +++--- - src/ClientTCPSocket.h | 6 ++-- - src/ClientUDPSocket.cpp | 4 +-- - src/ClientUDPSocket.h | 4 +-- - src/DownloadClient.cpp | 18 ++++++------ - src/DownloadQueue.cpp | 8 +++--- - src/EMSocket.cpp | 6 ++-- - src/EMSocket.h | 6 ++-- - src/EncryptedDatagramSocket.cpp | 10 +++---- - src/EncryptedStreamSocket.cpp | 10 +++---- - src/FileArea.cpp | 10 +++---- - src/FileArea.h | 8 +++--- - src/FileLock.h | 2 +- - src/GapList.h | 2 +- - src/IPFilterScanner.cpp | 2 +- - src/KnownFile.cpp | 12 ++++---- - src/KnownFile.h | 2 +- - src/MemFile.cpp | 8 +++--- - src/MemFile.h | 10 +++---- - src/MuleCollection.cpp | 2 +- - src/MuleColour.h | 18 ++++++------ - src/MuleUDPSocket.cpp | 2 +- - src/MuleUDPSocket.h | 2 +- - src/OtherFunctions.cpp | 32 ++++++++++----------- - src/Packet.cpp | 36 ++++++++++++------------ - src/Packet.h | 26 ++++++++--------- - src/Parser.cpp | 2 +- - src/PartFile.cpp | 6 ++-- - src/PartFile.h | 2 +- - src/PartFileConvert.cpp | 2 +- - src/PrefsUnifiedDlg.cpp | 2 +- - src/RLE.cpp | 4 +-- - src/SHA.cpp | 18 ++++++------ - src/SHA.h | 4 +-- - src/SHAHashSet.h | 8 +++--- - src/SafeFile.cpp | 2 +- - src/Scanner.cpp | 2 +- - src/SearchList.cpp | 4 +-- - src/SearchList.h | 2 +- - src/ServerList.cpp | 4 +-- - src/ServerSocket.cpp | 2 +- - src/ServerSocket.h | 2 +- - src/ServerUDPSocket.cpp | 10 +++---- - src/ServerUDPSocket.h | 2 +- - src/Statistics.cpp | 2 +- - src/Tag.cpp | 4 +-- - src/Tag.h | 12 ++++---- - src/ThreadTasks.cpp | 4 +-- - src/UploadBandwidthThrottler.cpp | 2 +- - src/UploadClient.cpp | 10 +++---- - src/kademlia/kademlia/Kademlia.cpp | 2 +- - src/kademlia/kademlia/Search.cpp | 2 +- - src/kademlia/kademlia/SearchManager.cpp | 4 +-- - src/kademlia/net/KademliaUDPListener.cpp | 2 +- - src/libs/common/StringFunctions.cpp | 4 +-- - src/libs/ec/cpp/ECSocket.cpp | 12 ++++---- - src/libs/ec/cpp/ECTag.cpp | 4 +-- - src/updownclient.h | 36 ++++++++++++------------ - src/utils/aLinkCreator/src/md4.cpp | 8 +++--- - src/utils/aLinkCreator/src/md4.h | 2 +- - src/utils/fileview/KadFiles.cpp | 4 +-- - 69 files changed, 257 insertions(+), 257 deletions(-) - -diff --git a/src/BarShader.cpp b/src/BarShader.cpp -index 047f90d..9ddfd51 100644 ---- a/src/BarShader.cpp -+++ b/src/BarShader.cpp -@@ -124,7 +124,7 @@ void CBarShader::FillRange(uint64 start, uint64 end, const CMuleColour& colour) - } - - // precision for small files: end must be increased by one -- // think of each byte as a visible block, then start points to -+ // think of each uint8_t as a visible block, then start points to - // the beginning of its block, but end points to the END of its block - end++; - -diff --git a/src/BaseClient.cpp b/src/BaseClient.cpp -index cf1093a..aa77e69 100644 ---- a/src/BaseClient.cpp -+++ b/src/BaseClient.cpp -@@ -361,7 +361,7 @@ void CUpDownClient::ClearHelloProperties() - m_bUnicodeSupport = false; - } - --bool CUpDownClient::ProcessHelloPacket(const byte* pachPacket, uint32 nSize) -+bool CUpDownClient::ProcessHelloPacket(const uint8_t* pachPacket, uint32 nSize) - { - const CMemFile data(pachPacket,nSize); - uint8 hashsize = data.ReadUInt8(); -@@ -459,7 +459,7 @@ void CUpDownClient::Safe_Delete() - } - - --bool CUpDownClient::ProcessHelloAnswer(const byte* pachPacket, uint32 nSize) -+bool CUpDownClient::ProcessHelloAnswer(const uint8_t* pachPacket, uint32 nSize) - { - const CMemFile data(pachPacket,nSize); - bool bIsMule = ProcessHelloTypePacket(data); -@@ -840,7 +840,7 @@ void CUpDownClient::SendMuleInfoPacket(bool bAnswer, bool OSInfo) - } - } - --bool CUpDownClient::ProcessMuleInfoPacket(const byte* pachPacket, uint32 nSize) -+bool CUpDownClient::ProcessMuleInfoPacket(const uint8_t* pachPacket, uint32 nSize) - { - uint8 protocol_version; - -@@ -1173,7 +1173,7 @@ void CUpDownClient::SendHelloTypePacket(CMemFile* data) - } - - --void CUpDownClient::ProcessMuleCommentPacket(const byte* pachPacket, uint32 nSize) -+void CUpDownClient::ProcessMuleCommentPacket(const uint8_t* pachPacket, uint32 nSize) - { - if (!m_reqfile) { - throw CInvalidPacket(wxT("Comment packet for unknown file")); -@@ -1977,7 +1977,7 @@ void CUpDownClient::RequestSharedFileList() - } - - --void CUpDownClient::ProcessSharedFileList(const byte* pachPacket, uint32 nSize, wxString& pszDirectory) -+void CUpDownClient::ProcessSharedFileList(const uint8_t* pachPacket, uint32 nSize, wxString& pszDirectory) - { - if (m_iFileListRequested > 0) { - m_iFileListRequested--; -@@ -2103,7 +2103,7 @@ void CUpDownClient::SendSignaturePacket() - } - } - //end v2 -- byte achBuffer[250]; -+ uint8_t achBuffer[250]; - - uint8 siglen = theApp->clientcredits->CreateSignature(credits, achBuffer, 250, ChallengeIP, byChaIPKind ); - wxCHECK2(siglen != 0, return); -@@ -2124,7 +2124,7 @@ void CUpDownClient::SendSignaturePacket() - } - - --void CUpDownClient::ProcessPublicKeyPacket(const byte* pachPacket, uint32 nSize) -+void CUpDownClient::ProcessPublicKeyPacket(const uint8_t* pachPacket, uint32 nSize) - { - theApp->clientlist->AddTrackClient(this); - -@@ -2160,7 +2160,7 @@ void CUpDownClient::ProcessPublicKeyPacket(const byte* pachPacket, uint32 nSize) - } - - --void CUpDownClient::ProcessSignaturePacket(const byte* pachPacket, uint32 nSize) -+void CUpDownClient::ProcessSignaturePacket(const uint8_t* pachPacket, uint32 nSize) - { - // here we spread the good guys from the bad ones ;) - -@@ -2248,7 +2248,7 @@ void CUpDownClient::SendSecIdentStatePacket() - } - - --void CUpDownClient::ProcessSecIdentStatePacket(const byte* pachPacket, uint32 nSize) -+void CUpDownClient::ProcessSecIdentStatePacket(const uint8_t* pachPacket, uint32 nSize) - { - if ( nSize != 5 ) { - return; -@@ -2344,7 +2344,7 @@ void CUpDownClient::SendPublicIPRequest() - } - } - --void CUpDownClient::ProcessPublicIPAnswer(const byte* pbyData, uint32 uSize) -+void CUpDownClient::ProcessPublicIPAnswer(const uint8_t* pbyData, uint32 uSize) - { - if (uSize != 4) { - throw wxString(wxT("Wrong Packet size on Public IP answer")); -@@ -2527,7 +2527,7 @@ bool CUpDownClient::SendChatMessage(const wxString& message) - - /* Kad stuff */ - --void CUpDownClient::SetBuddyID(const byte* pucBuddyID) -+void CUpDownClient::SetBuddyID(const uint8_t* pucBuddyID) - { - if( pucBuddyID == NULL ){ - md4clr(m_achBuddyID); -@@ -2722,7 +2722,7 @@ void CUpDownClient::ProcessChatMessage(wxString message) - m_strCaptchaChallenge = captcha.GetCaptchaText(); - m_nChatCaptchaState = CA_CHALLENGESENT; - m_cCaptchasSent++; -- CMemFile fileAnswer((byte*) memstr.GetOutputStreamBuffer()->GetBufferStart(), memstr.GetLength()); -+ CMemFile fileAnswer((uint8_t*) memstr.GetOutputStreamBuffer()->GetBufferStart(), memstr.GetLength()); - CPacket* packet = new CPacket(fileAnswer, OP_EMULEPROT, OP_CHATCAPTCHAREQ); - theStats::AddUpOverheadOther(packet->GetPacketSize()); - AddLogLineN(CFormat(wxT("sent Captcha %s (%d)")) % m_strCaptchaChallenge % packet->GetPacketSize()); -@@ -2756,7 +2756,7 @@ void CUpDownClient::ProcessChatMessage(wxString message) - m_cCaptchasSent = 0; - m_strCaptchaChallenge.Clear(); - CPacket* packet = new CPacket(OP_CHATCAPTCHARES, 1, OP_EMULEPROT, false); -- byte statusResponse = 0; // status response -+ uint8_t statusResponse = 0; // status response - packet->CopyToDataBuffer(0, &statusResponse, 1); - theStats::AddUpOverheadOther(packet->GetPacketSize()); - SafeSendPacket(packet); -@@ -2766,7 +2766,7 @@ void CUpDownClient::ProcessChatMessage(wxString message) - m_strCaptchaChallenge.Clear(); - m_strCaptchaPendingMsg.Clear(); - CPacket* packet = new CPacket(OP_CHATCAPTCHARES, 1, OP_EMULEPROT, false); -- byte statusResponse = (m_cCaptchasSent < 3) ? 1 : 2; // status response -+ uint8_t statusResponse = (m_cCaptchasSent < 3) ? 1 : 2; // status response - packet->CopyToDataBuffer(0, &statusResponse, 1); - theStats::AddUpOverheadOther(packet->GetPacketSize()); - SafeSendPacket(packet); -diff --git a/src/BitVector.h b/src/BitVector.h -index 9576a11..f4f2474 100644 ---- a/src/BitVector.h -+++ b/src/BitVector.h -@@ -113,7 +113,7 @@ public: - bool foundFalse = false; - uint32 lastByte = m_bytes; - if (m_bits & 7) { -- // uneven: check bits of last byte individually -+ // uneven: check bits of last uint8_t individually - lastByte--; - for (uint32 i = m_bits & 0xfffffff8; !foundFalse && i < m_bits; i++) { - foundFalse = !get(i); -diff --git a/src/ClientCredits.cpp b/src/ClientCredits.cpp -index 2804292..6439ac8 100644 ---- a/src/ClientCredits.cpp -+++ b/src/ClientCredits.cpp -@@ -195,7 +195,7 @@ void CClientCredits::Verified(uint32 dwForIP) - memcpy(m_pCredits->abySecureIdent, m_abyPublicKey, m_nPublicKeyLen); - if (GetDownloadedTotal() > 0){ - // for security reason, we have to delete all prior credits here -- // in order to save this client, set 1 byte -+ // in order to save this client, set 1 uint8_t - m_pCredits->downloaded = 1; - m_pCredits->uploaded = 1; - AddDebugLogLineN( logCredits, wxT("Credits deleted due to new SecureIdent") ); -@@ -205,7 +205,7 @@ void CClientCredits::Verified(uint32 dwForIP) - } - - --bool CClientCredits::SetSecureIdent(const byte* pachIdent, uint8 nIdentLen) -+bool CClientCredits::SetSecureIdent(const uint8_t* pachIdent, uint8 nIdentLen) - { // verified Public key cannot change, use only if there is not public key yet - if (MAXPUBKEYSIZE < nIdentLen || m_pCredits->nKeySize != 0 ) { - return false; -diff --git a/src/ClientCredits.h b/src/ClientCredits.h -index ae194c2..b89f7c5 100644 ---- a/src/ClientCredits.h -+++ b/src/ClientCredits.h -@@ -45,7 +45,7 @@ public: - uint32 nLastSeen; - uint16 nReserved3; - uint8 nKeySize; -- byte abySecureIdent[MAXPUBKEYSIZE]; -+ uint8_t abySecureIdent[MAXPUBKEYSIZE]; - }; - - enum EIdentState{ -@@ -65,7 +65,7 @@ public: - ~CClientCredits(); - - const CMD4Hash& GetKey() const {return m_pCredits->key;} -- const byte* GetSecureIdent() const {return m_abyPublicKey;} -+ const uint8_t* GetSecureIdent() const {return m_abyPublicKey;} - uint8 GetSecIDKeyLen() const {return m_nPublicKeyLen;} - const CreditStruct* GetDataStruct() const {return m_pCredits;} - void ClearWaitStartTime(); -@@ -75,7 +75,7 @@ public: - uint64 GetDownloadedTotal() const; - float GetScoreRatio(uint32 dwForIP, bool cryptoavail); - void SetLastSeen(); -- bool SetSecureIdent(const byte* pachIdent, uint8 nIdentLen); // Public key cannot change, use only if there is not public key yet -+ bool SetSecureIdent(const uint8_t* pachIdent, uint8 nIdentLen); // Public key cannot change, use only if there is not public key yet - uint32 m_dwCryptRndChallengeFor; - uint32 m_dwCryptRndChallengeFrom; - EIdentState GetCurrentIdentState(uint32 dwForIP) const; // can be != m_identState -@@ -89,7 +89,7 @@ private: - EIdentState m_identState; - void InitalizeIdent(); - CreditStruct* m_pCredits; -- byte m_abyPublicKey[80]; // even keys which are not verified will be stored here, and - if verified - copied into the struct -+ uint8_t m_abyPublicKey[80]; // even keys which are not verified will be stored here, and - if verified - copied into the struct - uint8 m_nPublicKeyLen; - uint32 m_dwIdentIP; - uint32 m_dwSecureWaitTime; -diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp -index 3bea9fe..d61e8d4 100644 ---- a/src/ClientCreditsList.cpp -+++ b/src/ClientCreditsList.cpp -@@ -326,7 +326,7 @@ void CClientCreditsList::InitalizeCrypting() - } - - --uint8 CClientCreditsList::CreateSignature(CClientCredits* pTarget, byte* pachOutput, uint8 nMaxSize, uint32 ChallengeIP, uint8 byChaIPKind, void* sigkey) -+uint8 CClientCreditsList::CreateSignature(CClientCredits* pTarget, uint8_t* pachOutput, uint8 nMaxSize, uint32 ChallengeIP, uint8 byChaIPKind, void* sigkey) - { - CryptoPP::RSASSA_PKCS1v15_SHA_Signer* signer = - static_cast(sigkey); -@@ -345,7 +345,7 @@ uint8 CClientCreditsList::CreateSignature(CClientCredits* pTarget, byte* pachOut - try { - CryptoPP::SecByteBlock sbbSignature(signer->SignatureLength()); - CryptoPP::AutoSeededX917RNG rng; -- byte abyBuffer[MAXPUBKEYSIZE+9]; -+ uint8_t abyBuffer[MAXPUBKEYSIZE+9]; - uint32 keylen = pTarget->GetSecIDKeyLen(); - memcpy(abyBuffer,pTarget->GetSecureIdent(),keylen); - // 4 additional bytes random data send from this client -@@ -373,7 +373,7 @@ uint8 CClientCreditsList::CreateSignature(CClientCredits* pTarget, byte* pachOut - } - - --bool CClientCreditsList::VerifyIdent(CClientCredits* pTarget, const byte* pachSignature, uint8 nInputSize, uint32 dwForIP, uint8 byChaIPKind) -+bool CClientCreditsList::VerifyIdent(CClientCredits* pTarget, const uint8_t* pachSignature, uint8 nInputSize, uint32 dwForIP, uint8 byChaIPKind) - { - wxASSERT( pTarget ); - wxASSERT( pachSignature ); -@@ -383,10 +383,10 @@ bool CClientCreditsList::VerifyIdent(CClientCredits* pTarget, const byte* pachSi - } - bool bResult; - try { -- CryptoPP::StringSource ss_Pubkey((byte*)pTarget->GetSecureIdent(),pTarget->GetSecIDKeyLen(),true,0); -+ CryptoPP::StringSource ss_Pubkey((uint8_t*)pTarget->GetSecureIdent(),pTarget->GetSecIDKeyLen(),true,0); - CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(ss_Pubkey); - // 4 additional bytes random data send from this client +5 bytes v2 -- byte abyBuffer[MAXPUBKEYSIZE+9]; -+ uint8_t abyBuffer[MAXPUBKEYSIZE+9]; - memcpy(abyBuffer,m_abyMyPublicKey,m_nMyPublicKeyLen); - uint32 challenge = pTarget->m_dwCryptRndChallengeFor; - wxASSERT ( challenge != 0 ); -@@ -455,7 +455,7 @@ bool CClientCreditsList::Debug_CheckCrypting(){ - CryptoPP::RSASSA_PKCS1v15_SHA_Signer priv(rng, 384); - CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pub(priv); - -- byte abyPublicKey[80]; -+ uint8_t abyPublicKey[80]; - CryptoPP::ArraySink asink(abyPublicKey, 80); - pub.DEREncode(asink); - int8 PublicKeyLen = asink.TotalPutLength(); -@@ -467,7 +467,7 @@ bool CClientCreditsList::Debug_CheckCrypting(){ - newcredits.SetSecureIdent(m_abyMyPublicKey,m_nMyPublicKeyLen); - newcredits.m_dwCryptRndChallengeFrom = challenge; - // create signature with fake priv key -- byte pachSignature[200]; -+ uint8_t pachSignature[200]; - memset(pachSignature,0,200); - uint8 sigsize = CreateSignature(&newcredits,pachSignature,200,0,false, &priv); - -diff --git a/src/ClientCreditsList.h b/src/ClientCreditsList.h -index 3b3aa6c..70b3c31 100644 ---- a/src/ClientCreditsList.h -+++ b/src/ClientCreditsList.h -@@ -39,13 +39,13 @@ public: - ~CClientCreditsList(); - - // return signature size, 0 = Failed | use sigkey param for debug only -- uint8 CreateSignature(CClientCredits* pTarget, byte* pachOutput, uint8 nMaxSize, uint32 ChallengeIP, uint8 byChaIPKind, void* sigkey = NULL); -- bool VerifyIdent(CClientCredits* pTarget, const byte* pachSignature, uint8 nInputSize, uint32 dwForIP, uint8 byChaIPKind); -+ uint8 CreateSignature(CClientCredits* pTarget, uint8_t* pachOutput, uint8 nMaxSize, uint32 ChallengeIP, uint8 byChaIPKind, void* sigkey = NULL); -+ bool VerifyIdent(CClientCredits* pTarget, const uint8_t* pachSignature, uint8 nInputSize, uint32 dwForIP, uint8 byChaIPKind); - - CClientCredits* GetCredit(const CMD4Hash& key); - void Process(); - uint8 GetPubKeyLen() const {return m_nMyPublicKeyLen;} -- const byte* GetPublicKey() const {return m_abyMyPublicKey;} -+ const uint8_t* GetPublicKey() const {return m_abyMyPublicKey;} - bool CryptoAvailable() const; - void SaveList(); - protected: -@@ -61,7 +61,7 @@ private: - uint32 m_nLastSaved; - // A void* to avoid having to include the large CryptoPP.h file - void* m_pSignkey; -- byte m_abyMyPublicKey[80]; -+ uint8_t m_abyMyPublicKey[80]; - uint8 m_nMyPublicKeyLen; - }; - -diff --git a/src/ClientList.cpp b/src/ClientList.cpp -index f26cce4..9b8b7ec 100644 ---- a/src/ClientList.cpp -+++ b/src/ClientList.cpp -@@ -923,7 +923,7 @@ bool CClientList::IncomingBuddy(Kademlia::CContact* contact, Kademlia::CUInt128* - CUpDownClient* pNewClient = new CUpDownClient(contact->GetTCPPort(), contact->GetIPAddress(), 0, 0, NULL, false, true ); - pNewClient->SetKadPort(contact->GetUDPPort()); - pNewClient->SetKadState(KS_INCOMING_BUDDY); -- byte ID[16]; -+ uint8_t ID[16]; - contact->GetClientID().ToByteArray(ID); - pNewClient->SetUserHash(CMD4Hash(ID)); - buddyID->ToByteArray(ID); -diff --git a/src/ClientTCPSocket.cpp b/src/ClientTCPSocket.cpp -index 73e5d21..ccd6016 100644 ---- a/src/ClientTCPSocket.cpp -+++ b/src/ClientTCPSocket.cpp -@@ -298,7 +298,7 @@ void CClientTCPSocket::Safe_Delete_Client() - } - - --bool CClientTCPSocket::ProcessPacket(const byte* buffer, uint32 size, uint8 opcode) -+bool CClientTCPSocket::ProcessPacket(const uint8_t* buffer, uint32 size, uint8 opcode) - { - #ifdef __PACKET_RECV_DUMP__ - //printf("Rec: OPCODE %x \n",opcode); -@@ -1016,7 +1016,7 @@ bool CClientTCPSocket::ProcessPacket(const byte* buffer, uint32 size, uint8 opco - } - - --bool CClientTCPSocket::ProcessExtPacket(const byte* buffer, uint32 size, uint8 opcode) -+bool CClientTCPSocket::ProcessExtPacket(const uint8_t* buffer, uint32 size, uint8 opcode) - { - #ifdef __PACKET_RECV_DUMP__ - //printf("Rec: OPCODE %x \n",opcode); -@@ -1637,7 +1637,7 @@ bool CClientTCPSocket::ProcessExtPacket(const byte* buffer, uint32 size, uint8 o - break; - } - CUInt128 fileid = data.ReadUInt128(); -- byte fileid2[16]; -+ uint8_t fileid2[16]; - fileid.ToByteArray(fileid2); - const CMD4Hash fileHash(fileid2); - if (theApp->sharedfiles->GetFileByID(fileHash) == NULL) { -@@ -1816,7 +1816,7 @@ bool CClientTCPSocket::ProcessExtPacket(const byte* buffer, uint32 size, uint8 o - return true; - } - --bool CClientTCPSocket::ProcessED2Kv2Packet(const byte* buffer, uint32 size, uint8 opcode) -+bool CClientTCPSocket::ProcessED2Kv2Packet(const uint8_t* buffer, uint32 size, uint8 opcode) - { - #ifdef __PACKET_RECV_DUMP__ - //printf("Rec: OPCODE %x ED2Kv2\n",opcode); -diff --git a/src/ClientTCPSocket.h b/src/ClientTCPSocket.h -index ba65265..5476663 100644 ---- a/src/ClientTCPSocket.h -+++ b/src/ClientTCPSocket.h -@@ -78,9 +78,9 @@ protected: - private: - CUpDownClient* m_client; - -- bool ProcessPacket(const byte* packet, uint32 size, uint8 opcode); -- bool ProcessExtPacket(const byte* packet, uint32 size, uint8 opcode); -- bool ProcessED2Kv2Packet(const byte* packet, uint32 size, uint8 opcode); -+ bool ProcessPacket(const uint8_t* packet, uint32 size, uint8 opcode); -+ bool ProcessExtPacket(const uint8_t* packet, uint32 size, uint8 opcode); -+ bool ProcessED2Kv2Packet(const uint8_t* packet, uint32 size, uint8 opcode); - void ResetTimeOutTimer(); - void SetClient(CUpDownClient* client); - -diff --git a/src/ClientUDPSocket.cpp b/src/ClientUDPSocket.cpp -index 924363a..0619304 100644 ---- a/src/ClientUDPSocket.cpp -+++ b/src/ClientUDPSocket.cpp -@@ -75,7 +75,7 @@ void CClientUDPSocket::OnReceive(int errorCode) - } - - --void CClientUDPSocket::OnPacketReceived(uint32 ip, uint16 port, byte* buffer, size_t length) -+void CClientUDPSocket::OnPacketReceived(uint32 ip, uint16 port, uint8_t* buffer, size_t length) - { - wxCHECK_RET(length >= 2, wxT("Invalid packet.")); - -@@ -137,7 +137,7 @@ void CClientUDPSocket::OnPacketReceived(uint32 ip, uint16 port, byte* buffer, si - } - - --void CClientUDPSocket::ProcessPacket(byte* packet, int16 size, int8 opcode, uint32 host, uint16 port) -+void CClientUDPSocket::ProcessPacket(uint8_t* packet, int16 size, int8 opcode, uint32 host, uint16 port) - { - switch (opcode) { - case OP_REASKCALLBACKUDP: { -diff --git a/src/ClientUDPSocket.h b/src/ClientUDPSocket.h -index 162acaa..d894a32 100644 ---- a/src/ClientUDPSocket.h -+++ b/src/ClientUDPSocket.h -@@ -37,8 +37,8 @@ protected: - void OnReceive(int errorCode); - - private: -- void OnPacketReceived(uint32 ip, uint16 port, byte* buffer, size_t length); -- void ProcessPacket(byte* packet, int16 size, int8 opcode, uint32 host, uint16 port); -+ void OnPacketReceived(uint32 ip, uint16 port, uint8_t* buffer, size_t length); -+ void ProcessPacket(uint8_t* packet, int16 size, int8 opcode, uint32 host, uint16 port); - }; - - #endif // CLIENTUDPSOCKET_H -diff --git a/src/DownloadClient.cpp b/src/DownloadClient.cpp -index c364f74..37f81a8 100644 ---- a/src/DownloadClient.cpp -+++ b/src/DownloadClient.cpp -@@ -568,7 +568,7 @@ void CUpDownClient::SetDownloadState(uint8 byNewState) - } - /* eMule 0.30c implementation, i give it a try (Creteil) END ... */ - --void CUpDownClient::ProcessHashSet(const byte* packet, uint32 size) -+void CUpDownClient::ProcessHashSet(const uint8_t* packet, uint32 size) - { - if ((!m_reqfile) || md4cmp(packet,m_reqfile->GetFileHash().GetHash())) { - throw wxString(wxT("Wrong fileid sent (ProcessHashSet)")); -@@ -830,7 +830,7 @@ The requests will still not exceed 180k, but may be smaller to - fill a gap. - */ - --void CUpDownClient::ProcessBlockPacket(const byte* packet, uint32 size, bool packed, bool largeblocks) -+void CUpDownClient::ProcessBlockPacket(const uint8_t* packet, uint32 size, bool packed, bool largeblocks) - { - // Ignore if no data required - if (!(GetDownloadState() == DS_DOWNLOADING || GetDownloadState() == DS_NONEEDEDPARTS)) { -@@ -930,7 +930,7 @@ void CUpDownClient::ProcessBlockPacket(const byte* packet, uint32 size, bool pac - return; - } - // Write to disk (will be buffered in part file class) -- lenWritten = m_reqfile->WriteToBuffer( size - header_size, (byte*)(packet + header_size), nStartPos, nEndPos, cur_block->block, this); -+ lenWritten = m_reqfile->WriteToBuffer( size - header_size, (uint8_t*)(packet + header_size), nStartPos, nEndPos, cur_block->block, this); - } else { - // Packed - wxASSERT( (long int)size > 0 ); -@@ -942,10 +942,10 @@ void CUpDownClient::ProcessBlockPacket(const byte* packet, uint32 size, bool pac - if (lenUnzipped > (BLOCKSIZE + 300)) { - lenUnzipped = (BLOCKSIZE + 300); - } -- byte *unzipped = new byte[lenUnzipped]; -+ uint8_t *unzipped = new uint8_t[lenUnzipped]; - - // Try to unzip the packet -- int result = unzip(cur_block, (byte*)(packet + header_size), (size - header_size), &unzipped, &lenUnzipped); -+ int result = unzip(cur_block, (uint8_t*)(packet + header_size), (size - header_size), &unzipped, &lenUnzipped); - - // no block can be uncompressed to >2GB, 'lenUnzipped' is obviously erroneous. - if (result == Z_OK && ((int)lenUnzipped >= 0)) { -@@ -1046,7 +1046,7 @@ void CUpDownClient::ProcessBlockPacket(const byte* packet, uint32 size, bool pac - } - } - --int CUpDownClient::unzip(Pending_Block_Struct *block, byte *zipped, uint32 lenZipped, byte **unzipped, uint32 *lenUnzipped, int iRecursion) -+int CUpDownClient::unzip(Pending_Block_Struct *block, uint8_t *zipped, uint32 lenZipped, uint8_t **unzipped, uint32 *lenUnzipped, int iRecursion) - { - int err = Z_DATA_ERROR; - -@@ -1112,7 +1112,7 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, byte *zipped, uint32 lenZi - newLength = lenZipped * 2; - } - // Copy any data that was successfully unzipped to new array -- byte *temp = new byte[newLength]; -+ uint8_t *temp = new uint8_t[newLength]; - wxASSERT( zS->total_out - block->totalUnzipped <= newLength ); - memcpy(temp, (*unzipped), (zS->total_out - block->totalUnzipped)); - delete [] (*unzipped); -@@ -1601,7 +1601,7 @@ void CUpDownClient::SendAICHRequest(CPartFile* pForFile, uint16 nPart){ - SafeSendPacket(packet); - } - --void CUpDownClient::ProcessAICHAnswer(const byte* packet, uint32 size) -+void CUpDownClient::ProcessAICHAnswer(const uint8_t* packet, uint32 size) - { - if (m_fAICHRequested == FALSE){ - throw wxString(wxT("Received unrequested AICH Packet")); -@@ -1643,7 +1643,7 @@ void CUpDownClient::ProcessAICHAnswer(const byte* packet, uint32 size) - } - - --void CUpDownClient::ProcessAICHRequest(const byte* packet, uint32 size) -+void CUpDownClient::ProcessAICHRequest(const uint8_t* packet, uint32 size) - { - if (size != 16 + 2 + CAICHHash::GetHashSize()) { - throw wxString(wxT("Received AICH Request Packet with wrong size")); -diff --git a/src/DownloadQueue.cpp b/src/DownloadQueue.cpp -index 7033cd1..6128fe2 100644 ---- a/src/DownloadQueue.cpp -+++ b/src/DownloadQueue.cpp -@@ -1114,7 +1114,7 @@ void CDownloadQueue::ProcessLocalRequests() - if (iSize > 0) { - // create one 'packet' which contains all buffered OP_GETSOURCES ED2K packets to be sent with one TCP frame - // server credits: (16+4)*regularfiles + (16+4+8)*largefiles +1 -- CScopedPtr packet(new CPacket(new byte[iSize], dataTcpFrame.GetLength(), true, false)); -+ CScopedPtr packet(new CPacket(new uint8_t[iSize], dataTcpFrame.GetLength(), true, false)); - dataTcpFrame.Seek(0, wxFromStart); - dataTcpFrame.Read(packet->GetPacket(), iSize); - uint32 size = packet->GetPacketSize(); -@@ -1591,7 +1591,7 @@ void CDownloadQueue::KademliaSearchFile(uint32_t searchID, const Kademlia::CUInt - //ctemp->SetServerIP(serverip); - //ctemp->SetServerPort(serverport); - ctemp->SetKadPort(udp); -- byte cID[16]; -+ uint8_t cID[16]; - pcontactID->ToByteArray(cID); - ctemp->SetUserHash(CMD4Hash(cID)); - break; -@@ -1609,7 +1609,7 @@ void CDownloadQueue::KademliaSearchFile(uint32_t searchID, const Kademlia::CUInt - // from this firewalled source, the compare method will match them. - ctemp->SetSourceFrom(SF_KADEMLIA); - ctemp->SetKadPort(udp); -- byte cID[16]; -+ uint8_t cID[16]; - pcontactID->ToByteArray(cID); - ctemp->SetUserHash(CMD4Hash(cID)); - pbuddyID->ToByteArray(cID); -@@ -1634,7 +1634,7 @@ void CDownloadQueue::KademliaSearchFile(uint32_t searchID, const Kademlia::CUInt - ctemp->SetSourceFrom(SF_KADEMLIA); - ctemp->SetKadPort(udp); - ctemp->SetIP(ED2KID); // need to set the IP address, which cannot be used for TCP but for UDP -- byte cID[16]; -+ uint8_t cID[16]; - pcontactID->ToByteArray(cID); - ctemp->SetUserHash(CMD4Hash(cID)); - } -diff --git a/src/EMSocket.cpp b/src/EMSocket.cpp -index 3ccaa7e..e3e45a0 100644 ---- a/src/EMSocket.cpp -+++ b/src/EMSocket.cpp -@@ -199,7 +199,7 @@ void CEMSocket::OnReceive(int nErrorCode) - } - - uint32 readMax; -- byte *buf; -+ uint8_t *buf; - if (pendingHeaderSize < PACKET_HEADER_SIZE) { - delete[] pendingPacket; - pendingPacket = NULL; -@@ -213,7 +213,7 @@ void CEMSocket::OnReceive(int nErrorCode) - OnError(ERR_TOOBIG); - return; - } -- pendingPacket = new byte[readMax + 1]; -+ pendingPacket = new uint8_t[readMax + 1]; - buf = pendingPacket; - } else { - buf = pendingPacket + pendingPacketSize; -@@ -529,7 +529,7 @@ SocketSentBytes CEMSocket::Send(uint32 maxNumberOfBytesToSend, uint32 minFragSiz - sent = 0; - delete curPacket; - -- CryptPrepareSendData((byte*)sendbuffer, sendblen); -+ CryptPrepareSendData((uint8_t*)sendbuffer, sendblen); - } - - // At this point we've got a packet to send in sendbuffer. Try to send it. Loop until entire packet -diff --git a/src/EMSocket.h b/src/EMSocket.h -index 4d00361..4866aa5 100644 ---- a/src/EMSocket.h -+++ b/src/EMSocket.h -@@ -99,15 +99,15 @@ private: - bool pendingOnReceive; - - // Download partial header -- byte pendingHeader[PACKET_HEADER_SIZE]; -+ uint8_t pendingHeader[PACKET_HEADER_SIZE]; - uint32 pendingHeaderSize; - - // Download partial packet -- byte* pendingPacket; -+ uint8_t* pendingPacket; - uint32 pendingPacketSize; - - // Upload control -- byte* sendbuffer; -+ uint8_t* sendbuffer; - uint32 sendblen; - uint32 sent; - -diff --git a/src/EncryptedDatagramSocket.cpp b/src/EncryptedDatagramSocket.cpp -index 842686f..73de612 100644 ---- a/src/EncryptedDatagramSocket.cpp -+++ b/src/EncryptedDatagramSocket.cpp -@@ -42,7 +42,7 @@ - - - Additional Comments: - - For obvious reasons the UDP handshake is actually no handshake. If a different Encryption method (or better a different Key) is to be used this has to be negotiated in a TCP connection -- - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header byte. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage -+ - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header uint8_t. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage - - Kad/Ed2k Marker are only indicators, which possibility could be tried first, and should not be trusted - - ****************************** Server Packets -@@ -66,7 +66,7 @@ - - - Additional Comments: - - For obvious reasons the UDP handshake is actually no handshake. If a different Encryption method (or better a different Key) is to be used this has to be negotiated in a TCP connection -- - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header byte. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage -+ - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header uint8_t. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage - - ****************************** KAD Packets - -@@ -86,7 +86,7 @@ - - - Additional Comments: - - For obvious reasons the UDP handshake is actually no handshake. If a different Encryption method (or better a different Key) is to be used this has to be negotiated in a TCP connection -- - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header byte. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage -+ - SemiRandomNotProtocolMarker is a Byte which has a value unequal any Protocol header uint8_t. This is a compromise, turning in complete randomness (and nice design) but gaining a lower CPU usage - - Kad/Ed2k Marker are only indicators, which possibility could be tried first, and should not be trusted - */ - -@@ -309,7 +309,7 @@ int CEncryptedDatagramSocket::EncryptSendClient(uint8_t **buf, int bufLen, const - - sendbuffer.SetKey(md5, true); - -- // create the semi random byte encryption header -+ // create the semi random uint8_t encryption header - uint8_t semiRandomNotProtocolMarker = 0; - int i; - for (i = 0; i < 128; i++) { -@@ -444,7 +444,7 @@ int CEncryptedDatagramSocket::EncryptSendServer(uint8_t** ppbyBuf, int nBufLen, - CRC4EncryptableBuffer sendbuffer; - sendbuffer.SetKey(md5, true); - -- // create the semi random byte encryption header -+ // create the semi random uint8_t encryption header - uint8_t bySemiRandomNotProtocolMarker = 0; - int i; - -diff --git a/src/EncryptedStreamSocket.cpp b/src/EncryptedStreamSocket.cpp -index da579ce..9fb5acc 100644 ---- a/src/EncryptedStreamSocket.cpp -+++ b/src/EncryptedStreamSocket.cpp -@@ -180,7 +180,7 @@ void CEncryptedStreamSocket::SetConnectionEncryption(bool bEnabled, const uint8_ - /* Internals, common to base class */ - - // unfortunately sending cannot be made transparent for the derived class, because of WSA_WOULDBLOCK --// together with the fact that each byte must pass the keystream only once -+// together with the fact that each uint8_t must pass the keystream only once - int CEncryptedStreamSocket::Write(const void* lpBuf, uint32_t nBufLen) - { - //printf("Starting write for %s\n", (const char*) unicode2char(GetPeer())); -@@ -403,7 +403,7 @@ void CEncryptedStreamSocket::StartNegotiation(bool bOutgoing) - - m_cryptDHA.Randomize((CryptoPP::AutoSeededRandomPool&)GetRandomPool(), DHAGREEMENT_A_BITS); // our random a - wxASSERT( m_cryptDHA.MinEncodedSize() <= DHAGREEMENT_A_BITS / 8 ); -- CryptoPP::Integer cryptDHPrime((byte*)dh768_p, PRIMESIZE_BYTES); // our fixed prime -+ CryptoPP::Integer cryptDHPrime((uint8_t*)dh768_p, PRIMESIZE_BYTES); // our fixed prime - // calculate g^a % p - CryptoPP::Integer cryptDHGexpAmodP = a_exp_b_mod_c(CryptoPP::Integer(2), m_cryptDHA, cryptDHPrime); - wxASSERT( m_cryptDHA.MinEncodedSize() <= PRIMESIZE_BYTES ); -@@ -590,8 +590,8 @@ int CEncryptedStreamSocket::Negotiate(const uint8* pBuffer, uint32 nLen) - wxASSERT( !m_cryptDHA.IsZero() ); - uint8_t aBuffer[PRIMESIZE_BYTES + 1]; - m_pfiReceiveBuffer.Read(aBuffer, PRIMESIZE_BYTES); -- CryptoPP::Integer cryptDHAnswer((byte*)aBuffer, PRIMESIZE_BYTES); -- CryptoPP::Integer cryptDHPrime((byte*)dh768_p, PRIMESIZE_BYTES); // our fixed prime -+ CryptoPP::Integer cryptDHAnswer((uint8_t*)aBuffer, PRIMESIZE_BYTES); -+ CryptoPP::Integer cryptDHPrime((uint8_t*)dh768_p, PRIMESIZE_BYTES); // our fixed prime - CryptoPP::Integer cryptResult = a_exp_b_mod_c(cryptDHAnswer, m_cryptDHA, cryptDHPrime); - - m_cryptDHA = 0; -@@ -694,7 +694,7 @@ int CEncryptedStreamSocket::SendNegotiatingData(const void* lpBuf, uint32_t nBuf - } - - if (nBufLen - nStartCryptFromByte > 0) { -- //printf("Crypting negotiation data on %s starting on byte %i\n", (const char*) unicode2char(GetPeer()), nStartCryptFromByte); -+ //printf("Crypting negotiation data on %s starting on uint8_t %i\n", (const char*) unicode2char(GetPeer()), nStartCryptFromByte); - //DumpMem(lpBuf, nBufLen, wxT("Pre-encryption:")); - m_pfiSendBuffer.RC4Crypt((uint8*)lpBuf + nStartCryptFromByte, pBuffer + nStartCryptFromByte, nBufLen - nStartCryptFromByte); - //DumpMem(pBuffer, nBufLen, wxT("Post-encryption:")); -diff --git a/src/FileArea.cpp b/src/FileArea.cpp -index 8a018b9..da0204b 100644 ---- a/src/FileArea.cpp -+++ b/src/FileArea.cpp -@@ -230,7 +230,7 @@ void CFileArea::ReadAt(CFileAutoClose& file, uint64 offset, size_t count) - void *p = mmap(NULL, m_length, PROT_READ, MAP_SHARED, file.fd(), offStart); - if (p != MAP_FAILED) { - m_file = &file; -- m_mmap_buffer = (byte*) p; -+ m_mmap_buffer = (uint8_t*) p; - m_buffer = m_mmap_buffer + (offset - offStart); - - // add to list to catch errors correctly -@@ -240,7 +240,7 @@ void CFileArea::ReadAt(CFileAutoClose& file, uint64 offset, size_t count) - } - file.Unlock(); - #endif -- m_buffer = new byte[count]; -+ m_buffer = new uint8_t[count]; - file.ReadAt(m_buffer, offset, count); - } - -@@ -257,7 +257,7 @@ void CFileArea::StartWriteAt(CFileAutoClose& file, uint64 offset, size_t count) - if (p != MAP_FAILED) - { - m_file = &file; -- m_mmap_buffer = (byte*) p; -+ m_mmap_buffer = (uint8_t*) p; - m_buffer = m_mmap_buffer + (offset - offStart); - - // add to list to catch errors correctly -@@ -266,13 +266,13 @@ void CFileArea::StartWriteAt(CFileAutoClose& file, uint64 offset, size_t count) - } - file.Unlock(); - } -- m_buffer = new byte[count]; -+ m_buffer = new uint8_t[count]; - } - #else - void CFileArea::StartWriteAt(CFileAutoClose&, uint64, size_t count) - { - Close(); -- m_buffer = new byte[count]; -+ m_buffer = new uint8_t[count]; - } - #endif - -diff --git a/src/FileArea.h b/src/FileArea.h -index 4006151..17c6dee 100644 ---- a/src/FileArea.h -+++ b/src/FileArea.h -@@ -22,7 +22,7 @@ - #ifndef FILEAREA_H - #define FILEAREA_H - --#include "Types.h" // Needed for byte -+#include "Types.h" // Needed for uint8_t - - class CFileAreaSigHandler; - class CFileAutoClose; -@@ -78,7 +78,7 @@ public: - * Get buffer that contains data readed or to write. - * @return allocated buffer or NULL if not initialized - */ -- byte *GetBuffer() const { return m_buffer; }; -+ uint8_t *GetBuffer() const { return m_buffer; }; - - /** - * Report error pending -@@ -97,11 +97,11 @@ private: - * If mapped points inside m_mmap_buffer area otherwise - * point to an allocated buffer to be freed. - */ -- byte *m_buffer; -+ uint8_t *m_buffer; - /** - * Pointer to memory mapped area or NULL if not mapped. - */ -- byte *m_mmap_buffer; -+ uint8_t *m_mmap_buffer; - /** - * Length of the mapped region, currently used only for munmap. - */ -diff --git a/src/FileLock.h b/src/FileLock.h -index 9758bdd..6a8a171 100644 ---- a/src/FileLock.h -+++ b/src/FileLock.h -@@ -91,7 +91,7 @@ private: - - /** Locks or unlocks the lock-file, returning true on success. */ - bool SetLock(bool doLock) { -- // lock/unlock first byte in the file -+ // lock/unlock first uint8_t in the file - OVERLAPPED ov; - ov.Offset = ov.OffsetHigh = 0; - BOOL ret; -diff --git a/src/GapList.h b/src/GapList.h -index 41c4af7..490180f 100644 ---- a/src/GapList.h -+++ b/src/GapList.h -@@ -52,7 +52,7 @@ private: - incomplete, - unknown - }; -- std::vector m_partsComplete; -+ std::vector m_partsComplete; - - // get size of any part - uint32 GetPartSize(uint16 part) const { return part == m_iPartCount - 1 ? m_sizeLastPart : PARTSIZE; } -diff --git a/src/IPFilterScanner.cpp b/src/IPFilterScanner.cpp -index 7cd5ae0..b81df8e 100644 ---- a/src/IPFilterScanner.cpp -+++ b/src/IPFilterScanner.cpp -@@ -1771,7 +1771,7 @@ YY_BUFFER_STATE yyip_scan_string (yyconst char * yystr ) - - /** Setup the input buffer state to scan the given bytes. The next call to yyiplex() will - * scan from a @e copy of @a bytes. -- * @param bytes the byte buffer to scan -+ * @param bytes the uint8_t buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. -diff --git a/src/KnownFile.cpp b/src/KnownFile.cpp -index 0e39630..6c5c389 100644 ---- a/src/KnownFile.cpp -+++ b/src/KnownFile.cpp -@@ -358,7 +358,7 @@ void CKnownFile::SetFileSize(uint64 nFileSize) - //Hash[ 1]: 31D6CFE0D16AE931B73C59D7E0C089C0 *special part hash* - // - // -- //File size: 1*PARTSIZE + 1 byte -+ //File size: 1*PARTSIZE + 1 uint8_t - //File hash: 2F620AE9D462CBB6A59FE8401D2B3D23 - //Nr. hashs: 2 - //Hash[ 0]: 121795F0BEDE02DDC7C5426D0995F53F -@@ -382,7 +382,7 @@ void CKnownFile::SetFileSize(uint64 nFileSize) - //Hash[ 3]: 31D6CFE0D16AE931B73C59D7E0C089C0 *special part hash* - // - // -- //File size: 3*PARTSIZE + 1 byte -+ //File size: 3*PARTSIZE + 1 uint8_t - //File hash: 797ED552F34380CAFF8C958207E40355 - //Nr. hashs: 4 - //Hash[ 0]: FC7FD02CCD6987DCF1421F4C0AF94FB8 -@@ -788,8 +788,8 @@ void CKnownFile::CreateHashFromHashlist(const ArrayOfCMD4Hash& hashes, CMD4Hash* - { - wxCHECK_RET(hashes.size(), wxT("No input to hash from in CreateHashFromHashlist")); - -- std::vector buffer(hashes.size() * MD4HASH_LENGTH); -- std::vector::iterator it = buffer.begin(); -+ std::vector buffer(hashes.size() * MD4HASH_LENGTH); -+ std::vector::iterator it = buffer.begin(); - - for (size_t i = 0; i < hashes.size(); ++i) { - it = STLCopy_n(hashes[i].GetHash(), MD4HASH_LENGTH, it); -@@ -811,7 +811,7 @@ void CKnownFile::CreateHashFromFile(CFileAutoClose& file, uint64 offset, uint32 - } - - --void CKnownFile::CreateHashFromInput(const byte* input, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut ) -+void CKnownFile::CreateHashFromInput(const uint8_t* input, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut ) - { - wxASSERT_MSG(Output || pShaHashOut, wxT("Nothing to do in CreateHashFromInput")); - { wxCHECK_RET(input, wxT("No input to hash from in CreateHashFromInput")); } -@@ -820,7 +820,7 @@ void CKnownFile::CreateHashFromInput(const byte* input, uint32 Length, CMD4Hash* - CMemFile data(input, Length); - - uint32 Required = Length; -- byte X[64*128]; -+ uint8_t X[64*128]; - - uint32 posCurrentEMBlock = 0; - uint32 nIACHPos = 0; -diff --git a/src/KnownFile.h b/src/KnownFile.h -index 0ef7559..ae78715 100644 ---- a/src/KnownFile.h -+++ b/src/KnownFile.h -@@ -333,7 +333,7 @@ protected: - CPath m_filePath; - - static void CreateHashFromFile(class CFileAutoClose& file, uint64 offset, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut); -- static void CreateHashFromInput(const byte* input, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut); -+ static void CreateHashFromInput(const uint8_t* input, uint32 Length, CMD4Hash* Output, CAICHHashTree* pShaHashOut); - - mutable bool m_bCommentLoaded; - uint16 m_iPartCount; -diff --git a/src/MemFile.cpp b/src/MemFile.cpp -index 4632bf4..4a01388 100644 ---- a/src/MemFile.cpp -+++ b/src/MemFile.cpp -@@ -38,7 +38,7 @@ CMemFile::CMemFile(unsigned int growthRate) - } - - --CMemFile::CMemFile(byte* buffer, size_t bufferSize) -+CMemFile::CMemFile(uint8_t* buffer, size_t bufferSize) - { - MULE_VALIDATE_PARAMS(buffer, wxT("CMemFile: Attempted to attach invalid buffer.")); - -@@ -51,11 +51,11 @@ CMemFile::CMemFile(byte* buffer, size_t bufferSize) - m_readonly = false; - } - --CMemFile::CMemFile(const byte* buffer, size_t bufferSize) -+CMemFile::CMemFile(const uint8_t* buffer, size_t bufferSize) - { - MULE_VALIDATE_PARAMS(buffer, wxT("CMemFile: Attempted to attach invalid buffer.")); - -- m_buffer = const_cast(buffer); -+ m_buffer = const_cast(buffer); - m_BufferSize = bufferSize; - m_fileSize = bufferSize; - m_growthRate = 0; -@@ -115,7 +115,7 @@ void CMemFile::enlargeBuffer(size_t size) - newsize = size; - } - -- byte *tmp = (byte*)realloc(m_buffer, newsize); -+ uint8_t *tmp = (uint8_t*)realloc(m_buffer, newsize); - if (tmp) { - m_buffer = tmp; - m_BufferSize = newsize; -diff --git a/src/MemFile.h b/src/MemFile.h -index c4f5508..67d487a 100644 ---- a/src/MemFile.h -+++ b/src/MemFile.h -@@ -86,10 +86,10 @@ public: - * - * The buffer is _not_ freed by CMemFile upon destruction. - * -- * If the buffer is a const byte*, the memfile is read-only. -+ * If the buffer is a const uint8_t*, the memfile is read-only. - */ -- CMemFile(byte* buffer, size_t bufferSize); -- CMemFile(const byte* buffer, size_t bufferSize); -+ CMemFile(uint8_t* buffer, size_t bufferSize); -+ CMemFile(const uint8_t* buffer, size_t bufferSize); - - /** Destructor. */ - virtual ~CMemFile(); -@@ -132,7 +132,7 @@ public: - virtual void ResetData(); - - // Sometimes it's useful to get the buffer and do stuff with it. -- byte* GetRawBuffer() const { return m_buffer; } -+ uint8_t* GetRawBuffer() const { return m_buffer; } - - protected: - /** @see CFileDataIO::doRead */ -@@ -167,7 +167,7 @@ private: - //! read-only mark. - bool m_readonly; - //! The actual buffer. -- byte* m_buffer; -+ uint8_t* m_buffer; - }; - - #endif // MEMFILE_H -diff --git a/src/MuleCollection.cpp b/src/MuleCollection.cpp -index 6c36f0b..a131740 100644 ---- a/src/MuleCollection.cpp -+++ b/src/MuleCollection.cpp -@@ -50,7 +50,7 @@ intType CMuleCollection::ReadInt(std::ifstream& infile) - { - intType integer = 0; - infile.read(reinterpret_cast(&integer),sizeof(intType)); -- // TODO: byte-sex -+ // TODO: uint8_t-sex - return integer; - } - -diff --git a/src/MuleColour.h b/src/MuleColour.h -index 1a983dd..ff54897 100644 ---- a/src/MuleColour.h -+++ b/src/MuleColour.h -@@ -40,7 +40,7 @@ public: - - CMuleColour() { Init(); Set(0,0,0); } - CMuleColour(const wxColour& colour) { Init(); Set(colour.Red(), colour.Green(), colour.Blue()); } -- CMuleColour(byte r, byte g, byte b) { Init(); Set(r,g,b); } -+ CMuleColour(uint8_t r, uint8_t g, uint8_t b) { Init(); Set(r,g,b); } - CMuleColour(unsigned long rgb) - { - Init(); -@@ -61,13 +61,13 @@ public: - - ~CMuleColour() { } - -- void Set(byte red, byte green, byte blue) { m_red = red; m_green = green; m_blue = blue; } -+ void Set(uint8_t red, uint8_t green, uint8_t blue) { m_red = red; m_green = green; m_blue = blue; } - -- inline byte Red() const { return m_red; } -- inline byte Green() const { return m_green; } -- inline byte Blue() const { return m_blue; } -+ inline uint8_t Red() const { return m_red; } -+ inline uint8_t Green() const { return m_green; } -+ inline uint8_t Blue() const { return m_blue; } - -- const CMuleColour& Blend(byte percentage, ColourComponent flags = (ColourComponent)(COLOUR_R | COLOUR_G | COLOUR_B) ) -+ const CMuleColour& Blend(uint8_t percentage, ColourComponent flags = (ColourComponent)(COLOUR_R | COLOUR_G | COLOUR_B) ) - { - unsigned int red = (unsigned int)(Red() * ((flags & COLOUR_R) ? ((float)percentage/(float)100) : (float)1)); - unsigned int green = (unsigned int)(Green() * ((flags & COLOUR_G) ? ((float)percentage/(float)100) : (float)1)); -@@ -99,9 +99,9 @@ public: - const wxBrush& GetBrush(int style = wxSOLID) const; - - private: -- byte m_red; -- byte m_green; -- byte m_blue; -+ uint8_t m_red; -+ uint8_t m_green; -+ uint8_t m_blue; - - mutable wxPen* m_cachedpen; - mutable wxBrush* m_cachedbrush; -diff --git a/src/MuleUDPSocket.cpp b/src/MuleUDPSocket.cpp -index a666c93..6f09a59 100644 ---- a/src/MuleUDPSocket.cpp -+++ b/src/MuleUDPSocket.cpp -@@ -180,7 +180,7 @@ void CMuleUDPSocket::OnReceive(int errorCode) - AddDebugLogLineN(logMuleUDP, (m_name + wxT(": Packet received (")) - << addr.IPAddress() << wxT(":") << port << wxT("): ") - << length << wxT("b")); -- OnPacketReceived(ip, port, (byte*)buffer, length); -+ OnPacketReceived(ip, port, (uint8_t*)buffer, length); - } - } - -diff --git a/src/MuleUDPSocket.h b/src/MuleUDPSocket.h -index c9cb023..1740c7a 100644 ---- a/src/MuleUDPSocket.h -+++ b/src/MuleUDPSocket.h -@@ -131,7 +131,7 @@ protected: - * @param buffer The data that has been received. - * @param length The length of the data buffer. - */ -- virtual void OnPacketReceived(uint32 ip, uint16 port, byte* buffer, size_t length) = 0; -+ virtual void OnPacketReceived(uint32 ip, uint16 port, uint8_t* buffer, size_t length) = 0; - - - /** See ThrottledControlSocket::SendControlData */ -diff --git a/src/OtherFunctions.cpp b/src/OtherFunctions.cpp -index 3c58aa2..8b84a90 100644 ---- a/src/OtherFunctions.cpp -+++ b/src/OtherFunctions.cpp -@@ -61,7 +61,7 @@ wxString CastItoXBytes( uint64 count ) - { - - if (count < 1024) -- return CFormat(wxT("%u ")) % count + wxPLURAL("byte", "bytes", count) ; -+ return CFormat(wxT("%u ")) % count + wxPLURAL("uint8_t", "bytes", count) ; - else if (count < 1048576) - return CFormat(wxT("%u ")) % (count >> 10) + _("kB") ; - else if (count < 1073741824) -@@ -92,7 +92,7 @@ wxString CastItoIShort(uint64 count) - wxString CastItoSpeed(uint32 bytes) - { - if (bytes < 1024) -- return CFormat(wxT("%u ")) % bytes + wxPLURAL("byte/sec", "bytes/sec", bytes); -+ return CFormat(wxT("%u ")) % bytes + wxPLURAL("uint8_t/sec", "bytes/sec", bytes); - else if (bytes < 1048576) - return CFormat(wxT("%.2f ")) % (bytes / 1024.0) + _("kB/s"); - else -@@ -284,14 +284,14 @@ static wxChar base16Lookup[BASE16_LOOKUP_MAX][2] = { - }; - - --// Returns a BASE16 encoded byte array -+// Returns a BASE16 encoded uint8_t array - // - // [In] --// buffer: Pointer to byte array -+// buffer: Pointer to uint8_t array - // bufLen: Lenght of buffer array - // - // [Return] --// wxString object with BASE16 encoded byte array -+// wxString object with BASE16 encoded uint8_t array - wxString EncodeBase16(const unsigned char* buffer, unsigned int bufLen) - { - wxString Base16Buff; -@@ -305,15 +305,15 @@ wxString EncodeBase16(const unsigned char* buffer, unsigned int bufLen) - } - - --// Decodes a BASE16 string into a byte array -+// Decodes a BASE16 string into a uint8_t array - // - // [In] - // base16Buffer: String containing BASE16 - // base16BufLen: Lenght BASE16 coded string's length - // - // [Out] --// buffer: byte array containing decoded string --unsigned int DecodeBase16(const wxString &base16Buffer, unsigned int base16BufLen, byte *buffer) -+// buffer: uint8_t array containing decoded string -+unsigned int DecodeBase16(const wxString &base16Buffer, unsigned int base16BufLen, uint8_t *buffer) - { - if (base16BufLen & 1) { - return 0; -@@ -323,7 +323,7 @@ unsigned int DecodeBase16(const wxString &base16Buffer, unsigned int base16BufLe - for(unsigned int i = 0; i < base16BufLen; ++i) { - int lookup = toupper(base16Buffer[i]) - wxT('0'); - // Check to make sure that the given word falls inside a valid range -- byte word = (lookup < 0 || lookup >= BASE16_LOOKUP_MAX) ? -+ uint8_t word = (lookup < 0 || lookup >= BASE16_LOOKUP_MAX) ? - 0xFF : base16Lookup[lookup][1]; - unsigned idx = i >> 1; - buffer[idx] = (i & 1) ? // odd or even? -@@ -334,14 +334,14 @@ unsigned int DecodeBase16(const wxString &base16Buffer, unsigned int base16BufLe - } - - --// Returns a BASE32 encoded byte array -+// Returns a BASE32 encoded uint8_t array - // - // [In] --// buffer: Pointer to byte array -+// buffer: Pointer to uint8_t array - // bufLen: Lenght of buffer array - // - // [Return] --// wxString object with BASE32 encoded byte array -+// wxString object with BASE32 encoded uint8_t array - wxString EncodeBase32(const unsigned char* buffer, unsigned int bufLen) - { - wxString Base32Buff; -@@ -349,7 +349,7 @@ wxString EncodeBase32(const unsigned char* buffer, unsigned int bufLen) - unsigned char word; - - for(i = 0, index = 0; i < bufLen;) { -- // Is the current word going to span a byte boundary? -+ // Is the current word going to span a uint8_t boundary? - if (index > 3) { - word = (buffer[i] & (0xFF >> index)); - index = (index + 5) % 8; -@@ -372,14 +372,14 @@ wxString EncodeBase32(const unsigned char* buffer, unsigned int bufLen) - } - - --// Decodes a BASE32 string into a byte array -+// Decodes a BASE32 string into a uint8_t array - // - // [In] - // base32Buffer: String containing BASE32 - // base32BufLen: Lenght BASE32 coded string's length - // - // [Out] --// buffer: byte array containing decoded string -+// buffer: uint8_t array containing decoded string - // [Return] - // nDecodeLen: - unsigned int DecodeBase32(const wxString &base32Buffer, unsigned int base32BufLen, unsigned char *buffer) -@@ -414,7 +414,7 @@ unsigned int DecodeBase32(const wxString &base32Buffer, unsigned int base32BufLe - nCount += 5; - if (nCount >= 8) - { -- *buffer++ = (byte)( nBits >> (nCount - 8) ); -+ *buffer++ = (uint8_t)( nBits >> (nCount - 8) ); - nCount -= 8; - } - nBits <<= 5; -diff --git a/src/Packet.cpp b/src/Packet.cpp -index d0e93b4..3e0f774 100644 ---- a/src/Packet.cpp -+++ b/src/Packet.cpp -@@ -47,12 +47,12 @@ CPacket::CPacket(CPacket &p) - memcpy(head, p.head, sizeof head); - tempbuffer = NULL; - if (p.completebuffer) { -- completebuffer = new byte[size + 10];; -+ completebuffer = new uint8_t[size + 10];; - pBuffer = completebuffer + sizeof(Header_Struct); - } else { - completebuffer = NULL; - if (p.pBuffer) { -- pBuffer = new byte[size]; -+ pBuffer = new uint8_t[size]; - } else { - pBuffer = NULL; - } -@@ -77,7 +77,7 @@ CPacket::CPacket(uint8 protocol) - } - - // only used for receiving packets --CPacket::CPacket(byte* rawHeader, byte *buf) -+CPacket::CPacket(uint8_t* rawHeader, uint8_t *buf) - { - memset(head, 0, sizeof head); - Header_Struct* header = reinterpret_cast(rawHeader); -@@ -104,7 +104,7 @@ CPacket::CPacket(const CMemFile& datafile, uint8 protocol, uint8 ucOpcode) - m_bFromPF = false; - memset(head, 0, sizeof head); - tempbuffer = NULL; -- completebuffer = new byte[size + sizeof(Header_Struct)/*Why this 4?*/]; -+ completebuffer = new uint8_t[size + sizeof(Header_Struct)/*Why this 4?*/]; - pBuffer = completebuffer + sizeof(Header_Struct); - - // Write contents of MemFile to buffer (while keeping original position in file) -@@ -126,7 +126,7 @@ CPacket::CPacket(int8 in_opcode, uint32 in_size, uint8 protocol, bool bFromPF) - memset(head, 0, sizeof head); - tempbuffer = NULL; - if (in_size) { -- completebuffer = new byte[in_size + sizeof(Header_Struct) + 4 /*Why this 4?*/]; -+ completebuffer = new uint8_t[in_size + sizeof(Header_Struct) + 4 /*Why this 4?*/]; - pBuffer = completebuffer + sizeof(Header_Struct); - memset(completebuffer, 0, in_size + sizeof(Header_Struct) + 4 /*Why this 4?*/); - } else { -@@ -136,7 +136,7 @@ CPacket::CPacket(int8 in_opcode, uint32 in_size, uint8 protocol, bool bFromPF) - } - - // only used for splitted packets! --CPacket::CPacket(byte* pPacketPart, uint32 nSize, bool bLast, bool bFromPF) -+CPacket::CPacket(uint8_t* pPacketPart, uint32 nSize, bool bLast, bool bFromPF) - { - size = nSize - sizeof(Header_Struct); - opcode = 0; -@@ -166,7 +166,7 @@ CPacket::~CPacket() - } - } - --uint32 CPacket::GetPacketSizeFromHeader(const byte* rawHeader) -+uint32 CPacket::GetPacketSizeFromHeader(const uint8_t* rawHeader) - { - const Header_Struct* header = reinterpret_cast(rawHeader); - uint32 size = ENDIAN_SWAP_32(header->packetlength); -@@ -175,13 +175,13 @@ uint32 CPacket::GetPacketSizeFromHeader(const byte* rawHeader) - return size - 1; - } - --void CPacket::CopyToDataBuffer(unsigned int offset, const byte* data, unsigned int n) -+void CPacket::CopyToDataBuffer(unsigned int offset, const uint8_t* data, unsigned int n) - { - wxASSERT(offset + n <= size + 1); - memcpy(pBuffer + offset, data, n); - } - --byte* CPacket::GetPacket() { -+uint8_t* CPacket::GetPacket() { - if (completebuffer) { - if (!m_bSplitted) { - memcpy(completebuffer, GetHeader(), sizeof(Header_Struct)); -@@ -192,19 +192,19 @@ byte* CPacket::GetPacket() { - delete [] tempbuffer; - tempbuffer = NULL; - } -- tempbuffer = new byte[size + sizeof(Header_Struct) + 4 /* why this 4?*/]; -+ tempbuffer = new uint8_t[size + sizeof(Header_Struct) + 4 /* why this 4?*/]; - memcpy(tempbuffer , GetHeader(), sizeof(Header_Struct)); - memcpy(tempbuffer + sizeof(Header_Struct), pBuffer , size); - return tempbuffer; - } - } - --byte* CPacket::DetachPacket() { -+uint8_t* CPacket::DetachPacket() { - if (completebuffer) { - if (!m_bSplitted) { - memcpy(completebuffer, GetHeader(), sizeof(Header_Struct)); - } -- byte* result = completebuffer; -+ uint8_t* result = completebuffer; - completebuffer = pBuffer = NULL; - return result; - } else{ -@@ -212,16 +212,16 @@ byte* CPacket::DetachPacket() { - delete[] tempbuffer; - tempbuffer = NULL; - } -- tempbuffer = new byte[size+sizeof(Header_Struct)+4 /* Why this 4?*/]; -+ tempbuffer = new uint8_t[size+sizeof(Header_Struct)+4 /* Why this 4?*/]; - memcpy(tempbuffer,GetHeader(),sizeof(Header_Struct)); - memcpy(tempbuffer+sizeof(Header_Struct),pBuffer,size); -- byte* result = tempbuffer; -+ uint8_t* result = tempbuffer; - tempbuffer = 0; - return result; - } - } - --byte* CPacket::GetHeader() { -+uint8_t* CPacket::GetHeader() { - wxASSERT( !m_bSplitted ); - - Header_Struct* header = reinterpret_cast(head); -@@ -232,7 +232,7 @@ byte* CPacket::GetHeader() { - return head; - } - --byte* CPacket::GetUDPHeader() { -+uint8_t* CPacket::GetUDPHeader() { - wxASSERT( !m_bSplitted ); - - memset(head, 0, 6); -@@ -249,7 +249,7 @@ void CPacket::PackPacket() - wxASSERT(!m_bSplitted); - - uLongf newsize = size + 300; -- byte* output = new byte[newsize]; -+ uint8_t* output = new uint8_t[newsize]; - - uint16 result = compress2(output, &newsize, pBuffer, size, Z_BEST_COMPRESSION); - -@@ -287,7 +287,7 @@ bool CPacket::UnPackPacket(uint32 uMaxDecompressedSize) { - nNewSize = uMaxDecompressedSize; - } - -- byte* unpack = new byte[nNewSize]; -+ uint8_t* unpack = new uint8_t[nNewSize]; - uLongf unpackedsize = nNewSize; - uint16 result = uncompress(unpack, &unpackedsize, pBuffer, size); - -diff --git a/src/Packet.h b/src/Packet.h -index 3e0fe71..407d345 100644 ---- a/src/Packet.h -+++ b/src/Packet.h -@@ -41,19 +41,19 @@ class CPacket { - public: - CPacket(CPacket &p); - CPacket(uint8 protocol); -- CPacket(byte* header, byte *buf); // only used for receiving packets -+ CPacket(uint8_t* header, uint8_t *buf); // only used for receiving packets - CPacket(const CMemFile& datafile, uint8 protocol, uint8 ucOpcode); - CPacket(int8 in_opcode, uint32 in_size, uint8 protocol, bool bFromPF = true); -- CPacket(byte* pPacketPart, uint32 nSize, bool bLast, bool bFromPF = true); // only used for splitted packets! -+ CPacket(uint8_t* pPacketPart, uint32 nSize, bool bLast, bool bFromPF = true); // only used for splitted packets! - - ~CPacket(); - -- byte* GetHeader(); -- byte* GetUDPHeader(); -- byte* GetPacket(); -- byte* DetachPacket(); -+ uint8_t* GetHeader(); -+ uint8_t* GetUDPHeader(); -+ uint8_t* GetPacket(); -+ uint8_t* DetachPacket(); - uint32 GetRealPacketSize() const { return size + 6; } -- static uint32 GetPacketSizeFromHeader(const byte* rawHeader); -+ static uint32 GetPacketSizeFromHeader(const uint8_t* rawHeader); - bool IsSplitted() { return m_bSplitted; } - bool IsLastSplitted() { return m_bLastSplitted; } - void PackPacket(); -@@ -66,9 +66,9 @@ public: - uint32 GetPacketSize() const { return size; } - uint8 GetProtocol() const { return prot; } - void SetProtocol(uint8 p) { prot = p; } -- const byte* GetDataBuffer(void) const { return pBuffer; } -+ const uint8_t* GetDataBuffer(void) const { return pBuffer; } - void Copy16ToDataBuffer(const void* data); -- void CopyToDataBuffer(unsigned int offset, const byte* data, unsigned int n); -+ void CopyToDataBuffer(unsigned int offset, const uint8_t* data, unsigned int n); - void CopyUInt32ToDataBuffer(uint32 data, unsigned int offset = 0); - - private: -@@ -82,10 +82,10 @@ private: - bool m_bLastSplitted; - bool m_bPacked; - bool m_bFromPF; -- byte head[6]; -- byte* tempbuffer; -- byte* completebuffer; -- byte* pBuffer; -+ uint8_t head[6]; -+ uint8_t* tempbuffer; -+ uint8_t* completebuffer; -+ uint8_t* pBuffer; - }; - - #endif // PACKET_H -diff --git a/src/Parser.cpp b/src/Parser.cpp -index 4d78feb..74f3e89 100644 ---- a/src/Parser.cpp -+++ b/src/Parser.cpp -@@ -929,7 +929,7 @@ yytnamerr (char *yyres, const char *yystr) - - /* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, -- including the terminating null byte. If YYRESULT is null, do not -+ including the terminating null uint8_t. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during -diff --git a/src/PartFile.cpp b/src/PartFile.cpp -index ad2768f..1a4ef88 100644 ---- a/src/PartFile.cpp -+++ b/src/PartFile.cpp -@@ -123,7 +123,7 @@ public: - uint64 end; // This is the end offset of the data - Requested_Block_Struct *block; // This is the requested block that this data relates to - -- PartFileBufferedData(CFileAutoClose& file, byte * data, uint64 _start, uint64 _end, Requested_Block_Struct *_block) -+ PartFileBufferedData(CFileAutoClose& file, uint8_t * data, uint64 _start, uint64 _end, Requested_Block_Struct *_block) - : start(_start), end(_end), block(_block) - { - area.StartWriteAt(file, start, end-start+1); -@@ -881,7 +881,7 @@ bool CPartFile::SavePartFile(bool Initial) - for (CGapList::const_iterator it = m_gaplist.begin(); it != m_gaplist.end(); ++it) { - wxString tagName = CFormat(wxT(" %u")) % i_pos; - -- // gap start = first missing byte but gap ends = first non-missing byte -+ // gap start = first missing uint8_t but gap ends = first non-missing uint8_t - // in edonkey but I think its easier to user the real limits - tagName[0] = FT_GAPSTART; - CTagIntSized(tagName, it.start(), IsLargeFile() ? 64 : 32).WriteTagToFile( &file ); -@@ -2863,7 +2863,7 @@ int CPartFile::GetCommonFilePenalty() - // Kry - transize is 32bits, no packet can be more than that (this is - // compressed size). Even 32bits is too much imho.As for the return size, - // look at the lenData below. --uint32 CPartFile::WriteToBuffer(uint32 transize, byte* data, uint64 start, uint64 end, Requested_Block_Struct *block, const CUpDownClient* client) -+uint32 CPartFile::WriteToBuffer(uint32 transize, uint8_t* data, uint64 start, uint64 end, Requested_Block_Struct *block, const CUpDownClient* client) - { - // Increment transferred bytes counter for this file - transferred += transize; -diff --git a/src/PartFile.h b/src/PartFile.h -index ed22213..5c8f3d5 100644 ---- a/src/PartFile.h -+++ b/src/PartFile.h -@@ -162,7 +162,7 @@ public: - int getPartfileStatusRang() const; - - // Barry - Added as replacement for BlockReceived to buffer data before writing to disk -- uint32 WriteToBuffer(uint32 transize, byte *data, uint64 start, uint64 end, Requested_Block_Struct *block, const CUpDownClient* client); -+ uint32 WriteToBuffer(uint32 transize, uint8_t *data, uint64 start, uint64 end, Requested_Block_Struct *block, const CUpDownClient* client); - void FlushBuffer(bool fromAICHRecoveryDataAvailable = false); - - // Barry - Added to prevent list containing deleted blocks on shutdown -diff --git a/src/PartFileConvert.cpp b/src/PartFileConvert.cpp -index 8427f31..ce96e49 100644 ---- a/src/PartFileConvert.cpp -+++ b/src/PartFileConvert.cpp -@@ -389,7 +389,7 @@ ConvStatus CPartFileConvert::performConvertToeMule(const CPath& fileName) - - CPath::RemoveFile(newfilename.RemoveExt()); - if (!oldfile.FileExists()) { -- // data file does not exist. well, then create a 0 byte big one -+ // data file does not exist. well, then create a 0 uint8_t big one - CFile datafile; - ret = datafile.Create(newfilename.RemoveExt()); - } else if (s_pfconverting->removeSource) { -diff --git a/src/PrefsUnifiedDlg.cpp b/src/PrefsUnifiedDlg.cpp -index 66842fd..3cee7c2 100644 ---- a/src/PrefsUnifiedDlg.cpp -+++ b/src/PrefsUnifiedDlg.cpp -@@ -1152,7 +1152,7 @@ void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent& event ) - case IDC_FILEBUFFERSIZE: - id = IDC_FILEBUFFERSIZE_STATIC; - // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation -- label = CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event.GetPosition() * 15000)) % (event.GetPosition() * 15000); -+ label = CFormat(wxPLURAL("File Buffer Size: %d uint8_t", "File Buffer Size: %d bytes", event.GetPosition() * 15000)) % (event.GetPosition() * 15000); - break; - - case IDC_QUEUESIZE: -diff --git a/src/RLE.cpp b/src/RLE.cpp -index ae5642f..1d95b35 100644 ---- a/src/RLE.cpp -+++ b/src/RLE.cpp -@@ -123,7 +123,7 @@ const uint8 *RLE_Data::Decode(const uint8 *buff, int len) - j += seqLen; - i += 3; - } else { -- // This is a single byte. -+ // This is a single uint8_t. - if (j < m_len) { - decBuf[j] = buff[i]; - } -@@ -180,7 +180,7 @@ const uint8 * RLE_Data::Encode(const uint8 *data, int inlen, int &outlen, bool & - // - // now RLE - // -- // In worst case 2-byte sequence is encoded as 3. So, data can grow by 50%. -+ // In worst case 2-uint8_t sequence is encoded as 3. So, data can grow by 50%. - uint8 * enc_buff = new uint8[m_len * 3/2 + 1]; - int i = 0, j = 0; - while ( i != m_len ) { -diff --git a/src/SHA.cpp b/src/SHA.cpp -index 2d831a8..eb44fbc 100644 ---- a/src/SHA.cpp -+++ b/src/SHA.cpp -@@ -58,8 +58,8 @@ - --------------------------------------------------------------------------- - Issue Date: 30/11/2002 - -- This is a byte oriented version of SHA1 that operates on arrays of bytes -- stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor -+ This is a uint8_t oriented version of SHA1 that operates on arrays of bytes -+ stored in memory. It runs at 22 cycles per uint8_t on a Pentium P4 processor - */ - - #include "SHA.h" -@@ -78,8 +78,8 @@ CSHA::CSHA() - It may well fail, in which case the definitions will need to be set by - editing at the points marked **** EDIT HERE IF NECESSARY **** below. - */ --#define SHA_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ --#define SHA_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ -+#define SHA_LITTLE_ENDIAN 1234 /* uint8_t 0 is least significant (i386) */ -+#define SHA_BIG_ENDIAN 4321 /* uint8_t 0 is most significant (mc68k) */ - - #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n))) - -@@ -93,7 +93,7 @@ CSHA::CSHA() - - #define SHA1_MASK (SHA1_BLOCK_SIZE - 1) - --/* reverse byte order in 32-bit words */ -+/* reverse uint8_t order in 32-bit words */ - - #define ch(x,y,z) (((x) & (y)) ^ (~(x) & (z))) - #define parity(x,y,z) ((x) ^ (y) ^ (z)) -@@ -213,15 +213,15 @@ void CSHA::Finish(CAICHHash& Hash) - uint32 i = (uint32)(m_nCount[0] & SHA1_MASK); - - /* mask out the rest of any partial 32-bit word and then set */ -- /* the next byte to 0x80. On big-endian machines any bytes in */ -+ /* the next uint8_t to 0x80. On big-endian machines any bytes in */ - /* the buffer will be at the top end of 32 bit words, on little */ - /* endian machines they will be at the bottom. Hence the AND */ - /* and OR masks above are reversed for little endian systems */ -- /* Note that we can always add the first padding byte at this */ -+ /* Note that we can always add the first padding uint8_t at this */ - /* because the buffer always contains at least one empty slot */ - m_nBuffer[i >> 2] = (m_nBuffer[i >> 2] & mask[i & 3]) | bits[i & 3]; - -- /* we need 9 or more empty positions, one for the padding byte */ -+ /* we need 9 or more empty positions, one for the padding uint8_t */ - /* (above) and eight for the length count. If there is not */ - /* enough space pad and empty the buffer */ - if(i > SHA1_BLOCK_SIZE - 9) -@@ -236,7 +236,7 @@ void CSHA::Finish(CAICHHash& Hash) - while(i < 14) /* and zero pad all but last two positions */ - m_nBuffer[i++] = 0; - -- /* assemble the eight byte counter in in big-endian format */ -+ /* assemble the eight uint8_t counter in in big-endian format */ - m_nBuffer[14] = swap_b32((m_nCount[1] << 3) | (m_nCount[0] >> 29)); - m_nBuffer[15] = swap_b32(m_nCount[0] << 3); - -diff --git a/src/SHA.h b/src/SHA.h -index 8854c44..7749e26 100644 ---- a/src/SHA.h -+++ b/src/SHA.h -@@ -58,8 +58,8 @@ - --------------------------------------------------------------------------- - Issue Date: 30/11/2002 - -- This is a byte oriented version of SHA1 that operates on arrays of bytes -- stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor -+ This is a uint8_t oriented version of SHA1 that operates on arrays of bytes -+ stored in memory. It runs at 22 cycles per uint8_t on a Pentium P4 processor - */ - - #ifndef __SHA_H__ -diff --git a/src/SHAHashSet.h b/src/SHAHashSet.h -index 6746417..e3d7ea1 100644 ---- a/src/SHAHashSet.h -+++ b/src/SHAHashSet.h -@@ -104,12 +104,12 @@ class CUpDownClient; - class CAICHHash - { - private: -- byte m_abyBuffer[HASHSIZE]; -+ uint8_t m_abyBuffer[HASHSIZE]; - - public: - CAICHHash() { memset(m_abyBuffer, 0, HASHSIZE); } - CAICHHash(CFileDataIO* file) { Read(file); } -- CAICHHash(byte* data) { Read(data); } -+ CAICHHash(uint8_t* data) { Read(data); } - CAICHHash(const CAICHHash& k1) { *this = k1; } - ~CAICHHash() {} - CAICHHash& operator=(const CAICHHash& k1) -@@ -124,9 +124,9 @@ public: - friend bool operator!=(const CAICHHash& k1,const CAICHHash& k2) { return !(k1 == k2); } - void Read(CFileDataIO* file); - void Write(CFileDataIO* file) const; -- void Read(byte* data) { memcpy(m_abyBuffer, data, HASHSIZE); } -+ void Read(uint8_t* data) { memcpy(m_abyBuffer, data, HASHSIZE); } - wxString GetString() const; -- byte* GetRawHash() { return m_abyBuffer; } -+ uint8_t* GetRawHash() { return m_abyBuffer; } - static uint32 GetHashSize() { return HASHSIZE;} - unsigned int DecodeBase32(const wxString &base32); - }; -diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp -index 5b0cfad..5a75b7a 100644 ---- a/src/SafeFile.cpp -+++ b/src/SafeFile.cpp -@@ -396,7 +396,7 @@ CTag *CFileDataIO::ReadTag(bool bOptACP) const - { - CTag *retVal = NULL; - wxString name; -- byte type = 0; -+ uint8_t type = 0; - try { - type = ReadUInt8(); - name = ReadString(false); -diff --git a/src/Scanner.cpp b/src/Scanner.cpp -index 35478ac..9117aa5 100644 ---- a/src/Scanner.cpp -+++ b/src/Scanner.cpp -@@ -1761,7 +1761,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) - - /** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. -- * @param bytes the byte buffer to scan -+ * @param bytes the uint8_t buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. -diff --git a/src/SearchList.cpp b/src/SearchList.cpp -index 32b28e9..647f296 100644 ---- a/src/SearchList.cpp -+++ b/src/SearchList.cpp -@@ -470,7 +470,7 @@ void CSearchList::OnGlobalSearchTimer(CTimerEvent& WXUNUSED(evt)) - } - - --void CSearchList::ProcessSharedFileList(const byte* in_packet, uint32 size, -+void CSearchList::ProcessSharedFileList(const uint8_t* in_packet, uint32 size, - CUpDownClient* sender, bool *moreResultsAvailable, const wxString& directory) - { - wxCHECK_RET(sender, wxT("No sender in search-results from client.")); -@@ -967,7 +967,7 @@ void CSearchList::KademliaSearchKeyword(uint32_t searchID, const Kademlia::CUInt - EUtf8Str eStrEncode = utf8strRaw; - - CMemFile temp(250); -- byte fileid[16]; -+ uint8_t fileid[16]; - fileID->ToByteArray(fileid); - temp.WriteHash(CMD4Hash(fileid)); - -diff --git a/src/SearchList.h b/src/SearchList.h -index 35b0fc6..414411b 100644 ---- a/src/SearchList.h -+++ b/src/SearchList.h -@@ -126,7 +126,7 @@ public: - * @param moreResultsAvailable Set to a value specifying if more results are available. - * @param directory The directory containing the shared files. - */ -- void ProcessSharedFileList(const byte* packet, uint32 size, CUpDownClient* sender, bool* moreResultsAvailable, const wxString& directory); -+ void ProcessSharedFileList(const uint8_t* packet, uint32 size, CUpDownClient* sender, bool* moreResultsAvailable, const wxString& directory); - - /** - * Processes a search-result sent via TCP from the local server. All results are added. -diff --git a/src/ServerList.cpp b/src/ServerList.cpp -index f2e14e0..8c52634 100644 ---- a/src/ServerList.cpp -+++ b/src/ServerList.cpp -@@ -112,7 +112,7 @@ bool CServerList::LoadServerMet(const CPath& path) - try { - Notify_ServerFreeze(); - -- byte version = servermet.ReadUInt8(); -+ uint8_t version = servermet.ReadUInt8(); - - if (version != 0xE0 && version != MET_HEADER) { - AddLogLineC(CFormat(_("Server.met file corrupt, found invalid versiontag: 0x%x, size %i")) % version % sizeof(version)); -@@ -290,7 +290,7 @@ void CServerList::ServerStats() - // if it doesn't get responsed, we don't count it as error but continue with a normal ping - ping_server->SetCryptPingReplyPending(true); - uint32 nPacketLen = 4 + (uint8)(rand() % 16); // max padding 16 bytes -- CScopedArray pRawPacket(nPacketLen); -+ CScopedArray pRawPacket(nPacketLen); - uint32 dwChallenge = (rand() << 17) | (rand() << 2) | (rand() & 0x03); - if (dwChallenge == 0) { - dwChallenge++; -diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp -index f0e32e6..5d7755f 100644 ---- a/src/ServerSocket.cpp -+++ b/src/ServerSocket.cpp -@@ -226,7 +226,7 @@ void CServerSocket::OnReceive(int nErrorCode) - m_dwLastTransmission = GetTickCount(); - } - --bool CServerSocket::ProcessPacket(const byte* packet, uint32 size, int8 opcode) -+bool CServerSocket::ProcessPacket(const uint8_t* packet, uint32 size, int8 opcode) - { - try { - AddDebugLogLineN( logServer, wxT("Processing Server Packet: ") ); -diff --git a/src/ServerSocket.h b/src/ServerSocket.h -index 155e824..57c6b01 100644 ---- a/src/ServerSocket.h -+++ b/src/ServerSocket.h -@@ -65,7 +65,7 @@ public: - uint32 GetServerIP() const; - - private: -- bool ProcessPacket(const byte* packet, uint32 size, int8 opcode); -+ bool ProcessPacket(const uint8_t* packet, uint32 size, int8 opcode); - void SetConnectionState(sint8 newstate); - CServerConnect* serverconnect; - sint8 connectionstate; -diff --git a/src/ServerUDPSocket.cpp b/src/ServerUDPSocket.cpp -index 4e840c0..2a8e0de 100644 ---- a/src/ServerUDPSocket.cpp -+++ b/src/ServerUDPSocket.cpp -@@ -60,12 +60,12 @@ CServerUDPSocket::CServerUDPSocket(amuleIPV4Address &address, const CProxyData * - } - - --void CServerUDPSocket::OnPacketReceived(uint32 serverip, uint16 serverport, byte* buffer, size_t length) -+void CServerUDPSocket::OnPacketReceived(uint32 serverip, uint16 serverport, uint8_t* buffer, size_t length) - { - wxCHECK_RET(length >= 2, wxT("Invalid packet.")); - - size_t nPayLoadLen = length; -- byte* pBuffer = buffer; -+ uint8_t* pBuffer = buffer; - CServer* pServer = theApp->serverlist->GetServerByIPUDP(serverip, serverport, true); - if (pServer && thePrefs::IsServerCryptLayerUDPEnabled() && - ((pServer->GetServerKeyUDP() != 0 && pServer->SupportsObfuscationUDP()) || (pServer->GetCryptPingReplyPending() && pServer->GetChallenge() != 0))) -@@ -238,7 +238,7 @@ void CServerUDPSocket::ProcessPacket(CMemFile& packet, uint8 opcode, uint32 ip, - // eserver 16.45+ supports a new OP_SERVER_DESC_RES answer, if the OP_SERVER_DESC_REQ contains a uint32 - // challenge, the server returns additional info with OP_SERVER_DESC_RES. To properly distinguish the - // old and new OP_SERVER_DESC_RES answer, the challenge has to be selected carefully. The first 2 bytes -- // of the challenge (in network byte order) MUST NOT be a valid string-len-int16! -+ // of the challenge (in network uint8_t order) MUST NOT be a valid string-len-int16! - CPacket* sendpacket = new CPacket(OP_SERVER_DESC_REQ, 4, OP_EDONKEYPROT); - uint32 uDescReqChallenge = ((uint32)GetRandomUint16() << 16) + INV_SERV_DESC_LEN; // 0xF0FF = an 'invalid' string length. - update->SetDescReqChallenge(uDescReqChallenge); -@@ -263,7 +263,7 @@ void CServerUDPSocket::ProcessPacket(CMemFile& packet, uint8 opcode, uint32 ip, - // new packet: - // - // NOTE: To properly distinguish between the two packets which are both useing the same opcode... -- // the first two bytes of (in network byte order) have to be an invalid at least. -+ // the first two bytes of (in network uint8_t order) have to be an invalid at least. - - uint16 Len = packet.ReadUInt16(); - -@@ -365,7 +365,7 @@ void CServerUDPSocket::SendPacket(CPacket* packet, CServer* host, bool delPacket - // We might need to encrypt the packet for this server. - if (!rawpacket && thePrefs::IsServerCryptLayerUDPEnabled() && host->GetServerKeyUDP() != 0 && host->SupportsObfuscationUDP()) { - uint16 uRawPacketSize = packet->GetPacketSize() + 2; -- byte* pRawPacket = new byte[uRawPacketSize]; -+ uint8_t* pRawPacket = new uint8_t[uRawPacketSize]; - memcpy(pRawPacket, packet->GetUDPHeader(), 2); - memcpy(pRawPacket + 2, packet->GetDataBuffer(), packet->GetPacketSize()); - -diff --git a/src/ServerUDPSocket.h b/src/ServerUDPSocket.h -index 6caed5d..a7acfea 100644 ---- a/src/ServerUDPSocket.h -+++ b/src/ServerUDPSocket.h -@@ -44,7 +44,7 @@ public: - virtual void OnReceiveError(int errorCode, uint32 ip, uint16 port); - - private: -- void OnPacketReceived(uint32 ip, uint16 port, byte* buffer, size_t length); -+ void OnPacketReceived(uint32 ip, uint16 port, uint8_t* buffer, size_t length); - void ProcessPacket(CMemFile& packet, uint8 opcode, uint32 ip, uint16 port); - void SendQueue(); - -diff --git a/src/Statistics.cpp b/src/Statistics.cpp -index 23ce7a2..d8896a8 100644 ---- a/src/Statistics.cpp -+++ b/src/Statistics.cpp -@@ -403,7 +403,7 @@ void CStatistics::RecordHistory() - // running average computations, use differences (delta bytes/ delta time), and - // for long uptimes the difference between two timestamps can lose too much - // accuracy because the large mantissa causes less significant bits to be dropped -- // (same for the difference between two cumulative byte counts). [We don't store -+ // (same for the difference between two cumulative uint8_t counts). [We don't store - // these values as integers because they will be used in floating point calculations, - // and we want to perform the conversion only once). Therefore timestamps and - // Kbyte counts are stored in the history as doubles, while computed values use -diff --git a/src/Tag.cpp b/src/Tag.cpp -index 2e7e0c8..29475c4 100644 ---- a/src/Tag.cpp -+++ b/src/Tag.cpp -@@ -286,7 +286,7 @@ uint32 CTag::GetBlobSize() const - } - - --const byte* CTag::GetBlob() const -+const uint8_t* CTag::GetBlob() const - { - CHECK_TAG_TYPE(IsBlob(), Blob); - -@@ -302,7 +302,7 @@ uint32 CTag::GetBsobSize() const - } - - --const byte* CTag::GetBsob() const -+const uint8_t* CTag::GetBsob() const - { - CHECK_TAG_TYPE(IsBsob(), Bsob); - -diff --git a/src/Tag.h b/src/Tag.h -index eb5ae25..a57f00a 100644 ---- a/src/Tag.h -+++ b/src/Tag.h -@@ -70,10 +70,10 @@ public: - - const CMD4Hash& GetHash() const; - -- const byte* GetBlob() const; -+ const uint8_t* GetBlob() const; - uint32 GetBlobSize() const; - -- const byte* GetBsob() const; -+ const uint8_t* GetBsob() const; - uint32 GetBsobSize() const; - - CTag* CloneTag() { return new CTag(*this); } -@@ -268,11 +268,11 @@ public: - class CTagBsob : public CTag - { - public: -- CTagBsob(const wxString& name, const byte* value, uint8 nSize) -+ CTagBsob(const wxString& name, const uint8_t* value, uint8 nSize) - : CTag(name) - { - m_uType = TAGTYPE_BSOB; -- m_pData = new byte[nSize]; -+ m_pData = new uint8_t[nSize]; - memcpy(m_pData, value, nSize); - m_nSize = nSize; - } -@@ -281,11 +281,11 @@ public: - class CTagBlob : public CTag - { - public: -- CTagBlob(const wxString& name, const byte* value, uint8 nSize) -+ CTagBlob(const wxString& name, const uint8_t* value, uint8 nSize) - : CTag(name) - { - m_uType = TAGTYPE_BLOB; -- m_pData = new byte[nSize]; -+ m_pData = new uint8_t[nSize]; - memcpy(m_pData, value, nSize); - m_nSize = nSize; - } -diff --git a/src/ThreadTasks.cpp b/src/ThreadTasks.cpp -index 327ab7e..2a43d00 100644 ---- a/src/ThreadTasks.cpp -+++ b/src/ThreadTasks.cpp -@@ -42,7 +42,7 @@ - #endif - - //! This hash represents the value for an empty MD4 hashing --const byte g_emptyMD4Hash[16] = { -+const uint8_t g_emptyMD4Hash[16] = { - 0x31, 0xD6, 0xCF, 0xE0, 0xD1, 0x6A, 0xE9, 0x31, - 0xB7, 0x3C, 0x59, 0xD7, 0xE0, 0xC0, 0x89, 0xC0 }; - -@@ -383,7 +383,7 @@ bool CAICHSyncTask::ConvertToKnown2ToKnown264() - CAICHHash aichHash(&oldfile); - uint32 nHashCount = oldfile.ReadUInt16(); - -- CScopedArray buffer(nHashCount * CAICHHash::GetHashSize()); -+ CScopedArray buffer(nHashCount * CAICHHash::GetHashSize()); - - oldfile.Read(buffer.get(), nHashCount * CAICHHash::GetHashSize()); - newfile.Write(aichHash.GetRawHash(), CAICHHash::GetHashSize()); -diff --git a/src/UploadBandwidthThrottler.cpp b/src/UploadBandwidthThrottler.cpp -index 67ebabf..17bcaba 100644 ---- a/src/UploadBandwidthThrottler.cpp -+++ b/src/UploadBandwidthThrottler.cpp -@@ -294,7 +294,7 @@ void* UploadBandwidthThrottler::Entry() - uint32 sleepTime; - if (bytesToSpend < 1) { - // We have sent more than allowed in last cycle so we have to wait now -- // until we can send at least 1 byte. -+ // until we can send at least 1 uint8_t. - sleepTime = std::max((-bytesToSpend + 1) * 1000 / allowedDataRate + 2, // add 2 ms to allow for rounding inaccuracies - extraSleepTime); - } else { -diff --git a/src/UploadClient.cpp b/src/UploadClient.cpp -index a74ab92..5c7522a 100644 ---- a/src/UploadClient.cpp -+++ b/src/UploadClient.cpp -@@ -206,7 +206,7 @@ void CUpDownClient::CreateNextBlockPackage() - // correctly treated as plain CKnownFile. - CPartFile* srcPartFile = srcfile->IsPartFile() ? static_cast(srcfile) : NULL; - -- // THIS EndOffset points BEHIND the last byte requested -+ // THIS EndOffset points BEHIND the last uint8_t requested - // (other than the offsets used in the PartFile code) - if (currentblock->EndOffset > srcfile->GetFileSize()) { - throw wxString(CFormat(wxT("Asked for data up to %d beyond end of file (%d)")) -@@ -282,7 +282,7 @@ void CUpDownClient::CreateNextBlockPackage() - } - - --void CUpDownClient::CreateStandardPackets(const byte* buffer, uint32 togo, Requested_Block_Struct* currentblock) -+void CUpDownClient::CreateStandardPackets(const uint8_t* buffer, uint32 togo, Requested_Block_Struct* currentblock) - { - uint32 nPacketSize; - -@@ -330,10 +330,10 @@ void CUpDownClient::CreateStandardPackets(const byte* buffer, uint32 togo, Reque - } - - --void CUpDownClient::CreatePackedPackets(const byte* buffer, uint32 togo, Requested_Block_Struct* currentblock) -+void CUpDownClient::CreatePackedPackets(const uint8_t* buffer, uint32 togo, Requested_Block_Struct* currentblock) - { - uLongf newsize = togo+300; -- CScopedArray output(newsize); -+ CScopedArray output(newsize); - uint16 result = compress2(output.get(), &newsize, buffer, togo, 9); - if (result != Z_OK || togo <= newsize){ - CreateStandardPackets(buffer, togo, currentblock); -@@ -836,7 +836,7 @@ void CUpDownClient::SetUploadFileID(const CMD4Hash& new_id) - SetUploadFileID(uploadingfile); // This will update queue count on old and new file. - } - --void CUpDownClient::ProcessRequestPartsPacket(const byte* pachPacket, uint32 nSize, bool largeblocks) { -+void CUpDownClient::ProcessRequestPartsPacket(const uint8_t* pachPacket, uint32 nSize, bool largeblocks) { - - CMemFile data(pachPacket, nSize); - -diff --git a/src/kademlia/kademlia/Kademlia.cpp b/src/kademlia/kademlia/Kademlia.cpp -index f0f657b..70ca262 100644 ---- a/src/kademlia/kademlia/Kademlia.cpp -+++ b/src/kademlia/kademlia/Kademlia.cpp -@@ -499,7 +499,7 @@ bool CKademlia::IsRunningInLANMode() - #include "../../CryptoPP_Inc.h" - void KadGetKeywordHash(const wxString& rstrKeyword, Kademlia::CUInt128* pKadID) - { -- byte Output[16]; -+ uint8_t Output[16]; - - #ifdef __WEAK_CRYPTO__ - CryptoPP::Weak::MD4 md4_hasher; -diff --git a/src/kademlia/kademlia/Search.cpp b/src/kademlia/kademlia/Search.cpp -index e60a354..0177caa 100644 ---- a/src/kademlia/kademlia/Search.cpp -+++ b/src/kademlia/kademlia/Search.cpp -@@ -509,7 +509,7 @@ void CSearch::StorePacket() - } else { - if (m_searchTermsDataSize == 0) { - searchTerms.WriteUInt8(0); -- // We send this extra byte to flag we handle large files. -+ // We send this extra uint8_t to flag we handle large files. - searchTerms.WriteUInt8(0); - } else { - // Set to 2 to flag we handle large files. -diff --git a/src/kademlia/kademlia/SearchManager.cpp b/src/kademlia/kademlia/SearchManager.cpp -index e7f25d4..34200d5 100644 ---- a/src/kademlia/kademlia/SearchManager.cpp -+++ b/src/kademlia/kademlia/SearchManager.cpp -@@ -234,8 +234,8 @@ void CSearchManager::GetWords(const wxString& str, WordList *words, bool allowDu - while (tkz.HasMoreTokens()) { - current_word = tkz.GetNextToken(); - // TODO: We'd need a safe way to determine if a sequence which contains only 3 chars is a real word. -- // Currently we do this by evaluating the UTF-8 byte count. This will work well for Western locales, -- // AS LONG AS the min. byte count is 3(!). If the byte count is once changed to 2, this will not -+ // Currently we do this by evaluating the UTF-8 uint8_t count. This will work well for Western locales, -+ // AS LONG AS the min. uint8_t count is 3(!). If the uint8_t count is once changed to 2, this will not - // work properly any longer because there are a lot of Western characters which need 2 bytes in UTF-8. - // Maybe we need to evaluate the Unicode character values itself whether the characters are located - // in code ranges where single characters are known to represent words. -diff --git a/src/kademlia/net/KademliaUDPListener.cpp b/src/kademlia/net/KademliaUDPListener.cpp -index e11dd5e..16e91c7 100644 ---- a/src/kademlia/net/KademliaUDPListener.cpp -+++ b/src/kademlia/net/KademliaUDPListener.cpp -@@ -1668,7 +1668,7 @@ void CKademliaUDPListener::SendLegacyChallenge(uint32_t ip, uint16_t port, const - } - - #if 0 --void CKademliaUDPListener::DebugClientOutput(const wxString& place, uint32 kad_ip, uint32 port, const byte* data, int len) -+void CKademliaUDPListener::DebugClientOutput(const wxString& place, uint32 kad_ip, uint32 port, const uint8_t* data, int len) - { - uint32 ip = wxUINT32_SWAP_ALWAYS(kad_ip); - printf("Error on %s received from: %s\n",(const char*)unicode2char(place),(const char*)unicode2char(Uint32_16toStringIP_Port(ip,port))); -diff --git a/src/libs/common/StringFunctions.cpp b/src/libs/common/StringFunctions.cpp -index 3710760..ba1f755 100644 ---- a/src/libs/common/StringFunctions.cpp -+++ b/src/libs/common/StringFunctions.cpp -@@ -48,7 +48,7 @@ Unicode2CharBuf unicode2char(const wxChar* s) - } - // Failed. Try to convert as much as possible. - size_t len = wxStrlen(s); -- size_t maxlen = len * 4; // Allow for an encoding of up to 4 byte per char. -+ size_t maxlen = len * 4; // Allow for an encoding of up to 4 uint8_t per char. - wxCharBuffer buf(maxlen + 1); // This is wasteful, but the string is used temporary anyway. - char * data = buf.data(); - for (size_t i = 0, pos = 0; i < len; i++) { -@@ -64,7 +64,7 @@ Unicode2CharBuf unicode2char(const wxChar* s) - } - - --static byte base16Chars[17] = "0123456789ABCDEF"; -+static uint8_t base16Chars[17] = "0123456789ABCDEF"; - - wxString URLEncode(const wxString& sIn) - { -diff --git a/src/libs/ec/cpp/ECSocket.cpp b/src/libs/ec/cpp/ECSocket.cpp -index a0283cc..22da25c 100644 ---- a/src/libs/ec/cpp/ECSocket.cpp -+++ b/src/libs/ec/cpp/ECSocket.cpp -@@ -66,12 +66,12 @@ struct utf8_table { - - static const struct utf8_table utf8_table[] = - { -- {0x80, 0x00, 0*6, 0x7F, 0, /* 1 byte sequence */}, -- {0xE0, 0xC0, 1*6, 0x7FF, 0x80, /* 2 byte sequence */}, -- {0xF0, 0xE0, 2*6, 0xFFFF, 0x800, /* 3 byte sequence */}, -- {0xF8, 0xF0, 3*6, 0x1FFFFF, 0x10000, /* 4 byte sequence */}, -- {0xFC, 0xF8, 4*6, 0x3FFFFFF, 0x200000, /* 5 byte sequence */}, -- {0xFE, 0xFC, 5*6, 0x7FFFFFFF, 0x4000000, /* 6 byte sequence */}, -+ {0x80, 0x00, 0*6, 0x7F, 0, /* 1 uint8_t sequence */}, -+ {0xE0, 0xC0, 1*6, 0x7FF, 0x80, /* 2 uint8_t sequence */}, -+ {0xF0, 0xE0, 2*6, 0xFFFF, 0x800, /* 3 uint8_t sequence */}, -+ {0xF8, 0xF0, 3*6, 0x1FFFFF, 0x10000, /* 4 uint8_t sequence */}, -+ {0xFC, 0xF8, 4*6, 0x3FFFFFF, 0x200000, /* 5 uint8_t sequence */}, -+ {0xFE, 0xFC, 5*6, 0x7FFFFFFF, 0x4000000, /* 6 uint8_t sequence */}, - {0, 0, 0, 0, 0, /* end of table */} - }; - -diff --git a/src/libs/ec/cpp/ECTag.cpp b/src/libs/ec/cpp/ECTag.cpp -index 7ba9e3a..255f3ac 100644 ---- a/src/libs/ec/cpp/ECTag.cpp -+++ b/src/libs/ec/cpp/ECTag.cpp -@@ -118,7 +118,7 @@ CECTag::CECTag(ec_tagname_t name, const EC_IPv4_t& data) : m_tagName(name) - /** - * Creates a new CECTag instance, which contains a MD4 hash. - * -- * This function takes care to store hash in network byte order. -+ * This function takes care to store hash in network uint8_t order. - * - * @param name TAG name - * @param data The CMD4Hash class containing the MD4 hash. -@@ -1007,7 +1007,7 @@ void CECTag::DebugPrint(int level, bool print_empty) const - case EC_TAGTYPE_UINT128: - // Using any non-inline function from UInt128.h would break linkage - // of remote apps otherwise not using CUInt128. So just fall through -- // and display the value as a byte-stream. Since the value is sent -+ // and display the value as a uint8_t-stream. Since the value is sent - // big-endian on the network, the visual result is correct, except - // for the intervening spaces... - //s2 = GetInt128Data().ToHexString(); break; -diff --git a/src/updownclient.h b/src/updownclient.h -index 2930df4..7dac1e9 100644 ---- a/src/updownclient.h -+++ b/src/updownclient.h -@@ -202,7 +202,7 @@ public: - - void ClearDownloadBlockRequests(); - void RequestSharedFileList(); -- void ProcessSharedFileList(const byte* pachPacket, uint32 nSize, wxString& pszDirectory); -+ void ProcessSharedFileList(const uint8_t* pachPacket, uint32 nSize, wxString& pszDirectory); - void SendSharedDirectories(); - void SendSharedFilesOfDirectory(const wxString& strReqDir); - -@@ -212,13 +212,13 @@ public: - - uint8 GetClientSoft() const { return m_clientSoft; } - void ReGetClientSoft(); -- bool ProcessHelloAnswer(const byte* pachPacket, uint32 nSize); -- bool ProcessHelloPacket(const byte* pachPacket, uint32 nSize); -+ bool ProcessHelloAnswer(const uint8_t* pachPacket, uint32 nSize); -+ bool ProcessHelloPacket(const uint8_t* pachPacket, uint32 nSize); - void SendHelloAnswer(); - bool SendHelloPacket(); - void SendMuleInfoPacket(bool bAnswer, bool OSInfo = false); -- bool ProcessMuleInfoPacket(const byte* pachPacket, uint32 nSize); -- void ProcessMuleCommentPacket(const byte* pachPacket, uint32 nSize); -+ bool ProcessMuleInfoPacket(const uint8_t* pachPacket, uint32 nSize); -+ void ProcessMuleCommentPacket(const uint8_t* pachPacket, uint32 nSize); - bool Compare(const CUpDownClient* tocomp, bool bIgnoreUserhash = false) const; - void SetLastSrcReqTime() { m_dwLastSourceRequest = ::GetTickCount(); } - void SetLastSrcAnswerTime() { m_dwLastSourceAnswer = ::GetTickCount(); } -@@ -234,17 +234,17 @@ public: - - bool SafeSendPacket(CPacket* packet); - -- void ProcessRequestPartsPacket(const byte* pachPacket, uint32 nSize, bool largeblocks); -+ void ProcessRequestPartsPacket(const uint8_t* pachPacket, uint32 nSize, bool largeblocks); - void ProcessRequestPartsPacketv2(const CMemFile& data); - - void SendPublicKeyPacket(); - void SendSignaturePacket(); -- void ProcessPublicKeyPacket(const byte* pachPacket, uint32 nSize); -- void ProcessSignaturePacket(const byte* pachPacket, uint32 nSize); -+ void ProcessPublicKeyPacket(const uint8_t* pachPacket, uint32 nSize); -+ void ProcessSignaturePacket(const uint8_t* pachPacket, uint32 nSize); - uint8 GetSecureIdentState(); - - void SendSecIdentStatePacket(); -- void ProcessSecIdentStatePacket(const byte* pachPacket, uint32 nSize); -+ void ProcessSecIdentStatePacket(const uint8_t* pachPacket, uint32 nSize); - - uint8 GetInfoPacketsReceived() const { return m_byInfopacketsReceived; } - void InfoPacketsReceived(); -@@ -340,12 +340,12 @@ public: - bool AskForDownload(); - void SendStartupLoadReq(); - void SendFileRequest(); -- void ProcessHashSet(const byte* packet, uint32 size); -+ void ProcessHashSet(const uint8_t* packet, uint32 size); - bool AddRequestForAnotherFile(CPartFile* file); - bool DeleteFileRequest(CPartFile* file); - void DeleteAllFileRequests(); - void SendBlockRequests(); -- void ProcessBlockPacket(const byte* packet, uint32 size, bool packed, bool largeblocks); -+ void ProcessBlockPacket(const uint8_t* packet, uint32 size, bool packed, bool largeblocks); - uint16 GetAvailablePartCount() const; - - bool SwapToAnotherFile(bool bIgnoreNoNeeded, bool ignoreSuspensions, bool bRemoveCompletely, CPartFile* toFile = NULL); -@@ -389,14 +389,14 @@ public: - bool IsSupportingAICH() const {return m_fSupportsAICH & 0x01;} - void SendAICHRequest(CPartFile* pForFile, uint16 nPart); - bool IsAICHReqPending() const {return m_fAICHRequested; } -- void ProcessAICHAnswer(const byte* packet, uint32 size); -- void ProcessAICHRequest(const byte* packet, uint32 size); -+ void ProcessAICHAnswer(const uint8_t* packet, uint32 size); -+ void ProcessAICHRequest(const uint8_t* packet, uint32 size); - void ProcessAICHFileHash(CMemFile* data, const CPartFile* file); - - EUtf8Str GetUnicodeSupport() const; - - // Barry - Process zip file as it arrives, don't need to wait until end of block -- int unzip(Pending_Block_Struct *block, byte *zipped, uint32 lenZipped, byte **unzipped, uint32 *lenUnzipped, int iRecursion = 0); -+ int unzip(Pending_Block_Struct *block, uint8_t *zipped, uint32 lenZipped, uint8_t **unzipped, uint32 *lenUnzipped, int iRecursion = 0); - void UpdateDisplayedInfo(bool force = false); - int GetFileListRequested() const { return m_iFileListRequested; } - void SetFileListRequested(int iFileListRequested) { m_iFileListRequested = iFileListRequested; } -@@ -413,7 +413,7 @@ public: - - const wxString& GetClientOSInfo() const { return m_sClientOSInfo; } - -- void ProcessPublicIPAnswer(const byte* pbyData, uint32 uSize); -+ void ProcessPublicIPAnswer(const uint8_t* pbyData, uint32 uSize); - void SendPublicIPRequest(); - - /** -@@ -473,8 +473,8 @@ public: - - /* Kad buddy support */ - // ID -- const byte* GetBuddyID() const { return m_achBuddyID; } -- void SetBuddyID(const byte* m_achTempBuddyID); -+ const uint8_t* GetBuddyID() const { return m_achBuddyID; } -+ void SetBuddyID(const uint8_t* m_achTempBuddyID); - bool HasValidBuddyID() const { return m_bBuddyIDValid; } - /* IP */ - void SetBuddyIP( uint32 val ) { m_nBuddyIP = val; } -@@ -789,7 +789,7 @@ private: - ESourceFrom m_nSourceFrom; - - /* Kad Stuff */ -- byte m_achBuddyID[16]; -+ uint8_t m_achBuddyID[16]; - bool m_bBuddyIDValid; - uint32 m_nBuddyIP; - uint16 m_nBuddyPort; -diff --git a/src/utils/aLinkCreator/src/md4.cpp b/src/utils/aLinkCreator/src/md4.cpp -index 52c7b7f..595fc19 100644 ---- a/src/utils/aLinkCreator/src/md4.cpp -+++ b/src/utils/aLinkCreator/src/md4.cpp -@@ -43,7 +43,7 @@ - #include "bithelp.h" - - --/// BIG ENDIAN byte reversing -+/// BIG ENDIAN uint8_t reversing - #if wxBYTE_ORDER == wxBIG_ENDIAN - // Note: this code is harmless on little-endian machines. - void MD4::byteReverse(unsigned char *buf, unsigned longs) -@@ -106,7 +106,7 @@ void MD4::MD4Update(struct MD4Context *ctx, unsigned char const *buf, - len -= t; - } - -- // Process data in 64-byte chunks -+ // Process data in 64-uint8_t chunks - while (len >= 64) - { - memcpy(ctx->in, buf, 64); -@@ -121,7 +121,7 @@ void MD4::MD4Update(struct MD4Context *ctx, unsigned char const *buf, - } - - --/// Final wrapup - pad to 64-byte boundary with the bit pattern -+/// Final wrapup - pad to 64-uint8_t boundary with the bit pattern - /// 1 0* (64-bit count of bits processed, MSB-first) - void MD4::MD4Final(struct MD4Context *ctx, unsigned char* digest) - { -@@ -132,7 +132,7 @@ void MD4::MD4Final(struct MD4Context *ctx, unsigned char* digest) - count = (ctx->bits[0] >> 3) & 0x3F; - - // Set the first char of padding to 0x80. -- //This is safe since there is always at least one byte free -+ //This is safe since there is always at least one uint8_t free - p = ctx->in + count; - *p++ = 0x80; - -diff --git a/src/utils/aLinkCreator/src/md4.h b/src/utils/aLinkCreator/src/md4.h -index c54167e..ebda1e2 100644 ---- a/src/utils/aLinkCreator/src/md4.h -+++ b/src/utils/aLinkCreator/src/md4.h -@@ -77,7 +77,7 @@ class MD4 - - size_t calcBufSize(size_t filesize); - -- // Needed to reverse byte order on BIG ENDIAN machines -+ // Needed to reverse uint8_t order on BIG ENDIAN machines - #if wxBYTE_ORDER == wxBIG_ENDIAN - - void byteReverse(unsigned char *buf, unsigned longs); -diff --git a/src/utils/fileview/KadFiles.cpp b/src/utils/fileview/KadFiles.cpp -index a2ded24..c1e497e 100644 ---- a/src/utils/fileview/KadFiles.cpp -+++ b/src/utils/fileview/KadFiles.cpp -@@ -52,7 +52,7 @@ void DecodeLoadIndexDat(const CFileDataIO& file) - #include "../../CryptoPP_Inc.h" - void KadGetKeywordHash(const wxString& rstrKeyword, Kademlia::CUInt128* pKadID) - { -- byte Output[16]; -+ uint8_t Output[16]; - #ifdef CRYPTOPP_ENABLE_NAMESPACE_WEAK - CryptoPP::Weak::MD4 md4_hasher; - #else -@@ -62,7 +62,7 @@ void KadGetKeywordHash(const wxString& rstrKeyword, Kademlia::CUInt128* pKadID) - // This should be safe - we assume rstrKeyword is ANSI anyway. - Unicode2CharBuf ansi_buffer(unicode2UTF8(rstrKeyword)); - -- md4_hasher.CalculateDigest(Output, (const byte *) (const char *) ansi_buffer, strlen(ansi_buffer)); -+ md4_hasher.CalculateDigest(Output, (const uint8_t *) (const char *) ansi_buffer, strlen(ansi_buffer)); - - pKadID->SetValueBE(Output); - } --- -2.17.1 - diff --git a/amule/patches/0003-fix-set_terminate.patch b/amule/patches/0003-fix-set_terminate.patch deleted file mode 100644 index 924a001e9..000000000 --- a/amule/patches/0003-fix-set_terminate.patch +++ /dev/null @@ -1,25 +0,0 @@ -From dcc605e06e106b05bc5e756eeeeb17abbc1a6e5c Mon Sep 17 00:00:00 2001 -From: W_Y_CPP <383152993@qq.com> -Date: Wed, 1 Dec 2021 23:13:08 -0800 -Subject: [PATCH] fix set_terminate - ---- - src/libs/common/MuleDebug.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/libs/common/MuleDebug.cpp b/src/libs/common/MuleDebug.cpp -index 5d8d758..14206f9 100644 ---- a/src/libs/common/MuleDebug.cpp -+++ b/src/libs/common/MuleDebug.cpp -@@ -24,7 +24,7 @@ - // - - #include // Needed for std::abort() -- -+#include - #ifdef HAVE_CONFIG_H - # include "config.h" // Needed for HAVE_CXXABI and HAVE_EXECINFO - #endif --- -2.17.1 - diff --git a/amule/patches/001-amule-dlp.patch b/amule/patches/001-amule-dlp.patch deleted file mode 100644 index 5a37a27a6..000000000 --- a/amule/patches/001-amule-dlp.patch +++ /dev/null @@ -1,1548 +0,0 @@ -diff -Naur a/configure.ac b/configure.ac ---- a/configure.ac 2016-10-06 19:01:54.000000000 +0800 -+++ b/configure.ac 2016-10-14 12:33:51.660347919 +0800 -@@ -89,6 +89,14 @@ - KDE_CONFIG_OPTIONS - QT_CONFIG_OPTIONS - -+#Dynamic Leecher Protection - Bill Lee -+AC_ARG_ENABLE( -+ [dlp], -+ [AS_HELP_STRING( -+ [--disable-dlp], -+ [Do not compile DLP.])], -+ [ENABLE_DLP=$enableval], [ENABLE_DLP=yes]) -+ - # Default is yes, because they're most likely compatible. - # However, this is only used when cross-compiling. - AC_ARG_WITH( -@@ -457,6 +465,8 @@ - AM_CONDITIONAL(GENERATE_FLEX_HEADER, test x$HAVE_FLEX_EXTENDED = xyes) - AM_CONDITIONAL(INSTALL_SKINS, test MULE_IS_ENABLED_ANY([monolithic, amule-gui])) - AM_CONDITIONAL(PLASMAMULE, test MULE_IS_ENABLED([plasmamule])) -+#Dynamic Leech Protection - Bill Lee -+AM_CONDITIONAL(ENABLE_DLP, test x$ENABLE_DLP = xyes) - - AM_CONDITIONAL([COMPILE_LIB_COMMON], [test MULE_IS_ENABLED_ANY([monolithic, amule-daemon, amulecmd, webserver, amule-gui, fileview])]) - AM_CONDITIONAL([COMPILE_LIB_EC], [test MULE_IS_ENABLED_ANY([monolithic, amule-daemon, amulecmd, webserver, amule-gui])]) -diff -Naur a/po/zh_CN.po b/po/zh_CN.po ---- a/po/zh_CN.po 2016-10-06 19:01:54.000000000 +0800 -+++ b/po/zh_CN.po 2016-10-14 12:33:51.662347964 +0800 -@@ -5,6 +5,7 @@ - # xiaoqiao <29551030@qq.com>, 2007, 2008. - # JimHu , 2009. - # Xiaoqiao , 2010. -+# Bill Lee , 2010, 2011. - # Yi Qi ,2011. - # - msgid "" -@@ -467,6 +468,12 @@ - msgid "http://kademlia.scs.cs.nyu.edu\n" - msgstr "http://kademlia.scs.cs.nyu.edu\n" - -+msgid "\nDynamic Leech Protection\n" -+msgstr "\n动态吸血保护\n" -+ -+msgid " Homepage: http://amule-dlp.googlecode.com \n" -+msgstr " 主页:http://amule-dlp.googlecode.com \n" -+ - #: src/amuleDlg.cpp:512 src/KadDlg.cpp:193 src/PartFile.cpp:918 - #: src/PartFile.cpp:926 src/PrefsUnifiedDlg.cpp:629 - #: src/PrefsUnifiedDlg.cpp:734 src/PrefsUnifiedDlg.cpp:847 -@@ -3856,6 +3863,9 @@ - msgid "Click on this button to update the nodes list from URL ..." - msgstr "按此更新节点列表自网址..." - -+msgid "DLP Info" -+msgstr "动态反吸血信息" -+ - #: src/muuli_wdr.cpp:2649 - msgid "Nodes (0)" - msgstr "节点(0)" -@@ -7682,6 +7692,48 @@ - #~ "\n" - #~ "此外,浏览器设定已经被重设为系统默认值。如有必要,请重新配置浏览器选项。\n" - -+msgid "Dynamic Leecher Protection Options" -+msgstr "动态反吸血保护选项" -+ -+msgid "Reload antiLeech" -+msgstr "重新装载 antiLeech" -+ -+msgid "Check bad modstring" -+msgstr "根据 Mod 名字检测吸血驴" -+ -+msgid "Check bad username" -+msgstr "根据用户名字检测吸血驴" -+ -+msgid "Check bad userhash" -+msgstr "检测错误的用户哈希值" -+ -+msgid "Check bad hello tag" -+msgstr "根据握手标签(HelloTag)检测吸血驴" -+ -+msgid "Check bad info tag" -+msgstr "根据 InfoTag 检测吸血驴" -+ -+msgid "Check ghost mod" -+msgstr "检测幽灵客户端(Ghost Mod)" -+ -+#~ msgid "Ban VeryCD easyMule2" -+#~ msgstr "屏蔽 VeryCD easyMule2" -+ -+msgid "Ban eMule VeryCD mod(Please consider carefully whether to use)" -+msgstr "屏蔽 VeryCD eMule(请慎重考虑是否使用)" -+ -+#~ msgid "Ban VeryCD miniMule" -+#~ msgstr "屏蔽 VeryCD miniMule" -+ -+msgid "Trying to load antiLeech..." -+msgstr "尝试加载 antiLeech..." -+ -+msgid "No antiLeech available!" -+msgstr "未找到 antiLeech!" -+ -+msgid "Succeed loading antiLeech! Version: %d" -+msgstr "成功加载 antiLeech! 版本: %d" -+ - #~ msgid "Fetching status..." - #~ msgstr "正在获取状态..." - -diff -Naur a/src/BaseClient.cpp b/src/BaseClient.cpp ---- a/src/BaseClient.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/BaseClient.cpp 2016-10-14 12:35:45.793953665 +0800 -@@ -1,4 +1,3 @@ --// - // This file is part of the aMule Project. - // - // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) -@@ -23,6 +22,11 @@ - // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - // - -+//Dynamic Leech Protect - Bill Lee -+#ifdef AMULE_DLP -+#include "DLP.h" -+#endif -+ - #include - #include - #include -@@ -83,10 +87,8 @@ - #include "kademlia/kademlia/UDPFirewallTester.h" - #include "kademlia/routing/RoutingZone.h" - -- - //#define __PACKET_DEBUG__ - -- - // some client testing variables - static wxString crash_name = wxT("[Invalid User Name]"); - static wxString empty_name = wxT("[Empty User Name]"); -@@ -290,6 +292,10 @@ - m_cMessagesReceived = 0; - m_cMessagesSent = 0; - -+ #ifdef AMULE_DLP -+ dlp_nonofficialopcodes = false; //Dynamic Leecher Protect -+ #endif -+ - } - - -@@ -635,6 +641,15 @@ - m_fSharedDirectories = 1; - dwEmuleTags |= 4; - break; -+ //Bill Lee start -+ //Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ default: //if tag isn't those above, it may be used by leecher. -+ theDLP->CheckHelloTag(this, temptag.GetNameID()); -+ dlp_nonofficialopcodes = true; //to detect Ghost Mod -+ break; -+ //Bill Lee end -+ #endif - } - } - -@@ -717,6 +732,11 @@ - Kademlia::CKademlia::Bootstrap(wxUINT32_SWAP_ALWAYS(GetIP()), GetKadPort()); - } - -+ //Dynamic Leecher Protection - Bill Lee -+ #ifdef AMULE_DLP -+ theDLP->DLPCheck(this); -+ #endif -+ - return bIsMule; - } - -@@ -966,6 +986,14 @@ - % GetClientFullInfo() - ); - -+ //Bill Lee start -+ //Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ theDLP->CheckInfoTag(this, temptag.GetNameID()); -+ dlp_nonofficialopcodes = true; -+ #endif -+ //Bill Lee end -+ - break; - } - } -@@ -1003,6 +1031,11 @@ - m_byInfopacketsReceived |= IP_EMULEPROTPACK; - } - -+ //Dynamic Leecher Protection - Added by Bill Lee -+ #ifdef AMULE_DLP -+ theDLP->DLPCheck(this); -+ #endif -+ - return (protocol_version == 0xFF); // This was a OS_Info? - } - -@@ -2302,7 +2335,7 @@ - } - - --#ifdef __DEBUG__ -+#if defined (__DEBUG__) || defined (AMULE_DLP) - wxString CUpDownClient::GetClientFullInfo() - { - if (m_clientVerString.IsEmpty()) { -diff -Naur a/src/CString_wx.h b/src/CString_wx.h ---- a/src/CString_wx.h 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/CString_wx.h 2016-10-14 12:33:51.664348010 +0800 -@@ -0,0 +1,59 @@ -+/** -+ * Author: Bill Lee -+ * License: GNU GPL -+ */ -+//--------------------- -+#ifndef CSTRING_WX_H -+#define CSTRING_WX_H -+ -+//#include -+#include -+ -+class CString : public wxString{ -+ public: -+ CString(){} -+ CString(wxChar c, size_t n=1): wxString(c, n){} -+ CString(const wxChar* str): wxString(str){} -+ CString(const wxString& str): wxString(str){} -+ CString(const CString& str): wxString(str){} -+ //--------------------- -+ CString& operator=(const wxChar* str){ -+ wxString::operator=(str); -+ return *this; -+ } -+ //operator*() from wxString; -+ size_t GetLength()const{ return Length(); } -+ wxChar GetAt(size_t nIndex)const{ return GetChar(nIndex); } -+ //IsEmpty() from wxString; -+ CString& TrimLeft(wxChar c){ -+ size_t pos = find_first_not_of(c); -+ if(pos == 0) -+ return *this; -+ erase(0, pos); -+ return *this; -+ } -+ CString& TrimRight(wxChar c){ -+ size_t pos = find_last_not_of(c) + 1; -+ if(pos == Length()) -+ return *this; -+ erase(pos, Length() - pos); -+ return *this; -+ } -+ CString Trim(){ -+ CString ret(*this); -+ ret.wxString::Trim(false); /* wxString::Trim(bool fromright = true) */ -+ ret.wxString::Trim(true); -+ return ret; -+ } -+ //Find(wxChar) and Find(wxChar*) from wxString; -+ int Find(const CString& str)const{ return wxString::Find(str.c_str()); } -+ int ReverseFind(const wxChar c)const{ return wxString::Find(c, true); } -+ int ReverseFind(const wxChar* str)const{ return rfind(str); } -+ int ReverseFind(const CString& str)const{ return rfind(str); } -+ CString Right(size_t len)const{ return wxString::Right(len); } -+ CString Left(size_t len)const{ return wxString::Left(len); } -+ CString Mid(size_t first, size_t count = wxSTRING_MAXLEN)const{ -+ return wxString::Mid(first, count); -+ } -+}; -+#endif -diff -Naur a/src/DLP.cpp b/src/DLP.cpp ---- a/src/DLP.cpp 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/DLP.cpp 2016-10-14 12:33:51.664348010 +0800 -@@ -0,0 +1,190 @@ -+// Copyright (C) 2011 Bill Lee -+// -+// This program is free software; you can redistribute it and/or modify -+// it under the terms of the GNU General Public License as published by -+// the Free Software Foundation; either version 2 of the License, or -+// (at your option) any later version. -+// -+// This program is distributed in the hope that it will be useful, -+// but WITHOUT ANY WARRANTY; without even the implied warranty of -+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+// GNU General Public License for more details. -+// -+// You should have received a copy of the GNU General Public License -+// along with this program; if not, write to the Free Software -+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -+// -+#include "Logger.h" -+ -+#include "DLP.h" -+#include "antiLeech.h" -+#include /* Needed for wxDynamicLibrary */ -+ -+#include "DLPPref.h" -+#include "Preferences.h" // Needed for CPreferences -+#include "amule.h" // Needed for theApp -+ -+#include /* Needed for wxStandardPaths */ -+ -+#define PRE_CHECK(tag) if( (!c->IsBanned()) && antiLeech && (thePrefs::GetDLPCheckMask() & tagn) ) -+ -+void DLP::CheckHelloTag(CUpDownClient* c, UINT tagn){ -+ PRE_CHECK(PF_HELLOTAG){ -+ const wxChar* dlp_result = antiLeech->DLPCheckHelloTag(tagn); -+ if(dlp_result != NULL) { -+ wxString ret; -+ ret.Printf(_("[HelloTag %s] %s"), dlp_result, c->GetClientFullInfo().c_str()); -+ //ret.Printf(_("[HelloTag %s] %s"), dlp_result, c->GetClientShortInfo().c_str()); -+ c->Ban(); -+ theApp->AddDLPMessageLine(ret); -+ } -+ } -+} -+ -+void DLP::CheckInfoTag(CUpDownClient* c, UINT tagn){ -+ PRE_CHECK(PF_INFOTAG){ -+ const wxChar* dlp_result = antiLeech->DLPCheckInfoTag(tagn); -+ if(dlp_result != NULL) { -+ wxString ret; -+ ret.Printf(_("[InfoTag %s] %s"), dlp_result, c->GetClientFullInfo().c_str()); -+ //ret.Printf(_("[InfoTag %s] %s"), dlp_result, c->GetClientShortInfo().c_str()); -+ c->Ban(); -+ theApp->AddDLPMessageLine(ret); -+ } -+ } -+} -+ -+bool DLP::DLPCheck(CUpDownClient* c){ -+ const wxChar* tmp = NULL; -+ wxString ret; -+ -+ unsigned int prefs = thePrefs::GetDLPCheckMask(); -+ -+ CString modver(c->GetClientModString()); -+ CString clientver(c->GetClientVerString()); -+ CString uname(c->GetUserName()); -+ CString uhash(wxString(c->GetUserHash().EncodeSTL().c_str(), wxConvUTF8)); -+ -+ //CheckGhostMod -+ if(prefs & PF_GHOSTMOD) { -+ if(c->HasNonOfficialOpCodes() && (modver.IsEmpty())) { -+ ret = _("GhostMod"); -+ tmp = ret.c_str(); //char pointer -+ } -+ } -+ -+ // Check bad modstring -+ if ((prefs & PF_MODSTRING) && (tmp == NULL)) { -+ if((tmp = antiLeech->DLPCheckModstring_Soft(modver.c_str(), clientver.c_str())) == NULL) -+ tmp = antiLeech->DLPCheckModstring_Hard(modver.c_str(), clientver.c_str()); -+ } -+ /* -+ if ((prefs & PF_USERHASH) && (tmp == NULL)) { -+ // not finished -+ } -+ */ -+ // Check bad username -+ if ((prefs & PF_USERNAME) && (tmp == NULL)) { -+ if ((tmp = antiLeech->DLPCheckNameAndHashAndMod(uname, uhash, modver)) == NULL){ -+ if( (tmp = antiLeech->DLPCheckUsername_Hard(uname.c_str())) == NULL ) -+ tmp = antiLeech->DLPCheckUsername_Soft(uname.c_str()); -+ } -+ } -+ -+ -+ // Check VeryCD eMule -+ if ((prefs & PF_VERYCDEMULE) && (tmp == NULL)) { -+ if(modver.Find(wxT("VeryCD")) != wxNOT_FOUND){ -+ ret = _("VeryCD Mod"); -+ tmp = ret.c_str(); -+ } -+ } -+ -+ if (tmp != NULL) { -+ ret = tmp; -+ wxString wxInfo; -+ wxInfo.Printf(wxT("[%s] %s"), ret.c_str(), c->GetClientFullInfo().c_str()); -+ //wxInfo.Printf(wxT("[%s] %s"), ret.c_str(), c->GetClientShortInfo().c_str()); -+ c->Ban(); -+ theApp->AddDLPMessageLine(wxInfo); -+ return true; -+ } -+ -+ return false; -+ -+} -+ -+int DLP::ReloadAntiLeech(){ -+ //Unloading -+ AddLogLineN( _("Checking if there is a antiLeech working...")); -+ if(antiLeechLib.IsLoaded()){ -+ Destoryer fn = (Destoryer)(antiLeechLib.GetSymbol( wxT("destoryAntiLeechInstant"))); -+ wxASSERT(fn); -+ AddLogLineN( _("Unload previous antiLeech...")); -+ fn(antiLeech); -+ antiLeech = NULL; -+ antiLeechLib.Unload(); -+ } -+ else -+ AddLogLineN( _("No working antiLeech exists.")); -+ //Get lib's location -+ wxStandardPathsBase &spb(wxStandardPaths::Get()); -+#ifdef __WXMSW__ -+ wxString dataDir(spb.GetPluginsDir()); -+#elif defined(__WXMAC__) -+ wxString dataDir(spb.GetDataDir()); -+#else -+ wxString dataDir(spb.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule")); -+#endif -+ wxString localName = wxDynamicLibrary::CanonicalizeName(wxT("antiLeech")); -+ wxString systemwideFile(JoinPaths(dataDir, localName)); -+ //wxString userFile(theApp->ConfigDir + localName); -+ wxString userFile(thePrefs::GetConfigDir() + localName); -+ wxString fallbackFile(wxT("antiLeech")); -+ //Try to load lib; -+ AddLogLineN( _("Trying to load antiLeech...")); -+ if( !LoadFrom(userFile) ){ -+ if( !LoadFrom(systemwideFile) ){ -+ if( !LoadFrom(fallbackFile) ){ -+ AddLogLineC( _("No antiLeech available!")); -+ return 1; //Not found -+ } -+ } -+ } -+ //Searching symbol "createAntiLeechInstant" -+ Creator fn = (Creator)(antiLeechLib.GetSymbol( wxT("createAntiLeechInstant") )); -+ if(!fn){ -+ antiLeechLib.Unload(); -+ AddLogLineC( _("antiLeech found, but it seems not to be a valid antiLeech!")); -+ return 2; //Found, but isn't antiLeech -+ } -+ //Try to create antiLeech -+ antiLeech = fn(); -+ if(antiLeech){ -+ wxString logline; -+ logline.Printf(_("Succeed loading antiLeech! Version: %d"), antiLeech->GetDLPVersion()); -+ AddLogLineC( logline); -+ return 0; -+ } -+ //else -+ antiLeechLib.Unload(); -+ AddLogLineC( _("FAIL! An error occur when setting up antiLeech.")); -+ return 3; //Fail to create antiLeech instant -+ -+} -+ -+DLP::~DLP(){ -+ if(antiLeechLib.IsLoaded()){ -+ Destoryer fn = (Destoryer)(antiLeechLib.GetSymbol( wxT("destoryAntiLeechInstant"))); -+ wxASSERT(fn); -+ AddLogLineN( _("Unload previous antiLeech...")); -+ fn(antiLeech); -+ //antiLeech = NULL; -+ //antiLeechLib.Unload(); -+ } -+} -+ -+bool DLP::LoadFrom(wxString& file){ -+ antiLeechLib.Load(file); -+ return antiLeechLib.IsLoaded(); -+} -diff -Naur a/src/DLP.h b/src/DLP.h ---- a/src/DLP.h 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/DLP.h 2016-10-14 12:33:51.665348032 +0800 -@@ -0,0 +1,45 @@ -+// Copyright (C) 2011 Bill Lee -+// -+// This program is free software; you can redistribute it and/or modify -+// it under the terms of the GNU General Public License as published by -+// the Free Software Foundation; either version 2 of the License, or -+// (at your option) any later version. -+// -+// This program is distributed in the hope that it will be useful, -+// but WITHOUT ANY WARRANTY; without even the implied warranty of -+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+// GNU General Public License for more details. -+// -+// You should have received a copy of the GNU General Public License -+// along with this program; if not, write to the Free Software -+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -+// -+ -+class IantiLeech; //forward declaretion -+ -+#include "updownclient.h" // Needed for CUpDownClient -+#include "antiLeech_wx.h" -+ -+#include -+ -+class DLP -+{ -+public: -+ DLP() : antiLeech(NULL) { ReloadAntiLeech(); } -+ ~DLP(); -+ -+ void CheckHelloTag(CUpDownClient*, UINT tagnumber); -+ void CheckInfoTag(CUpDownClient*, UINT tagnumber); -+ bool DLPCheck(CUpDownClient*); -+ -+ int ReloadAntiLeech(); -+ -+private: -+ typedef IantiLeech* (*Creator)(); -+ typedef int (*Destoryer)(IantiLeech*); -+ -+ wxDynamicLibrary antiLeechLib; -+ IantiLeech* antiLeech; -+ -+ bool LoadFrom(wxString& file); -+}; -diff -Naur a/src/DLPPref.h b/src/DLPPref.h ---- a/src/DLPPref.h 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/DLPPref.h 2016-10-14 12:33:51.665348032 +0800 -@@ -0,0 +1,15 @@ -+#ifndef ANTILEECH_AMULE_H -+#define ANTILEECH_AMULE_H -+ -+/* Define DLPCheck prefs arg */ -+#define PF_MODSTRING 0x1 -+#define PF_USERHASH 0x2 -+#define PF_USERNAME 0x4 -+#define PF_HELLOTAG 0x8 -+#define PF_INFOTAG 0x10 -+#define PF_VERYCDEMULE 0x20 -+//#define PF_EASYMULE 0x40 -+//#define PF_MINIMULE 0x80 -+#define PF_GHOSTMOD 0x100 -+ -+#endif -diff -Naur a/src/DownloadQueue.cpp b/src/DownloadQueue.cpp ---- a/src/DownloadQueue.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/DownloadQueue.cpp 2016-10-14 12:33:51.665348032 +0800 -@@ -623,6 +623,15 @@ - return; - } - -+ //Dynamic Leecher Protect - Bill Lee -+ #ifdef AMULE_DLP -+ if ( source->IsBanned() ){ -+ source->Safe_Delete(); -+ return; -+ } -+ #endif -+ //Bill Lee end -+ - // Filter sources which are known to be dead/useless - if ( theApp->clientlist->IsDeadSource( source ) || sender->IsDeadSource(source) ) { - source->Safe_Delete(); -diff -Naur a/src/ExternalConn.cpp b/src/ExternalConn.cpp ---- a/src/ExternalConn.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/ExternalConn.cpp 2016-10-14 12:33:51.666348055 +0800 -@@ -57,6 +57,9 @@ - #include "kademlia/kademlia/UDPFirewallTester.h" - #include "Statistics.h" - -+#ifdef AMULE_DLP -+#include "DLP.h" -+#endif - - //-------------------- File_Encoder -------------------- - -@@ -1384,6 +1387,15 @@ - } - } - break; -+ //Dynamic Leech Protect - Bill Lee -+ #ifdef AMULE_DLP -+ case EC_OP_ANTILEECH_RELOAD: -+ if( theDLP->ReloadAntiLeech() ) -+ response = new CECPacket(EC_OP_FAILED); -+ else -+ response = new CECPacket(EC_OP_NOOP); -+ break; -+ #endif - // - // Status requests - // -diff -Naur a/src/Logger.cpp b/src/Logger.cpp ---- a/src/Logger.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/Logger.cpp 2016-10-14 12:40:22.827322335 +0800 -@@ -297,6 +297,8 @@ - } - - CLogger theLogger; -+//Dynamic Leech Protect - persmule -+CLogger dlpLogger; - - BEGIN_EVENT_TABLE(CLogger, wxEvtHandler) - EVT_MULE_LOGGING(CLogger::OnLoggingEvent) -diff -Naur a/src/Logger.h b/src/Logger.h ---- a/src/Logger.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/Logger.h 2016-10-14 12:41:14.694519856 +0800 -@@ -310,6 +310,8 @@ - }; - - extern CLogger theLogger; -+//Dynamic Leech Protect - persmule -+extern CLogger dlpLogger; - - /** - * This class forwards log-lines from wxWidgets to CLogger. -@@ -456,5 +458,8 @@ - #define AddLogLineF(string) theLogger.AddLogLine(__TFILE__, __LINE__, false, logStandard, string, false, false) - #endif - -+//Dynamic Leech Protect - persmule -+#define DlpAddLogLine(string) dlpLogger.AddLogLine(__TFILE__, __LINE__, false, logStandard, string, false, false) -+ - #endif - // File_checked_for_headers -diff -Naur a/src/LoggerConsole.cpp b/src/LoggerConsole.cpp ---- a/src/LoggerConsole.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/LoggerConsole.cpp 2016-10-14 12:41:54.805446813 +0800 -@@ -85,6 +85,8 @@ - } - - CLogger theLogger; -+//Dynamic Leech Protect - persmule -+CLogger dlpLogger; - - BEGIN_EVENT_TABLE(CLogger, wxEvtHandler) - END_EVENT_TABLE() -diff -Naur a/src/Makefile.am b/src/Makefile.am ---- a/src/Makefile.am 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/Makefile.am 2016-10-14 12:33:51.666348055 +0800 -@@ -179,6 +179,13 @@ - kademlia/routing/RoutingZone.cpp - - -+#Dynamic Leecher Protection - Bill Lee -+if ENABLE_DLP -+core_sources += \ -+ DLP.cpp -+AM_CPPFLAGS += -DAMULE_DLP -+endif -+ - gui_sources = \ - amule-gui.cpp \ - amuleDlg.cpp \ -diff -Naur a/src/Preferences.cpp b/src/Preferences.cpp ---- a/src/Preferences.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/Preferences.cpp 2016-10-14 12:33:51.667348078 +0800 -@@ -51,6 +51,11 @@ - - #include "UserEvents.h" - -+#ifdef AMULE_DLP -+#include "DLPPref.h" -+#include "antiLeech.h" -+#endif -+ - #ifndef AMULE_DAEMON - #include - #include "muuli_wdr.h" -@@ -344,6 +349,19 @@ - wxWindow* m_widget; - }; - -+/* Dynamic Leecher Protection */ -+#ifdef AMULE_DLP -+bool CPreferences::s_DLPCheckModString; -+bool CPreferences::s_DLPCheckUsername; -+bool CPreferences::s_DLPCheckUserHash; -+bool CPreferences::s_DLPCheckHelloTag; -+bool CPreferences::s_DLPCheckInfoTag; -+//bool CPreferences::s_DLPCheckEasyMule; -+bool CPreferences::s_DLPCheckVeryCDMod; -+//bool CPreferences::s_DLPCheckminiMule; //Added by Bill Lee -+bool CPreferences::s_DLPCheckGhostMod; -+unsigned int CPreferences::s_DLPCheckMask; -+#endif - - /** Cfg class for wxStrings. */ - class Cfg_Str : public Cfg_Tmpl -@@ -953,6 +971,11 @@ - s_userhash[5] = 14; - s_userhash[14] = 111; - -+ // Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ CalcDLPCheckMask(); -+ #endif -+ - #ifndef CLIENT_GUI - LoadPreferences(); - ReloadSharedFolders(); -@@ -1062,6 +1085,20 @@ - NewCfgItem( IDC_NETWORKKAD, (new Cfg_Bool( wxT("/eMule/ConnectToKad"), s_ConnectToKad, true )) ); - NewCfgItem( IDC_NETWORKED2K, ( new Cfg_Bool( wxT("/eMule/ConnectToED2K"), s_ConnectToED2K, true ) )); - -+ /** -+ * Dynamic Leecher Protection -+ **/ -+ #ifdef AMULE_DLP -+ NewCfgItem(IDC_CHECKMODSTRING, (new Cfg_Bool( wxT("/DLP/CheckModString"), s_DLPCheckModString, true ))); -+ NewCfgItem(IDC_CHECKUSERNAME, (new Cfg_Bool( wxT("/DLP/CheckUsername"), s_DLPCheckUsername, true ))); -+ NewCfgItem(IDC_CHECKUSERHASH, (new Cfg_Bool( wxT("/DLP/CheckUserHash"), s_DLPCheckUserHash, true ))); -+ NewCfgItem(IDC_CHECKHELLOTAG, (new Cfg_Bool( wxT("/DLP/CheckHelloTag"), s_DLPCheckHelloTag, true ))); -+ NewCfgItem(IDC_CHECKINFOTAG, (new Cfg_Bool( wxT("/DLP/CheckInfoTag"), s_DLPCheckInfoTag, true ))); -+ //NewCfgItem(IDC_CHECKEASYMULE, (new Cfg_Bool( wxT("/DLP/CheckEasyMule"), s_DLPCheckEasyMule, true ))); //Modified by Bill Lee -+ NewCfgItem(IDC_CHECKVERYCDMOD, (new Cfg_Bool( wxT("/DLP/CheckVeryCDMod"), s_DLPCheckVeryCDMod, false ))); -+ //NewCfgItem(IDC_CHECKMINIMULE, (new Cfg_Bool( wxT("/DLP/CheckminiMule"), s_DLPCheckminiMule, true))); //Added by Bill Lee -+ NewCfgItem(IDC_CHECKGHOSTMOD, (new Cfg_Bool( wxT("/DLP/CheckGhostMod"), s_DLPCheckGhostMod, true ))); //Added by Bill Lee. -+ #endif - - /** - * Files -@@ -1471,6 +1508,11 @@ - } - - SavePreferences(); -+ -+ // Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ CalcDLPCheckMask(); -+ #endif - - #ifndef CLIENT_GUI - CTextFile sdirfile; -@@ -1483,6 +1525,21 @@ - #endif - } - -+#ifdef AMULE_DLP -+void CPreferences::CalcDLPCheckMask() -+{ -+ s_DLPCheckMask = 0; -+ if (s_DLPCheckModString) s_DLPCheckMask |= PF_MODSTRING; -+ if (s_DLPCheckUsername) s_DLPCheckMask |= PF_USERNAME; -+ if (s_DLPCheckUserHash) s_DLPCheckMask |= PF_USERHASH; -+ if (s_DLPCheckHelloTag) s_DLPCheckMask |= PF_HELLOTAG; -+ if (s_DLPCheckInfoTag) s_DLPCheckMask |= PF_INFOTAG; -+ if (s_DLPCheckGhostMod) s_DLPCheckMask |= PF_GHOSTMOD; -+ //if (s_DLPCheckEasyMule) s_DLPCheckMask |= PF_EASYMULE; -+ if (s_DLPCheckVeryCDMod) s_DLPCheckMask |= PF_VERYCDEMULE; -+ //if (s_DLPCheckminiMule) s_DLPCheckMask |= PF_MINIMULE; //Added by Bill Lee -+} -+#endif - - CPreferences::~CPreferences() - { -diff -Naur a/src/Preferences.h b/src/Preferences.h ---- a/src/Preferences.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/Preferences.h 2016-10-14 12:33:51.667348078 +0800 -@@ -579,6 +579,11 @@ - // Sleep - static bool GetPreventSleepWhileDownloading() { return s_preventSleepWhileDownloading; } - static void SetPreventSleepWhileDownloading(bool status) { s_preventSleepWhileDownloading = status; } -+ -+ // Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ static unsigned int GetDLPCheckMask() {return s_DLPCheckMask;} -+ #endif - protected: - static int32 GetRecommendedMaxConnections(); - -@@ -599,6 +604,11 @@ - private: - void LoadPreferences(); - void SavePreferences(); -+ -+ // Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ void CalcDLPCheckMask(); -+ #endif - - protected: - static wxString s_configDir; -@@ -813,6 +823,20 @@ - // Stats server - static wxString s_StatsServerName; - static wxString s_StatsServerURL; -+ -+ // Dynamic Leecher Protection -+ #ifdef AMULE_DLP -+ static bool s_DLPCheckModString; -+ static bool s_DLPCheckUsername; -+ static bool s_DLPCheckUserHash; -+ static bool s_DLPCheckHelloTag; -+ static bool s_DLPCheckInfoTag; -+ //static bool s_DLPCheckEasyMule; -+ static bool s_DLPCheckVeryCDMod; -+ //static bool s_DLPCheckminiMule; //Added by Bill Lee -+ static bool s_DLPCheckGhostMod; //Added by Bill Lee -+ static unsigned int s_DLPCheckMask; -+ #endif - }; - - -diff -Naur a/src/PrefsUnifiedDlg.cpp b/src/PrefsUnifiedDlg.cpp ---- a/src/PrefsUnifiedDlg.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/PrefsUnifiedDlg.cpp 2016-10-14 12:33:51.668348101 +0800 -@@ -53,6 +53,11 @@ - #include "UserEvents.h" - #include "PlatformSpecific.h" // Needed for PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE - -+//Dynamic Leech Protect - Bill Lee -+#ifdef AMULE_DLP -+#include "DLP.h" -+#endif -+ - BEGIN_EVENT_TABLE(PrefsUnifiedDlg,wxDialog) - // Events - #define USEREVENTS_EVENT(ID, NAME, VARS) \ -@@ -114,6 +119,11 @@ - EVT_CHOICE(IDC_COLORSELECTOR, PrefsUnifiedDlg::OnColorCategorySelected) - EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL,PrefsUnifiedDlg::OnPrefsPageChange) - -+ //Dynamic Leech Protect - Bill Lee -+ #ifdef AMULE_DLP -+ EVT_BUTTON(IDC_RELOADANTILEECH, PrefsUnifiedDlg::OnButtonReloadAntiLeech) -+ #endif -+ - EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog) - - EVT_COMMAND_SCROLL(IDC_SLIDER, PrefsUnifiedDlg::OnScrollBarChange) -@@ -187,6 +197,9 @@ - { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab, 21 }, - { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab, 12 }, - { wxTRANSLATE("Events"), PreferencesEventsTab, 5 } -+#ifdef AMULE_DLP -+ ,{ wxTRANSLATE("DLP"), PreferencesDLPTab, 5} -+#endif - #ifdef __DEBUG__ - ,{ wxTRANSLATE("Debugging"), PreferencesDebug, 25 } - #endif -@@ -1076,6 +1089,21 @@ - theApp->ipfilter->Update( CastChild( IDC_IPFILTERURL, wxTextCtrl )->GetValue() ); - } - -+//Bill Lee -+#ifdef AMULE_DLP -+void PrefsUnifiedDlg::OnButtonReloadAntiLeech(wxCommandEvent& WXUNUSED(event)){ -+ #ifndef CLIENT_GUI -+ if( theDLP->ReloadAntiLeech() ) -+ wxMessageBox(_("Cannot load antiLeech!"), _("Message"), wxOK | wxICON_EXCLAMATION, this); -+ else -+ wxMessageBox(_("Succeed loading antiLeech!"), _("Message"), wxOK | wxICON_INFORMATION, this); -+ #else -+ AddLogLineN(_("Reload antiLeech from remote GUI has not been implemented.")); -+ wxMessageBox(_("Sorry, it has not been implemented yet!")); -+ #endif -+} -+#endif -+ - - void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent& event) - { -diff -Naur a/src/PrefsUnifiedDlg.h b/src/PrefsUnifiedDlg.h ---- a/src/PrefsUnifiedDlg.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/PrefsUnifiedDlg.h 2016-10-14 12:33:51.668348101 +0800 -@@ -124,6 +124,9 @@ - void OnUserEventSelected(wxListEvent& event); - void OnLanguageChoice(wxCommandEvent &event); - void CreateEventPanels(const int idx, const wxString& vars, wxWindow* parent); -+ #ifdef AMULE_DLP -+ void OnButtonReloadAntiLeech(wxCommandEvent &event); /* Dynamic Leech Protect - Bill Lee */ -+ #endif - - void OnInitDialog( wxInitDialogEvent& evt ); - -diff -Naur a/src/ServerWnd.cpp b/src/ServerWnd.cpp ---- a/src/ServerWnd.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/ServerWnd.cpp 2016-10-14 12:33:51.668348101 +0800 -@@ -46,6 +46,7 @@ - EVT_BUTTON(ID_BTN_RESET, CServerWnd::OnBnClickedResetLog) - EVT_BUTTON(ID_BTN_RESET_SERVER, CServerWnd::OnBnClickedResetServerLog) - EVT_SPLITTER_SASH_POS_CHANGED(ID_SRV_SPLITTER,CServerWnd::OnSashPositionChanged) -+ EVT_BUTTON(ID_BTN_RESET_DLP, CServerWnd::OnBnClickedResetDLPLog) - END_EVENT_TABLE() - - -@@ -152,6 +153,11 @@ - theApp->GetServerLog(true); // Reset it - } - -+void CServerWnd::OnBnClickedResetDLPLog(wxCommandEvent& WXUNUSED(evt)) -+{ -+ wxTextCtrl* cv= CastByID( ID_DLPINFO, this, wxTextCtrl ); -+ cv->Clear(); -+} - - void CServerWnd::UpdateED2KInfo() - { -diff -Naur a/src/ServerWnd.h b/src/ServerWnd.h ---- a/src/ServerWnd.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/ServerWnd.h 2016-10-14 12:33:51.668348101 +0800 -@@ -50,6 +50,7 @@ - void OnBnClickedUpdateservermetfromurl(wxCommandEvent& evt); - void OnBnClickedResetLog(wxCommandEvent& evt); - void OnBnClickedResetServerLog(wxCommandEvent& evt); -+ void OnBnClickedResetDLPLog(wxCommandEvent& evt); - - DECLARE_EVENT_TABLE() - }; -diff -Naur a/src/TextClient.cpp b/src/TextClient.cpp ---- a/src/TextClient.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/TextClient.cpp 2016-10-14 12:33:51.669348124 +0800 -@@ -73,6 +73,7 @@ - CMD_ID_RELOAD_SHARED, - CMD_ID_RELOAD_IPFILTER_LOCAL, - CMD_ID_RELOAD_IPFILTER_NET, -+ CMD_ID_RELOAD_ANTILEECH, /* Only used internally - Dynamic Leech Protect - Bill Lee */ - CMD_ID_SET_IPFILTER_ON, - CMD_ID_SET_IPFILTER_OFF, - CMD_ID_SET_IPFILTER_CLIENTS_ON, -@@ -106,7 +107,6 @@ - CMD_ID_DOWNLOAD, - // IDs for deprecated commands - CMD_ID_SET_IPFILTER -- - }; - - // method to create a SearchFile -@@ -240,6 +240,12 @@ - case CMD_ID_DISCONNECT_KAD: - request_list.push_back(new CECPacket(EC_OP_KAD_STOP)); - break; -+ //Dynamic Leech Protect - Bill Lee -+ #ifdef AMULE_DLP -+ case CMD_ID_RELOAD_ANTILEECH: -+ request_list.push_back(new CECPacket(EC_OP_ANTILEECH_RELOAD)); -+ break; -+ #endif - - case CMD_ID_RELOAD_SHARED: - request_list.push_back(new CECPacket(EC_OP_SHAREDFILES_RELOAD)); -@@ -903,6 +909,9 @@ - tmp2->AddCommand(wxT("Net"), CMD_ID_RELOAD_IPFILTER_NET, wxTRANSLATE("Update IP filtering table from URL."), - wxTRANSLATE("If URL is omitted the URL from the preferences is used."), CMD_PARAM_OPTIONAL); - -+ #ifdef AMULE_DLP -+ tmp->AddCommand(wxT("AntiLeech"), CMD_ID_RELOAD_ANTILEECH, wxTRANSLATE("Reloads antiLeech."), wxEmptyString, CMD_PARAM_NEVER); //Bill Lee -+ #endif - tmp = m_commands.AddCommand(wxT("Connect"), CMD_ID_CONNECT, wxTRANSLATE("Connect to the network."), - wxTRANSLATE("This will connect to all networks that are enabled in Preferences.\nYou may also optionally specify a server address in IP:Port form, to connect to\nthat server only. The IP must be a dotted decimal IPv4 address,\nor a resolvable DNS name."), CMD_PARAM_OPTIONAL); - tmp->AddCommand(wxT("ED2K"), CMD_ID_CONNECT_ED2K, wxTRANSLATE("Connect to eD2k only."), wxEmptyString, CMD_PARAM_NEVER); -diff -Naur a/src/UploadQueue.cpp b/src/UploadQueue.cpp ---- a/src/UploadQueue.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/UploadQueue.cpp 2016-10-14 12:33:51.669348124 +0800 -@@ -390,6 +390,11 @@ - return; - } - -+ //Dynamic Leecher Protect - Bill Lee -+ #if defined AMULE_DLP && defined __DEBUG__ -+ AddLogLineN(client->GetClientFullInfo()); -+ #endif -+ - client->AddAskedCount(); - client->SetLastUpRequest(); - -diff -Naur a/src/amule-gui.cpp b/src/amule-gui.cpp ---- a/src/amule-gui.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amule-gui.cpp 2016-10-14 12:33:51.669348124 +0800 -@@ -333,6 +333,21 @@ - return CamuleApp::GetLog(reset); - } - -+#ifdef AMULE_DLP -+void CamuleGuiApp::AddDLPMessageLine(const wxString &msg) -+{ -+ wxString message; -+ time_t rawtime; -+ struct tm *timeinfo; -+ char tbuf[101]; -+ time(&rawtime); -+ timeinfo = localtime(&rawtime); -+ strftime(tbuf, 100, "%Y-%m-%d %X: ", timeinfo); -+ -+ message = wxString(tbuf, wxConvUTF8) + msg; -+ amuledlg->AddDLPMessageLine(message); -+} -+#endif - - wxString CamuleGuiApp::GetServerLog(bool reset) - { -diff -Naur a/src/amule.cpp b/src/amule.cpp ---- a/src/amule.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amule.cpp 2016-10-14 12:33:51.670348146 +0800 -@@ -23,7 +23,6 @@ - // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - // - -- - #include "amule.h" // Interface declarations. - - #include -@@ -90,6 +89,11 @@ - #include // Do_not_auto_remove - #endif - -+//Dynamic Leecher Protection - Bill Lee -+#ifdef AMULE_DLP -+#include "DLP.h" -+#endif -+ - #ifndef AMULE_DAEMON - #ifdef __WXMAC__ - #include // Do_not_auto_remove -@@ -520,6 +524,11 @@ - uploadqueue = new CUploadQueue(); - ipfilter = new CIPFilter(); - -+ //DLP initialization - Bill Lee -+ #ifdef AMULE_DLP -+ theDLP = new DLP(); -+ #endif -+ - // Creates all needed listening sockets - wxString msg; - if (!ReinitializeNetwork(&msg)) { -@@ -2062,3 +2071,8 @@ - DEFINE_LOCAL_EVENT_TYPE(wxEVT_CORE_UDP_DNS_DONE) - DEFINE_LOCAL_EVENT_TYPE(wxEVT_CORE_SERVER_DNS_DONE) - // File_checked_for_headers -+ -+//Dynamic Leech Protect - Bill Lee -+#ifdef AMULE_DLP -+DLP* theDLP; -+#endif -diff -Naur a/src/amule.h b/src/amule.h ---- a/src/amule.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amule.h 2016-10-14 12:42:22.776093625 +0800 -@@ -135,6 +135,8 @@ - bool m_geometryEnabled; - wxString m_geometryString; - wxString m_logFile; -+ //Dynamic Leech Protect - persmule -+ wxString m_dlplogFile; - wxString m_appName; - wxString m_PidFile; - -@@ -410,6 +412,7 @@ - wxString GetLog(bool reset = false); - wxString GetServerLog(bool reset = false); - void AddServerMessageLine(wxString &msg); -+ void AddDLPMessageLine(const wxString &msg); - DECLARE_EVENT_TABLE() - }; - -@@ -573,6 +576,8 @@ - - virtual int ShowAlert(wxString msg, wxString title, int flags); - -+ void AddDLPMessageLine(const wxString &msg); -+ - DECLARE_EVENT_TABLE() - }; - -@@ -583,3 +588,8 @@ - - #endif // AMULE_H - // File_checked_for_headers -+ -+#ifdef AMULE_DLP -+class DLP; //forward declaretion -+extern DLP* theDLP; -+#endif -diff -Naur a/src/amuleAppCommon.cpp b/src/amuleAppCommon.cpp ---- a/src/amuleAppCommon.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amuleAppCommon.cpp 2016-10-14 12:44:08.981552362 +0800 -@@ -65,6 +65,9 @@ - m_configFile = wxT("amule.conf"); - m_logFile = wxT("logfile"); - -+ //Dynamic Leech Protect - persmule -+ m_dlplogFile = wxT("antileech.log"); -+ - if (IsDaemon()) { - m_appName = wxT("aMuleD"); - } else { -@@ -443,6 +446,21 @@ - return false; - } - -+ // Open the dlp log file - Dynamic Leech Protect - persmule -+ if (!IsRemoteGui()){ -+ CPath dlplogfileName = CPath(thePrefs::GetConfigDir() + m_dlplogFile); -+ if (dlplogfileName.FileExists()) { -+ CPath::BackupFile(dlplogfileName, wxT(".bak")); -+ } -+ -+ if (!dlpLogger.OpenLogfile(dlplogfileName.GetRaw())) { -+ // use std err as last resolt to indicate problem -+ fputs("ERROR: unable to open dlp log file\n", stderr); -+ // failure to open log is serious problem -+ return false; -+ } -+ } -+ - // Load Preferences - CPreferences::BuildItemList(thePrefs::GetConfigDir()); - CPreferences::LoadAllItems( wxConfigBase::Get() ); -diff -Naur a/src/amuleDlg.cpp b/src/amuleDlg.cpp ---- a/src/amuleDlg.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amuleDlg.cpp 2016-10-14 12:44:47.637582726 +0800 -@@ -315,7 +315,7 @@ - wxNotebook* logs_notebook = CastChild( ID_SRVLOG_NOTEBOOK, wxNotebook); - wxNotebook* networks_notebook = CastChild( ID_NETNOTEBOOK, wxNotebook); - -- wxASSERT(logs_notebook->GetPageCount() == 4); -+ wxASSERT(logs_notebook->GetPageCount() == 5); - wxASSERT(networks_notebook->GetPageCount() == 2); - - for (uint32 i = 0; i < logs_notebook->GetPageCount(); ++i) { -@@ -507,7 +507,12 @@ - _("Part of aMule is based on \n") << - _("Kademlia: Peer-to-peer routing based on the XOR metric.\n") << - _(" Copyright (c) 2002-2011 Petar Maymounkov ( petar@post.harvard.edu )\n") << -- _("http://kademlia.scs.cs.nyu.edu\n"); -+ _("http://kademlia.scs.cs.nyu.edu\n") << -+ _("\nDynamic Leech Protection\n") << -+ _(" Homepage: http://amule-dlp.googlecode.com \n") << -+ _(" Copyright (C) 2002-2007 Xtreme-Mod \n") << -+ _(" Copyright (C) 2009 greensea \n") << -+ _(" Copyright (C) 2009-2011 Bill Lee \n"); - - if (m_is_safe_state) { - wxMessageBox(msg, _("Message"), wxOK | wxICON_INFORMATION, this); -@@ -659,8 +664,24 @@ - } - cv->ShowPosition(cv->GetLastPosition()-1); - } -+ //Dynamic Leech Protect - persmule -+ DlpAddLogLine(msg); - } - -+#ifdef AMULE_DLP -+void CamuleDlg::AddDLPMessageLine(const wxString& msg) /* modified by Bill Lee */ -+{ -+ wxTextCtrl* cv = CastByID( ID_DLPINFO, m_serverwnd, wxTextCtrl ); -+ if(cv) { -+ if (msg.Length() > 500) { -+ cv->AppendText(msg.Left(500) + wxT("\n")); -+ } else { -+ cv->AppendText(msg + wxT("\n")); -+ } -+ cv->ShowPosition(cv->GetLastPosition()-1); -+ } -+} -+#endif - - void CamuleDlg::ShowConnectionState(bool skinChanged) - { -@@ -1456,7 +1477,9 @@ - if (thePrefs::GetNetworkKademlia()) { - logs_notebook->AddPage(m_logpages[3].page, m_logpages[3].name); - } -- -+ -+ logs_notebook->AddPage(m_logpages[4].page, m_logpages[4].name); -+ - // Set the main window. - // If we have both networks active, activate a notebook to select between them. - // If only one is active, show the window directly without a surrounding one tab notebook. -diff -Naur a/src/amuleDlg.h b/src/amuleDlg.h ---- a/src/amuleDlg.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amuleDlg.h 2016-10-14 12:33:51.671348169 +0800 -@@ -114,6 +114,9 @@ - - void AddLogLine(const wxString& line); - void AddServerMessageLine(wxString& message); -+ #ifdef AMULE_DLP -+ void AddDLPMessageLine(const wxString& msg); /* Modified by Bill Lee */ -+ #endif - void ResetLog(int id); - - void ShowUserCount(const wxString& info = wxEmptyString); -@@ -231,7 +234,7 @@ - WX_DECLARE_STRING_HASH_MAP(wxZipEntry*, ZipCatalog); - ZipCatalog cat; - -- PageType m_logpages[4]; -+ PageType m_logpages[5]; - PageType m_networkpages[2]; - - bool LoadGUIPrefs(bool override_pos, bool override_size); -diff -Naur a/src/amuled.cpp b/src/amuled.cpp ---- a/src/amuled.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/amuled.cpp 2016-10-14 12:45:23.506600119 +0800 -@@ -749,4 +749,10 @@ - return 0; // That's neither yes nor no, ok, cancel - } - -+void CamuleDaemonApp::AddDLPMessageLine(const wxString &msg) -+{ -+ //Dynamic Leech Protect - persmule -+ DlpAddLogLine(msg); -+} -+ - // File_checked_for_headers -diff -Naur a/src/antiLeech.h b/src/antiLeech.h ---- a/src/antiLeech.h 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/antiLeech.h 2016-10-14 12:33:51.672348192 +0800 -@@ -0,0 +1,48 @@ -+#ifndef ANTILEECH_H -+#define ANTILEECH_H -+ -+ -+#pragma once -+ -+#include "antiLeech_wx.h" -+#include "CString_wx.h" -+ -+class IantiLeech -+{ -+public: -+ virtual ~IantiLeech(){}; /* Bill Lee: Not be used currently */ -+ //BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD,LPVOID); -+ virtual DWORD GetDLPVersion() = 0; -+ //old versions to keep compatible -+ /* //drop old version support -+ virtual LPCTSTR DLPCheckModstring(LPCTSTR modversion, LPCTSTR clientversion); -+ virtual LPCTSTR DLPCheckUsername(LPCTSTR username); -+ virtual LPCTSTR DLPCheckNameAndHash(CString username, CString& userhash); -+ */ -+ //new versions -+ virtual LPCTSTR DLPCheckModstring_Hard(LPCTSTR modversion, LPCTSTR clientversion) = 0; -+ virtual LPCTSTR DLPCheckModstring_Soft(LPCTSTR modversion, LPCTSTR clientversion) = 0; -+ virtual LPCTSTR DLPCheckUsername_Hard(LPCTSTR username) = 0; -+ virtual LPCTSTR DLPCheckUsername_Soft(LPCTSTR username) = 0; -+ virtual LPCTSTR DLPCheckNameAndHashAndMod(const CString& username, const CString& userhash, const CString& modversion) = 0; -+ virtual LPCTSTR DLPCheckMessageSpam(LPCTSTR messagetext) = 0; -+ -+ -+ virtual LPCTSTR DLPCheckUserhash(const PBYTE userhash) = 0; -+ -+ -+ virtual LPCTSTR DLPCheckHelloTag(UINT tagnumber) = 0; -+ virtual LPCTSTR DLPCheckInfoTag(UINT tagnumber) = 0; -+ -+ //void TestFunc(); -+ -+//Bill Lee: no need in interface abstract class -+//private: -+// static bool IsTypicalHex (const CString& addon); -+}; -+ -+//Bill Lee: never call delete on IantiLeech, use destoryAntiLeechInstat instead. -+extern "C" IantiLeech* createAntiLeechInstant(); -+extern "C" int destoryAntiLeechInstant(IantiLeech*); -+ -+#endif -diff -Naur a/src/antiLeech_wx.h b/src/antiLeech_wx.h ---- a/src/antiLeech_wx.h 1970-01-01 08:00:00.000000000 +0800 -+++ b/src/antiLeech_wx.h 2016-10-14 12:33:51.672348192 +0800 -@@ -0,0 +1,49 @@ -+#ifndef ANTILEECH_WX_H -+#define ANTILEECH_WX_H -+ -+#include -+#include -+ -+#define LPCTSTR const wxChar* -+#define BOOL bool -+//#define _T(var) wxT(var) //defined in wxWidgets -+#define DWORD wxUint32 -+#define UINT wxUint16 -+#define WINAPI -+#define HINSTANCE -+#define LPVOID void* -+#define PBYTE unsigned char* -+#define TCHAR wxChar -+#define _TINT wxInt32 -+ -+#define StrCmpI _tcsicmp -+ -+#define _istdigit(var) iswdigit(var) -+#define _istcntrl(var) iswcntrl(var) -+#define _istpunct(var) iswpunct(var) -+#define _istspace(var) iswspace(var) -+#define _istxdigit(var) iswxdigit(var) -+inline float _tstof(const wchar_t* str){ -+ wchar_t** ptail = NULL; -+ return wcstof(str, ptail); -+} -+//This function is not used. by Orzogc Lee -+//But I think there is no need to removing, linker will remove it. -+/* -+inline void tolowers(wxChar* str){ -+ int i = 0; -+ do{ -+ str[i] = towlower(str[i]); -+ }while(str[++i]); -+} -+*/ -+#define _tcsstr(haystack, needle) wcsstr(haystack, needle) -+#define _tcslen(var) wcslen(var) -+#define StrStr(a, b) wcsstr(a, b) -+ -+LPCTSTR StrStrI(LPCTSTR haystack, LPCTSTR needle); -+//Bill Lee: I think inlining this function make no senses, because it is a very large operation. -+ -+#define _tcsicmp(a, b) wcscasecmp(a, b) -+ -+#endif -diff -Naur a/src/libs/ec/abstracts/ECCodes.abstract b/src/libs/ec/abstracts/ECCodes.abstract ---- a/src/libs/ec/abstracts/ECCodes.abstract 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/libs/ec/abstracts/ECCodes.abstract 2016-10-14 12:33:51.672348192 +0800 -@@ -148,6 +148,8 @@ - - EC_OP_FRIEND 0x57 - -+EC_OP_ANTILEECH_RELOAD 0x80 -+ - [/Section] - - [Section Content] -diff -Naur a/src/libs/ec/cpp/ECCodes.h b/src/libs/ec/cpp/ECCodes.h ---- a/src/libs/ec/cpp/ECCodes.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/libs/ec/cpp/ECCodes.h 2016-10-14 12:33:51.673348215 +0800 -@@ -121,7 +121,8 @@ - EC_OP_CLIENT_SWAP_TO_ANOTHER_FILE = 0x54, - EC_OP_SHARED_FILE_SET_COMMENT = 0x55, - EC_OP_SERVER_SET_STATIC_PRIO = 0x56, -- EC_OP_FRIEND = 0x57 -+ EC_OP_FRIEND = 0x57, -+ EC_OP_ANTILEECH_RELOAD = 0x80 - }; - - enum ECTagNames { -@@ -556,6 +557,7 @@ - case 0x55: return wxT("EC_OP_SHARED_FILE_SET_COMMENT"); - case 0x56: return wxT("EC_OP_SERVER_SET_STATIC_PRIO"); - case 0x57: return wxT("EC_OP_FRIEND"); -+ case 0x80 : return wxT("EC_OP_ANTILEECH_RELOAD"); - default: return CFormat(wxT("unknown %d 0x%x")) % arg % arg; - } - } -diff -Naur a/src/libs/ec/java/ECCodes.java b/src/libs/ec/java/ECCodes.java ---- a/src/libs/ec/java/ECCodes.java 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/libs/ec/java/ECCodes.java 2016-10-14 12:33:51.673348215 +0800 -@@ -112,6 +112,7 @@ - public final static byte EC_OP_SHARED_FILE_SET_COMMENT = 0x55; - public final static byte EC_OP_SERVER_SET_STATIC_PRIO = 0x56; - public final static byte EC_OP_FRIEND = 0x57; -+public final static byte EC_OP_ANTILEECH_RELOAD = 0x80 ; - - public final static short EC_TAG_STRING = 0x0000; - public final static short EC_TAG_PASSWD_HASH = 0x0001; -diff -Naur a/src/muuli_wdr.cpp b/src/muuli_wdr.cpp ---- a/src/muuli_wdr.cpp 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/muuli_wdr.cpp 2016-10-14 12:33:51.676348283 +0800 -@@ -1769,6 +1769,51 @@ - return item0; - } - -+#ifdef AMULE_DLP -+wxSizer *PreferencesDLPTab( wxWindow *parent, bool call_fit, bool set_sizer ) -+{ -+ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); -+ -+ wxButton* btnReload = new wxButton( parent, IDC_RELOADANTILEECH, _("Reload antiLeech"), wxDefaultPosition, wxDefaultSize, 0 ); //Bill Lee -+ -+ wxStaticBox *item2 = new wxStaticBox( parent, -1, _("Dynamic Leecher Protection Options") ); -+ wxStaticBoxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL ); -+ -+ wxCheckBox *item4 = new wxCheckBox( parent, IDC_CHECKMODSTRING, _("Check bad modstring"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item5 = new wxCheckBox( parent, IDC_CHECKUSERNAME, _("Check bad username"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item5, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item6 = new wxCheckBox( parent, IDC_CHECKUSERHASH, _("Check bad userhash"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item6, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item7 = new wxCheckBox( parent, IDC_CHECKHELLOTAG, _("Check bad hello tag"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item7, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item8 = new wxCheckBox( parent, IDC_CHECKINFOTAG, _("Check bad info tag"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item8, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item9 = new wxCheckBox( parent, IDC_CHECKGHOSTMOD, _("Check ghost mod"), wxDefaultPosition, wxDefaultSize, 0); -+ item1->Add( item9, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxCheckBox *item10 = new wxCheckBox( parent, IDC_CHECKVERYCDMOD, _("Ban eMule VeryCD mod(Please consider carefully whether to use)"), wxDefaultPosition, wxDefaultSize, 0 ); //Modified by Bill Lee -+ item1->Add( item10, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ item0->Add( btnReload, 0, wxGROW|wxALL, 5); //Bill Lee -+ item0->Add( item1, 0, wxGROW|wxALL, 5 ); -+ -+ if (set_sizer) -+ { -+ parent->SetSizer( item0 ); -+ if (call_fit) -+ item0->SetSizeHints( parent ); -+ } -+ -+ return item0; -+} -+#endif -+ - wxSizer *PreferencesFilesTab( wxWindow *parent, bool call_fit, bool set_sizer ) - { - wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); -@@ -2587,6 +2632,42 @@ - return item0; - } - -+wxSizer *DLPInfoLog( wxWindow *parent, bool call_fit, bool set_sizer ) -+{ -+ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); -+ -+ wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL ); -+ -+ wxStaticBitmap *item2 = new wxStaticBitmap( parent, -1, amuleDlgImages( 3 ), wxDefaultPosition, wxDefaultSize ); -+ item2->SetToolTip( _("Display DLP log") ); -+ item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 ); -+ -+ wxStaticText *item3 = new wxStaticText( parent, -1, _("DLP Info"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 ); -+ -+ item0->Add( item1, 0, wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL ); -+ -+ CMuleTextCtrl *item5 = new CMuleTextCtrl( parent, ID_DLPINFO, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxVSCROLL ); -+ item4->Add( item5, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL, 5 ); -+ -+ wxButton *item6 = new wxButton( parent, ID_BTN_RESET_DLP, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 ); -+ item6->SetToolTip( _("Click this button to reset the log.") ); -+ item4->Add( item6, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); -+ -+ item0->Add( item4, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); -+ -+ if (set_sizer) -+ { -+ parent->SetSizer( item0 ); -+ if (call_fit) -+ item0->SetSizeHints( parent ); -+ } -+ -+ return item0; -+} -+ - wxSizer *serverListDlgDown( wxWindow *parent, bool call_fit, bool set_sizer ) - { - wxStaticBox *item1 = new wxStaticBox( parent, -1, wxT("") ); -@@ -2602,7 +2683,7 @@ - wxPanel *item4 = new wxPanel( item3, -1 ); - aMuleLog( item4, FALSE ); - item3->AddPage( item4, _("aMule Log") ); -- -+ - wxPanel *item5 = new wxPanel( item3, -1 ); - ServerInfoLog( item5, FALSE ); - item3->AddPage( item5, _("Server Info") ); -@@ -2614,6 +2695,10 @@ - wxPanel *item7 = new wxPanel( item3, -1 ); - Kad_Info( item7, FALSE ); - item3->AddPage( item7, _("Kad Info") ); -+ -+ wxPanel *item8 = new wxPanel( item3, -1); -+ DLPInfoLog( item8, FALSE); -+ item3->AddPage(item8, _("DLP Info")); - - item0->Add( item2, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); - -diff -Naur a/src/muuli_wdr.h b/src/muuli_wdr.h ---- a/src/muuli_wdr.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/muuli_wdr.h 2016-10-14 12:33:51.676348283 +0800 -@@ -335,6 +335,10 @@ - #define ID_BTN_RESET_SERVER 10240 - wxSizer *ServerInfoLog( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE ); - -+#define ID_DLPINFO 22001 -+#define ID_BTN_RESET_DLP 22002 -+wxSizer *DLPInfoLog( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE ); -+ - #define ID_LOGVIEW 10241 - #define ID_BTN_RESET 10242 - wxSizer *aMuleLog( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE ); -@@ -424,6 +428,21 @@ - #define ID_DEBUGCATS 10307 - wxSizer *PreferencesDebug( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE ); - -+/* Dynamic Leecher Protection */ -+#define IDC_CHECKMODSTRING 11001 -+#define IDC_CHECKUSERNAME 11002 -+#define IDC_CHECKUSERHASH 11003 -+#define IDC_CHECKHELLOTAG 11004 -+#define IDC_CHECKINFOTAG 11005 -+#define IDC_CHECKEASYMULE 11006 -+#define IDC_CHECKVERYCDMOD 11007 -+#define IDC_CHECKMINIMULE 11008 -+#define IDC_CHECKGHOSTMOD 11009 -+#ifdef AMULE_DLP -+#define IDC_RELOADANTILEECH 11010 //Bill Lee -+wxSizer *PreferencesDLPTab( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE ); -+#endif -+ - extern wxSizer *IDC_CURJOB; - #define IDC_CONV_PB_LABEL 10308 - #define IDC_CONV_PROZENT 10309 -diff -Naur a/src/updownclient.h b/src/updownclient.h ---- a/src/updownclient.h 2016-10-06 19:01:54.000000000 +0800 -+++ b/src/updownclient.h 2016-10-14 12:37:03.224728226 +0800 -@@ -408,7 +408,13 @@ - bool GetSentCancelTransfer() const { return m_fSentCancelTransfer; } - void SetSentCancelTransfer(bool bVal) { m_fSentCancelTransfer = bVal; } - -- DEBUG_ONLY( wxString GetClientFullInfo(); ) -+#if defined (__DEBUG__) || defined (AMULE_DLP) -+ /* -+ * This function is essential for dlp to produce ban log. -+ * So I decide to retain it when dlp is enabled. -+ */ -+ wxString GetClientFullInfo(); -+#endif - wxString GetClientShortInfo(); - - const wxString& GetClientOSInfo() const { return m_sClientOSInfo; } -@@ -581,7 +587,10 @@ - bool ShouldReceiveCryptUDPPackets() const; - - bool HasDisabledSharedFiles() const { return m_fNoViewSharedFiles; } -- -+ #ifdef AMULE_DLP -+ bool HasNonOfficialOpCodes() const { return dlp_nonofficialopcodes; } //Dynamic Leecher Protection - Bill Lee -+ #endif -+ - private: - - CClientCredits *credits; -@@ -842,6 +851,10 @@ - #ifdef __DEBUG__ - wxString connection_reason; - #endif -+ -+ #ifdef AMULE_DLP -+ bool dlp_nonofficialopcodes; //Dynamic Leecher Protect - Bill Lee -+ #endif - }; - - diff --git a/amule/patches/003_enable_upnp_cross_compile.patch b/amule/patches/003_enable_upnp_cross_compile.patch deleted file mode 100644 index 462e490c0..000000000 --- a/amule/patches/003_enable_upnp_cross_compile.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff -Naur a/m4/libupnp.m4 b/m4/libupnp.m4 ---- a/m4/libupnp.m4 2016-10-06 19:01:54.000000000 +0800 -+++ b/m4/libupnp.m4 2016-10-11 07:36:39.198318574 +0800 -@@ -52,7 +52,6 @@ - [export PKG_CONFIG_PATH=$withval/lib/pkgconfig]) - - dnl Check for libupnp >= MIN_LIBUPNP_VERSION -- AS_IF([test $cross_compiling = no], [ - AC_MSG_CHECKING([for libupnp version >= MIN_LIBUPNP_VERSION]) - AS_IF([test -n "$PKG_CONFIG"], [ - AS_IF([$PKG_CONFIG libupnp --exists], [ -@@ -79,11 +78,6 @@ - ]) - AC_MSG_RESULT([$result$resultstr]) - libupnp_error="libupnp >= MIN_LIBUPNP_VERSION not found$resultstr" -- ], [ --dnl Currently cross-compilation with libupnp is not supported. -- result=no -- libupnp_error="cross compiling" -- ]) - - dnl Execute the right action. - AS_IF([test ${result:-no} = yes], [$2], [$3]) diff --git a/amule/patches/004_file_name_conversion.patch b/amule/patches/004_file_name_conversion.patch deleted file mode 100644 index 2c511d0ce..000000000 --- a/amule/patches/004_file_name_conversion.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff --git a/src/amule.h b/src/amule.h -index f25702f..240c02d 100644 ---- a/src/amule.h -+++ b/src/amule.h -@@ -553,6 +553,13 @@ class CamuleDaemonApp : public CamuleApp - int OnExit(); - - virtual int InitGui(bool geometry_enable, wxString &geometry_string); -+ // The GTK wxApps sets its file name conversion properly -+ // in wxApp::Initialize(), while wxAppConsole::Initialize() -+ // does not, leaving wxConvFile being set to wxConvLibc. File -+ // name conversion should be set otherwise amuled will abort to -+ // handle non-ASCII file names which monolithic amule can handle. -+ // This function are overrided to perform this. -+ virtual bool Initialize(int& argc_, wxChar **argv_); - - #ifdef AMULED_APPTRAITS - struct sigaction m_oldSignalChildAction; -diff --git a/src/amuled.cpp b/src/amuled.cpp -index 486da59..86e1ff8 100644 ---- a/src/amuled.cpp -+++ b/src/amuled.cpp -@@ -704,6 +704,41 @@ int CamuleDaemonApp::InitGui(bool ,wxString &) - return 0; - } - -+bool CamuleDaemonApp::Initialize(int& argc_, wxChar **argv_) -+{ -+ if ( !wxAppConsole::Initialize(argc_, argv_) ) { -+ return false; -+ } -+ -+#ifdef __UNIX__ -+ wxString encName; -+#if wxUSE_INTL -+ // if a non default locale is set, -+ // assume that the user wants his -+ // filenames in this locale too -+ encName = wxLocale::GetSystemEncodingName().Upper(); -+ -+ // But don't consider ASCII in this case. -+ if ( !encName.empty() ) { -+ if ( encName == wxT("US-ASCII") ) { -+ // This means US-ASCII when returned -+ // from GetEncodingFromName(). -+ encName.clear(); -+ } -+ } -+#endif // wxUSE_INTL -+ -+ // in this case, UTF-8 is used by default. -+ if ( encName.empty() ) { -+ encName = wxT("UTF-8"); -+ } -+ -+ static wxConvBrokenFileNames fileconv(encName); -+ wxConvFileName = &fileconv; -+#endif // __UNIX__ -+ -+ return true; -+} - - int CamuleDaemonApp::OnExit() - { -diff --git a/src/libs/common/Path.cpp b/src/libs/common/Path.cpp -index 28152a2..5efefd0 100644 ---- a/src/libs/common/Path.cpp -+++ b/src/libs/common/Path.cpp -@@ -229,7 +229,8 @@ CPath::CPath(const wxString& filename) - } - - wxCharBuffer fn = filename2char(filename); -- if (fn.data()) { -+ // add fn.length() for wx 3.x -+ if (fn.data()) { - // Filename is valid in the current locale. This means that - // it either originated from a (wx)system-call, or from a - // user with a properly setup system. diff --git a/amule/patches/005_best_keyword_kad_search.patch b/amule/patches/005_best_keyword_kad_search.patch deleted file mode 100644 index c450a9f8e..000000000 --- a/amule/patches/005_best_keyword_kad_search.patch +++ /dev/null @@ -1,174 +0,0 @@ -diff --git a/src/SearchList.cpp b/src/SearchList.cpp -index 32b28e9..342a18f 100644 ---- a/src/SearchList.cpp -+++ b/src/SearchList.cpp -@@ -75,7 +75,7 @@ void ParsedSearchExpression(const CSearchExpr* pexpr) - int iOpNot = 0; - - for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) { -- wxString str(pexpr->m_aExpr[i]); -+ const wxString& str = pexpr->m_aExpr[i]; - if (str == SEARCHOPTOK_AND) { - iOpAnd++; - } else if (str == SEARCHOPTOK_OR) { -@@ -108,6 +108,25 @@ void ParsedSearchExpression(const CSearchExpr* pexpr) - - // optimize search expression, if no OR nor NOT specified - if (iOpAnd > 0 && iOpOr == 0 && iOpNot == 0) { -+ // figure out if we can use a better keyword than the one the user selected -+ // for example most user will search like this "The oxymoronaccelerator 2", which would ask the node which indexes "the" -+ // This causes higher traffic for such nodes and makes them a viable target to attackers, while the kad result should be -+ // the same or even better if we ask the node which indexes the rare keyword "oxymoronaccelerator", so we try to rearrange -+ // keywords and generally assume that the longer keywords are rarer -+ if (/*thePrefs::GetRearrangeKadSearchKeywords() &&*/ !s_strCurKadKeyword.IsEmpty()) { -+ for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) { -+ if (pexpr->m_aExpr[i] != SEARCHOPTOK_AND) { -+ if (pexpr->m_aExpr[i] != s_strCurKadKeyword -+ && pexpr->m_aExpr[i].find_first_of(Kademlia::CSearchManager::GetInvalidKeywordChars()) == wxString::npos -+ && pexpr->m_aExpr[i].Find('"') != 0 // no quoted expressions as keyword -+ && pexpr->m_aExpr[i].length() >= 3 -+ && s_strCurKadKeyword.length() < pexpr->m_aExpr[i].length()) -+ { -+ s_strCurKadKeyword = pexpr->m_aExpr[i]; -+ } -+ } -+ } -+ } - wxString strAndTerms; - for (unsigned int i = 0; i < pexpr->m_aExpr.GetCount(); i++) { - if (pexpr->m_aExpr[i] != SEARCHOPTOK_AND) { -@@ -285,7 +304,7 @@ void CSearchList::RemoveResults(long searchID) - } - - --wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CSearchParams& params) -+wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, CSearchParams& params) - { - // Check that we can actually perform the specified desired search. - if ((type == KadSearch) && !Kademlia::CKademlia::IsRunning()) { -@@ -306,6 +325,16 @@ wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CS - m_resultType.Clear(); - } - -+ if (type == KadSearch) { -+ Kademlia::WordList words; -+ Kademlia::CSearchManager::GetWords(params.searchString, &words); -+ if (!words.empty()) { -+ params.strKeyword = words.front(); -+ } else { -+ return _("No keyword for Kad search - aborting"); -+ } -+ } -+ - bool supports64bit = type == KadSearch ? true : theApp->serverconnect->GetCurrentServer() != NULL && (theApp->serverconnect->GetCurrentServer()->GetTCPFlags() & SRV_TCPFLG_LARGEFILES); - bool packetUsing64bit; - -@@ -332,8 +361,7 @@ wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CS - - // searchstring will get tokenized there - // The tab must be created with the Kad search ID, so searchID is updated. -- Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords( -- params.searchString, data->GetLength(), data->GetRawBuffer(), *searchID); -+ Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords(params.strKeyword, data->GetLength(), data->GetRawBuffer(), *searchID); - - *searchID = search->GetSearchID(); - m_currentSearch = *searchID; -@@ -632,7 +660,7 @@ void CSearchList::StopSearch(bool globalOnly) - } - - --CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& params, SearchType WXUNUSED(type), bool supports64bit, bool& packetUsing64bit) -+CSearchList::CMemFilePtr CSearchList::CreateSearchData(CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit) - { - // Count the number of used parameters - unsigned int parametercount = 0; -@@ -659,14 +687,16 @@ CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& para - _astrParserErrors.Empty(); - _SearchExpr.m_aExpr.Empty(); - -+ s_strCurKadKeyword.Clear(); -+ if (type == KadSearch) { -+ wxASSERT( !params.strKeyword.IsEmpty() ); -+ s_strCurKadKeyword = params.strKeyword; -+ } -+ - LexInit(params.searchString); - int iParseResult = yyparse(); - LexFree(); - --#ifdef __DEBUG__ -- AddLogLineNS(CFormat(wxT("Search parsing result for \"%s\": %i")) -- % params.searchString % iParseResult); --#endif - if (_astrParserErrors.GetCount() > 0) { - for (unsigned int i=0; i < _astrParserErrors.GetCount(); ++i) { - AddLogLineNS(CFormat(wxT("Error %u: %s\n")) % i % _astrParserErrors[i]); -@@ -681,21 +711,13 @@ CSearchList::CMemFilePtr CSearchList::CreateSearchData(const CSearchParams& para - return CMemFilePtr(NULL); - } - -- #ifdef __DEBUG__ -- wxString mes(wxT("Search expression:")); -- for (unsigned int i = 0; i < _SearchExpr.m_aExpr.GetCount(); i++) { -- mes << wxT(" ") << _SearchExpr.m_aExpr[i]; -+ if (type == KadSearch && s_strCurKadKeyword != params.strKeyword) { -+ AddDebugLogLineN(logSearch, CFormat(wxT("Keyword was rearranged, using '%s' instead of '%s'")) % s_strCurKadKeyword % params.strKeyword); -+ params.strKeyword = s_strCurKadKeyword; - } -- AddLogLineNS(mes); -- AddLogLineNS(CFormat(wxT("Expression count: %i")) % _SearchExpr.m_aExpr.GetCount()); -- #endif - - parametercount += _SearchExpr.m_aExpr.GetCount(); - -- #ifdef __DEBUG__ -- AddLogLineNS(CFormat(wxT("Parameters: %i")) % parametercount); -- #endif -- - /* Leave the unicode comment there, please... */ - CSearchExprTarget target(data.get(), true /*I assume everyone is unicoded */ ? utf8strRaw : utf8strNone, supports64bit, packetUsing64bit); - -diff --git a/src/SearchList.h b/src/SearchList.h -index 35b0fc6..6db7508 100644 ---- a/src/SearchList.h -+++ b/src/SearchList.h -@@ -64,6 +64,8 @@ class CSearchList : public wxEvtHandler - - //! The actual string to search for. - wxString searchString; -+ //! The keyword selected for Kad search -+ wxString strKeyword; - //! The type of files to search for (may be empty), one of ED2KFTSTR_* - wxString typeText; - //! The filename extension. May be empty. -@@ -90,7 +92,7 @@ class CSearchList : public wxEvtHandler - * @param params The search parameters, see CSearchParams. - * @return An empty string on success, otherwise an error-message. - */ -- wxString StartNewSearch(uint32* searchID, SearchType type, const CSearchParams& params); -+ wxString StartNewSearch(uint32* searchID, SearchType type, CSearchParams& params); - - /** Stops the current search (global or Kad), if any is in progress. */ - void StopSearch(bool globalOnly = false); -@@ -189,7 +191,7 @@ class CSearchList : public wxEvtHandler - typedef std::auto_ptr CMemFilePtr; - - /** Create a basic search-packet for the given search-type. */ -- CMemFilePtr CreateSearchData(const CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit); -+ CMemFilePtr CreateSearchData(CSearchParams& params, SearchType type, bool supports64bit, bool& packetUsing64bit); - - - //! Timer used for global search intervals. -diff --git a/src/kademlia/kademlia/SearchManager.cpp b/src/kademlia/kademlia/SearchManager.cpp -index e7f25d4..f9ee924 100644 ---- a/src/kademlia/kademlia/SearchManager.cpp -+++ b/src/kademlia/kademlia/SearchManager.cpp -@@ -127,7 +127,7 @@ CSearch* CSearchManager::PrepareFindKeywords(const wxString& keyword, uint32_t s - - wxString wstrKeyword = s->m_words.front(); - -- AddLogLineNS(CFormat(_("Keyword for search: %s")) % wstrKeyword); -+ AddDebugLogLineN(logSearch, CFormat(wxT("Keyword for search: %s")) % wstrKeyword); - - // Kry - I just decided to assume everyone is unicoded - // GonoszTopi - seconded diff --git a/amule/patches/006_update-libupnp.patch b/amule/patches/006_update-libupnp.patch deleted file mode 100644 index a66c33bad..000000000 --- a/amule/patches/006_update-libupnp.patch +++ /dev/null @@ -1,365 +0,0 @@ -diff -Naur a/m4/libupnp.m4 b/m4/libupnp.m4 ---- a/m4/libupnp.m4 2016-10-06 18:49:44.000000000 +0800 -+++ b/m4/libupnp.m4 2019-12-11 22:13:19.008225399 +0800 -@@ -45,11 +45,16 @@ - - dnl Test for --with-libupnp-prefix - AC_ARG_WITH( -- [libupnp-prefix], -- [AS_HELP_STRING( -+ [libupnp-prefix],[ -+ AS_HELP_STRING( - [--with-libupnp-prefix=PREFIX], -- [UPnP library location])], -- [export PKG_CONFIG_PATH=$withval/lib/pkgconfig]) -+ [UPnP library location])],[ -+ AS_IF([test -d "$withval/lib64/pkgconfig"],[ -+ export PKG_CONFIG_PATH=$withval/lib64/pkgconfig -+ ],[ -+ export PKG_CONFIG_PATH=$withval/lib/pkgconfig -+ ]) -+ ]) - - dnl Check for libupnp >= MIN_LIBUPNP_VERSION - AS_IF([test $cross_compiling = no], [ -diff -Naur a/src/UPnPBase.cpp b/src/UPnPBase.cpp ---- a/src/UPnPBase.cpp 2016-10-06 18:49:44.000000000 +0800 -+++ b/src/UPnPBase.cpp 2019-12-11 22:15:04.536768532 +0800 -@@ -1127,7 +1127,11 @@ - - - // This function is static -+#if UPNP_VERSION >= 10800 -+int CUPnPControlPoint::Callback(Upnp_EventType_e EventType, const void *Event, void * /*Cookie*/) -+#else - int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/) -+#endif - { - std::ostringstream msg; - std::ostringstream msg2; -@@ -1149,24 +1153,47 @@ - msg2<< "UPNP_DISCOVERY_SEARCH_RESULT: "; - // UPnP Discovery - upnpDiscovery: -+#if UPNP_VERSION >= 10800 -+ UpnpDiscovery *d_event = (UpnpDiscovery *)Event; -+#else - struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event; -+#endif - IXML_Document *doc = NULL; -+#if UPNP_VERSION >= 10800 -+ int errCode = UpnpDiscovery_get_ErrCode(d_event); -+ if (errCode != UPNP_E_SUCCESS) { -+ msg << UpnpGetErrorMessage(errCode) << "."; -+#else - int ret; - if (d_event->ErrCode != UPNP_E_SUCCESS) { - msg << UpnpGetErrorMessage(d_event->ErrCode) << "."; -+#endif - AddDebugLogLineC(logUPnP, msg); - } - // Get the XML tree device description in doc -+#if UPNP_VERSION >= 10800 -+ const char *location = UpnpDiscovery_get_Location_cstr(d_event); -+ int ret = UpnpDownloadXmlDoc(location, &doc); -+#else - ret = UpnpDownloadXmlDoc(d_event->Location, &doc); -+#endif - if (ret != UPNP_E_SUCCESS) { - msg << "Error retrieving device description from " << -+#if UPNP_VERSION >= 10800 -+ location << ": " << -+#else - d_event->Location << ": " << -+#endif - UpnpGetErrorMessage(ret) << - "(" << ret << ")."; - AddDebugLogLineC(logUPnP, msg); - } else { - msg2 << "Retrieving device description from " << -+#if UPNP_VERSION >= 10800 -+ location << "."; -+#else - d_event->Location << "."; -+#endif - AddDebugLogLineN(logUPnP, msg2); - } - if (doc) { -@@ -1194,8 +1221,14 @@ - AddDebugLogLineC(logUPnP, msg); - } - // Add the root device to our list -+#if UPNP_VERSION >= 10800 -+ int expires = UpnpDiscovery_get_Expires(d_event); -+ upnpCP->AddRootDevice(rootDevice, urlBase, -+ location, expires); -+#else - upnpCP->AddRootDevice(rootDevice, urlBase, - d_event->Location, d_event->Expires); -+#endif - } - // Free the XML doc tree - IXML::Document::Free(doc); -@@ -1216,28 +1249,62 @@ - case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: { - //fprintf(stderr, "Callback: UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE\n"); - // UPnP Device Removed -+#if UPNP_VERSION >= 10800 -+ UpnpDiscovery *dab_event = (UpnpDiscovery *)Event; -+ int errCode = UpnpDiscovery_get_ErrCode(dab_event); -+ if (errCode != UPNP_E_SUCCESS) { -+#else - struct Upnp_Discovery *dab_event = (struct Upnp_Discovery *)Event; - if (dab_event->ErrCode != UPNP_E_SUCCESS) { -+#endif - msg << "error(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE): " << -+#if UPNP_VERSION >= 10800 -+ UpnpGetErrorMessage(errCode) << -+#else - UpnpGetErrorMessage(dab_event->ErrCode) << -+#endif - "."; - AddDebugLogLineC(logUPnP, msg); - } -+#if UPNP_VERSION >= 10800 -+ std::string devType = UpnpDiscovery_get_DeviceType_cstr(dab_event); -+#else - std::string devType = dab_event->DeviceType; -+#endif - // Check for an InternetGatewayDevice and removes it from the list -+ - std::transform(devType.begin(), devType.end(), devType.begin(), tolower); -+ - if (stdStringIsEqualCI(devType, UPnP::Device::IGW)) { -+#if UPNP_VERSION >= 10800 -+ const char *deviceID = -+ UpnpDiscovery_get_DeviceID_cstr(dab_event); -+ upnpCP->RemoveRootDevice(deviceID); -+#else - upnpCP->RemoveRootDevice(dab_event->DeviceId); -+#endif - } - break; - } - case UPNP_EVENT_RECEIVED: { - //fprintf(stderr, "Callback: UPNP_EVENT_RECEIVED\n"); - // Event reveived -+#if UPNP_VERSION >= 10800 -+ UpnpEvent *e_event = (UpnpEvent *)Event; -+ int eventKey = UpnpEvent_get_EventKey(e_event); -+ IXML_Document *changedVariables = -+ UpnpEvent_get_ChangedVariables(e_event); -+ const std::string sid = UpnpEvent_get_SID_cstr(e_event); -+#else - struct Upnp_Event *e_event = (struct Upnp_Event *)Event; - const std::string Sid = e_event->Sid; -+#endif - // Parses the event -+#if UPNP_VERSION >= 10800 -+ upnpCP->OnEventReceived(sid, eventKey, changedVariables); -+#else - upnpCP->OnEventReceived(Sid, e_event->EventKey, e_event->ChangedVariables); -+#endif - break; - } - case UPNP_EVENT_SUBSCRIBE_COMPLETE: -@@ -1252,24 +1319,42 @@ - //fprintf(stderr, "Callback: UPNP_EVENT_RENEWAL_COMPLETE\n"); - msg << "error(UPNP_EVENT_RENEWAL_COMPLETE): "; - upnpEventRenewalComplete: -+#if UPNP_VERSION >= 10800 -+ UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event; -+ int errCode = UpnpEventSubscribe_get_ErrCode(es_event); -+ if (errCode != UPNP_E_SUCCESS) { -+#else - struct Upnp_Event_Subscribe *es_event = - (struct Upnp_Event_Subscribe *)Event; - if (es_event->ErrCode != UPNP_E_SUCCESS) { -+#endif - msg << "Error in Event Subscribe Callback"; -+#if UPNP_VERSION >= 10800 -+ UPnP::ProcessErrorMessage(msg.str(), errCode, NULL, NULL); -+#else - UPnP::ProcessErrorMessage( - msg.str(), es_event->ErrCode, NULL, NULL); -+#endif - } else { - #if 0 -+#if UPNP_VERSION >= 10800 -+ -+ const UpnpString *publisherUrl = -+ UpnpEventSubscribe_get_PublisherUrl(es_event); -+ const char *sid = UpnpEvent_get_SID_cstr(es_event); -+ int timeOut = UpnpEvent_get_TimeOut(es_event); -+ TvCtrlPointHandleSubscribeUpdate( -+ publisherUrl, sid, timeOut); -+#else - TvCtrlPointHandleSubscribeUpdate( - GET_UPNP_STRING(es_event->PublisherUrl), - es_event->Sid, - es_event->TimeOut ); - #endif -+#endif - } -- - break; - } -- - case UPNP_EVENT_AUTORENEWAL_FAILED: - //fprintf(stderr, "Callback: UPNP_EVENT_AUTORENEWAL_FAILED\n"); - msg << "error(UPNP_EVENT_AUTORENEWAL_FAILED): "; -@@ -1280,29 +1365,56 @@ - msg << "error(UPNP_EVENT_SUBSCRIPTION_EXPIRED): "; - msg2 << "UPNP_EVENT_SUBSCRIPTION_EXPIRED: "; - upnpEventSubscriptionExpired: -+#if UPNP_VERSION >= 10800 -+ UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event; -+#else - struct Upnp_Event_Subscribe *es_event = - (struct Upnp_Event_Subscribe *)Event; -+#endif - Upnp_SID newSID; - memset(newSID, 0, sizeof(Upnp_SID)); - int TimeOut = 1801; -+#if UPNP_VERSION >= 10800 -+ const char *publisherUrl = -+ UpnpEventSubscribe_get_PublisherUrl_cstr(es_event); -+#endif - int ret = UpnpSubscribe( - upnpCP->m_UPnPClientHandle, -+#if UPNP_VERSION >= 10800 -+ publisherUrl, -+#else - GET_UPNP_STRING(es_event->PublisherUrl), -+#endif - &TimeOut, - newSID); - if (ret != UPNP_E_SUCCESS) { - msg << "Error Subscribing to EventURL"; -+#if UPNP_VERSION >= 10800 -+ int errCode = UpnpEventSubscribe_get_ErrCode(es_event); -+#endif - UPnP::ProcessErrorMessage( -+#if UPNP_VERSION >= 10800 -+ msg.str(), errCode, NULL, NULL); -+#else - msg.str(), es_event->ErrCode, NULL, NULL); -+#endif - } else { - ServiceMap::iterator it = -+#if UPNP_VERSION >= 10800 -+ upnpCP->m_ServiceMap.find(publisherUrl); -+#else - upnpCP->m_ServiceMap.find(GET_UPNP_STRING(es_event->PublisherUrl)); -+#endif - if (it != upnpCP->m_ServiceMap.end()) { - CUPnPService &service = *(it->second); - service.SetTimeout(TimeOut); - service.SetSID(newSID); - msg2 << "Re-subscribed to EventURL '" << -+#if UPNP_VERSION >= 10800 -+ publisherUrl << -+#else - GET_UPNP_STRING(es_event->PublisherUrl) << -+#endif - "' with SID == '" << - newSID << "'."; - AddDebugLogLineC(logUPnP, msg2); -@@ -1321,17 +1433,34 @@ - case UPNP_CONTROL_ACTION_COMPLETE: { - //fprintf(stderr, "Callback: UPNP_CONTROL_ACTION_COMPLETE\n"); - // This is here if we choose to do this asynchronously -+#if UPNP_VERSION >= 10800 -+ UpnpActionComplete *a_event = (UpnpActionComplete *)Event; -+ int errCode = UpnpActionComplete_get_ErrCode(a_event); -+ IXML_Document *actionResult = -+ UpnpActionComplete_get_ActionResult(a_event); -+ if (errCode != UPNP_E_SUCCESS) { -+#else - struct Upnp_Action_Complete *a_event = - (struct Upnp_Action_Complete *)Event; - if (a_event->ErrCode != UPNP_E_SUCCESS) { -+#endif - UPnP::ProcessErrorMessage( - "UpnpSendActionAsync", -+#if UPNP_VERSION >= 10800 -+ errCode, NULL, -+ actionResult); -+#else - a_event->ErrCode, NULL, - a_event->ActionResult); -+#endif - } else { - // Check the response document - UPnP::ProcessActionResponse( -+#if UPNP_VERSION >= 10800 -+ actionResult, -+#else - a_event->ActionResult, -+#endif - ""); - } - /* No need for any processing here, just print out results. -@@ -1342,22 +1471,43 @@ - case UPNP_CONTROL_GET_VAR_COMPLETE: { - //fprintf(stderr, "Callback: UPNP_CONTROL_GET_VAR_COMPLETE\n"); - msg << "error(UPNP_CONTROL_GET_VAR_COMPLETE): "; -+#if UPNP_VERSION >= 10800 -+ UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event; -+ int errCode = UpnpStateVarComplete_get_ErrCode(sv_event); -+ if (errCode != UPNP_E_SUCCESS) { -+#else - struct Upnp_State_Var_Complete *sv_event = - (struct Upnp_State_Var_Complete *)Event; - if (sv_event->ErrCode != UPNP_E_SUCCESS) { -+#endif - msg << "m_UpnpGetServiceVarStatusAsync"; - UPnP::ProcessErrorMessage( -+#if UPNP_VERSION >= 10800 -+ msg.str(), errCode, NULL, NULL); -+#else - msg.str(), sv_event->ErrCode, NULL, NULL); -+#endif - } else { - #if 0 - // Warning: The use of UpnpGetServiceVarStatus and - // UpnpGetServiceVarStatusAsync is deprecated by the - // UPnP forum. -+#if UPNP_VERSION >= 10800 -+ const char *ctrlUrl = -+ UpnpStateVarComplete_get_CtrlUrl(sv_event); -+ const char *stateVarName = -+ UpnpStateVarComplete_get_StateVarName(sv_event); -+ const DOMString currentVal = -+ UpnpStateVarComplete_get_CurrentVal(sv_event); -+ TvCtrlPointHandleGetVar( -+ ctrlUrl, stateVarName, currentVal); -+#else - TvCtrlPointHandleGetVar( - sv_event->CtrlUrl, - sv_event->StateVarName, - sv_event->CurrentVal ); - #endif -+#endif - } - break; - } -diff -Naur a/src/UPnPBase.h b/src/UPnPBase.h ---- a/src/UPnPBase.h 2016-10-06 18:49:44.000000000 +0800 -+++ b/src/UPnPBase.h 2019-12-11 22:16:28.165063153 +0800 -@@ -489,9 +489,15 @@ - - // Callback function - static int Callback( -+ #if UPNP_VERSION >= 10800 -+ Upnp_EventType_e EventType, -+ const void *Event, -+ void *Cookie); -+ #else - Upnp_EventType EventType, - void* Event, - void* Cookie); -+ #endif - - private: - void OnEventReceived( diff --git a/amule/patches/007-binutils.patch b/amule/patches/007-binutils.patch deleted file mode 100644 index 600a47620..000000000 --- a/amule/patches/007-binutils.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/src/libs/common/MuleDebug.cpp 2016-10-06 18:49:44.000000000 +0800 -+++ b/src/libs/common/MuleDebug.cpp 2021-06-17 02:16:40.000000000 +0800 -@@ -268,14 +268,14 @@ - return; - } - -- bfd_vma vma = bfd_get_section_vma(abfd, section); -+ bfd_vma vma = bfd_section_vma(section); - - unsigned long address = (unsigned long)_address; - if (address < vma) { - return; - } - -- bfd_size_type size = bfd_section_size(abfd, section); -+ bfd_size_type size = bfd_section_size(section); - if (address > (vma + size)) { - return; - } diff --git a/amule/patches/008-upnp2.patch b/amule/patches/008-upnp2.patch deleted file mode 100644 index 20592509c..000000000 --- a/amule/patches/008-upnp2.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/UPnPBase.cpp b/src/UPnPBase.cpp -index 46ac7451e..dd244e5b0 100644 ---- a/src/UPnPBase.cpp -+++ b/src/UPnPBase.cpp -@@ -828,9 +828,9 @@ - int ret; - char *ipAddress = NULL; - unsigned short port = 0; -- ret = UpnpInit(ipAddress, udpPort); -+ ret = UpnpInit2(0, udpPort); - if (ret != UPNP_E_SUCCESS) { -- msg << "error(UpnpInit): Error code "; -+ msg << "error(UpnpInit2): Error code "; - goto error; - } - port = UpnpGetServerPort(); diff --git a/baidupcs-web/Makefile b/baidupcs-web/Makefile deleted file mode 100644 index 69651b822..000000000 --- a/baidupcs-web/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# -# Copyright (C) 2019 OpenWrt.org -# -# KFERMercer -# -# This is free software, licensed under the GNU General Public License v3. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=baidupcs-web -PKG_VERSION:=3.7.4-nnew -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/Erope/BaiduPCS-Go.git -PKG_SOURCE_VERSION:=cffd49d0709f9c7d3dd6ae5c9625f68bfd446166 -PKG_MIRROR_HASH:=skip - -PKG_LICENSE:=Apache-2.0 -PKG_LICENSE_FILES:=LICENSE - -PKG_CONFIG_DEPENDS:= \ - CONFIG_BAIDUPCS_WEB_COMPRESS_GOPROXY \ - CONFIG_BAIDUPCS_WEB_COMPRESS_UPX - -PKG_BUILD_DEPENDS:=golang/host -PKG_BUILD_PARALLEL:=1 -PKG_USE_MIPS16:=0 - -GO_PKG:=github.com/Erope/BaiduPCS-Go -GO_PKG_LDFLAGS:=-s -w -GO_PKG_LDFLAGS_X:=main.Version=v$(PKG_VERSION) - -include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk - -define Package/baidupcs-web - TITLE:=BaiduPCS-Web is a web controller for BaiduPCS-Go - SECTION:=net - CATEGORY:=Network - SUBMENU:=Web Servers/Proxies - URL:=https://github.com/Erope/BaiduPCS-Go - DEPENDS:=$(GO_ARCH_DEPENDS) -endef - -define Package/baidupcs-web/description - BaiduPCS-Web is a web controller for BaiduPCS-Go -endef - -define Package/baidupcs-web/config -config BAIDUPCS_WEB_COMPRESS_GOPROXY - bool "Compiling with GOPROXY proxy" - default n - -config BAIDUPCS_WEB_COMPRESS_UPX - bool "Compress executable files with UPX" - depends on !mips64 - default n -endef - -ifeq ($(CONFIG_BAIDUPCS_WEB_COMPRESS_GOPROXY),y) - export GO111MODULE=on - export GOPROXY=https://goproxy.baidu.com -endif - -define Build/Compile -( \ - GOOS=$$$$(go env GOOS) GOARCH=$$$$(go env GOARCH) go get -v github.com/GeertJohan/go.rice/rice/... ; \ - cd $(PKG_BUILD_DIR)/internal/pcsweb ; \ - "$$$$(go env GOPATH)/bin/rice" embed-go ; \ -) - $(call GoPackage/Build/Compile) -ifeq ($(CONFIG_BAIDUPCS_WEB_COMPRESS_UPX),y) - $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/BaiduPCS-Go -endif -endef - -define Package/baidupcs-web/install - $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR)) - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/BaiduPCS-Go $(1)/usr/bin/baidupcs-web -endef - -$(eval $(call GoBinPackage,baidupcs-web)) -$(eval $(call BuildPackage,baidupcs-web)) diff --git a/cgroupfs-mount/Makefile b/cgroupfs-mount/Makefile new file mode 100644 index 000000000..cffb48f07 --- /dev/null +++ b/cgroupfs-mount/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=cgroupfs-mount +PKG_RELEASE:=2 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/tianon/$(PKG_NAME) +PKG_SOURCE_VERSION:=0549428171605eae3097a3e21bf7664845eac9e8 +PKG_SOURCE_DATE:=2020-06-26 +PKG_MIRROR_HASH:=skip + +PKG_MAINTAINER:=Gerard Ryan + +include $(INCLUDE_DIR)/package.mk + +define Package/cgroupfs-mount/config + config CGROUPFS_MOUNT_KERNEL_CGROUPS + bool "Enable kernel cgroups support" + depends on PACKAGE_cgroupfs-mount + default y if ( DOCKER_KERNEL_OPTIONS || LXC_KERNEL_OPTIONS ) + select KERNEL_CGROUPS +endef + +define Package/cgroupfs-mount + SECTION:=utils + CATEGORY:=Utilities + TITLE:=cgroup mount scripts + DEPENDS:=+mount-utils + MENU:=1 +endef + +define Package/cgroupfs-mount/description +Simple scripts to properly mount the cgroupfs hierarchy, especially structured for Debian packaging +endef + +Build/Compile=# Nothing to compile, just install the scripts + +define Package/cgroupfs-mount/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/cgroupfs-mount $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/cgroupfs-umount $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/cgroupfs-mount.init $(1)/etc/init.d/cgroupfs-mount +endef + +$(eval $(call BuildPackage,cgroupfs-mount)) diff --git a/cgroupfs-mount/files/cgroupfs-mount.init b/cgroupfs-mount/files/cgroupfs-mount.init new file mode 100755 index 000000000..0d6b68dc3 --- /dev/null +++ b/cgroupfs-mount/files/cgroupfs-mount.init @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common + +START=01 + +boot() { + # Procd mounts non-hierarchical cgroupfs so unmount first before cgroupfs-mount + if mountpoint -q /sys/fs/cgroup; then + umount /sys/fs/cgroup/ + fi + + cgroupfs-mount +} diff --git a/coremark/Makefile b/coremark/Makefile new file mode 100644 index 000000000..368d86958 --- /dev/null +++ b/coremark/Makefile @@ -0,0 +1,87 @@ +# +# Copyright (C) 2018 Lim Guo Wei +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=coremark +PKG_SOURCE_DATE:=2020-12-17 +PKG_SOURCE_VERSION:=5e0f662ce709f1af8d272bd8d3960034603d3850 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_DATE).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/eembc/coremark/tar.gz/$(PKG_SOURCE_VERSION)? +PKG_HASH:=skip +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION) + +PKG_MAINTAINER:=Lim Guo Wei +PKG_LICENSE:=Apache-2.0 +PKG_LICENSE_FILES:=LICENSE.md + +PKG_USE_MIPS16:=0 + +include $(INCLUDE_DIR)/package.mk + +define Package/coremark + SECTION:=utils + CATEGORY:=Utilities + TITLE:=CoreMark Embedded Microprocessor Benchmark + URL:=https://github.com/eembc/coremark +endef + +define Package/coremark/description + Embedded Microprocessor Benchmark +endef + +DIR_ARCH:=linux$(if $(CONFIG_ARCH_64BIT),64) + +define Package/coremark/config + config COREMARK_OPTIMIZE_O3 + bool "Use all optimizations (-O3)" + depends on PACKAGE_coremark + default y + help + This enables additional optmizations using the -O3 compilation flag. + + config COREMARK_ENABLE_MULTITHREADING + bool "Enable multithreading support" + depends on PACKAGE_coremark + default n + help + This enables multithreading support + + config COREMARK_NUMBER_OF_THREADS + int "Number of threads" + depends on COREMARK_ENABLE_MULTITHREADING + default 2 + help + Number of threads to run in parallel +endef + +TARGET_CFLAGS += -flto + +ifeq ($(CONFIG_COREMARK_OPTIMIZE_O3),y) + TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3 +endif + +ifeq ($(CONFIG_COREMARK_ENABLE_MULTITHREADING),y) + EXTRA_CFLAGS := -DMULTITHREAD=$(CONFIG_COREMARK_NUMBER_OF_THREADS) -DUSE_PTHREAD +endif + +define Build/Compile + $(SED) 's|EXE = .exe|EXE =|' $(PKG_BUILD_DIR)/$(DIR_ARCH)/core_portme.mak + mkdir $(PKG_BUILD_DIR)/$(ARCH) + $(CP) -r $(PKG_BUILD_DIR)/$(DIR_ARCH)/* $(PKG_BUILD_DIR)/$(ARCH) + $(MAKE) -C $(PKG_BUILD_DIR) PORT_DIR=$(ARCH) $(MAKE_FLAGS) \ + PORT_CFLAGS="$(TARGET_CFLAGS)" XCFLAGS="$(EXTRA_CFLAGS)" compile +endef + +define Package/coremark/install + $(INSTALL_DIR) $(1)/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/coremark $(1)/bin/ +endef + +$(eval $(call BuildPackage,coremark)) diff --git a/ddns-scripts/Makefile b/ddns-scripts/Makefile new file mode 100644 index 000000000..c2044d9c8 --- /dev/null +++ b/ddns-scripts/Makefile @@ -0,0 +1,438 @@ +# +# Copyright (C) 2008-2018 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=ddns-scripts +PKG_VERSION:=2.8.2 +PKG_RELEASE:=12 + +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/ddns-scripts/Default + SECTION:=net + CATEGORY:=Network + SUBMENU:=IP Addresses and Names + PKGARCH:=all +endef + + +define Package/ddns-scripts + $(call Package/ddns-scripts/Default) + TITLE:=Dynamic DNS Client scripts (with IPv6 support) + DEPENDS:=+ddns-scripts-services +endef + +define Package/ddns-scripts/description + Dynamic DNS Client scripts (with IPv6 support) + A highly configurable set of scripts for doing dynamic dns updates. + - IPv6 support + - DNS server support + - Glue Record support (require BIND host or KNOT host) + - DNS requests via TCP + - Proxy server support + - log file support + - support to run once + Version: $(PKG_VERSION)-$(PKG_RELEASE) + Info : https://openwrt.org/docs/guide-user/services/ddns/client +endef + +define Package/ddns-scripts/conffiles +/etc/config/ddns +endef + + +define Package/ddns-scripts-services + $(call Package/ddns-scripts/Default) + TITLE:=Common ddns providers +endef + +define Package/ddns-scripts-services/description + Dynamic DNS Client definitions for supported services +endef + + +define Package/ddns-scripts-cloudflare + $(call Package/ddns-scripts/Default) + TITLE:=Extension for cloudflare.com API v4 + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-cloudflare/description + Dynamic DNS Client scripts extension for cloudflare.com API v4 (require curl) +endef + + +define Package/ddns-scripts-freedns + $(call Package/ddns-scripts/Default) + TITLE:=Extension for freedns.42.pl + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-freedns/description + Dynamic DNS Client scripts extension for "freedns.42.pl". +endef + + +define Package/ddns-scripts-godaddy + $(call Package/ddns-scripts/Default) + TITLE:=Extension for godaddy.com API v1 + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-godaddy/description + Dynamic DNS Client scripts extension for "godaddy.com API v1". +endef + + +define Package/ddns-scripts-digitalocean + $(call Package/ddns-scripts/Default) + TITLE:=Extention for digitalocean.com API v2 + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-digitalocean/description + Dynamic DNS Client scripts extension for "digitalocean.com API v2". + The script directly updates a DNS record using the DO API. + It requires: + "option dns_server" to be set to the server to be used by nsupdate. + "option domain" the dns domain to update the record for (eg. A-record: home.) + "option username" the dns record name to update (eg. A-record: .example.com) + "option param_opt" the id of the dns record to update (check using chrome inspector in the DO dns tab) + "option password" the api token generated in the DO panel +endef + + +define Package/ddns-scripts-noip + $(call Package/ddns-scripts/Default) + TITLE:=Extension for no-ip.com + DEPENDS:=ddns-scripts +endef + +define Package/ddns-scripts-noip/description + Dynamic DNS Client scripts extension for "no-ip.com". +endef + + +define Package/ddns-scripts-nsupdate + $(call Package/ddns-scripts/Default) + TITLE:=Extension for using bind nsupdate. + DEPENDS:=ddns-scripts +bind-client +endef + +define Package/ddns-scripts-nsupdate/description + Dynamic DNS Client scripts extension for direct updates using bind nsupdate + The script directly updates a PowerDNS (or maybe bind server) via nsupdate + from bind-client package. + It requires: + "option dns_server" to be set to the server to be used by nsupdate. + "option username" should be set to the key name and + "option password" to the base64 encoded shared secret. +endef + + +define Package/ddns-scripts-route53 + $(call Package/ddns-scripts/Default) + TITLE:=Extension for route53 API v1 + DEPENDS:=ddns-scripts +curl +openssl-util +endef + +define Package/ddns-scripts-route53/description + Dynamic DNS Client scripts extension for Amazon AWS "route53 API v1". + Note: You must also install ca-certificate or ca-bundle. + It requires: + "option username" to be a valid AWS access key id + "option password" to be the matching AWS secret key id + "option domain" to contain the hosted zone ID +endef + + +define Package/ddns-scripts-cnkuai + $(call Package/ddns-scripts/Default) + TITLE:=CnKuai API + DEPENDS:=ddns-scripts +curl +giflib-utils +endef + +define Package/ddns-scripts-cnkuai/description + Dynamic DNS Client scripts extension for "cnkuai.cn". + It requires: + "option username" to be a valid CnKuai control panel id + "option password" to be the matching CnKuai control panel password + "option domain" to contain the domain +endef + + +define Package/ddns-scripts-gandi + $(call Package/ddns-scripts/Default) + TITLE:=Gandi API + DEPENDS:=ddns-scripts +curl +endef + +define Package/ddns-scripts-gandi/description + Dynamic DNS Client scripts extension for "gandi.net". + It requires: + "option username" to be a valid subdomain for gandi.net + "option password" to be a valid API key for ganid.net +endef + + +define Build/Configure +endef + +define Build/Compile +endef + + +define Package/ddns-scripts/install + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/etc/hotplug.d/iface/ddns \ + $(1)/etc/hotplug.d/iface/95-ddns + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/etc/init.d/ddns \ + $(1)/etc/init.d/ddns + + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/etc/config/ddns \ + $(1)/etc/config/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns + echo "$(PKG_VERSION)-$(PKG_RELEASE)" > $(1)/usr/share/ddns/version + + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_DATA) ./files/usr/lib/ddns/dynamic_dns_functions.sh \ + $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/dynamic_dns_lucihelper.sh \ + $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/dynamic_dns_updater.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/usr/bin/ddns.sh \ + $(1)/usr/bin/ddns +endef + +define Package/ddns-scripts/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns enabled + /etc/init.d/ddns start +fi +exit 0 +endef + +define Package/ddns-scripts/prerm +#!/bin/sh +if [ -n "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop + /etc/init.d/ddns disable +fi +exit 0 +endef + + +define Package/ddns-scripts-services/install + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/* \ + $(1)/usr/share/ddns/default + + # Remove special services + rm $(1)/usr/share/ddns/default/cloudflare.com-v4.json + rm $(1)/usr/share/ddns/default/freedns.42.pl.json + rm $(1)/usr/share/ddns/default/godaddy.com-v1.json + rm $(1)/usr/share/ddns/default/digitalocean.com-v2.json + rm $(1)/usr/share/ddns/default/no-ip.com.json + rm $(1)/usr/share/ddns/default/bind-nsupdate.json + rm $(1)/usr/share/ddns/default/route53-v1.json + rm $(1)/usr/share/ddns/default/cnkuai.cn.json + rm $(1)/usr/share/ddns/default/gandi.net.json +endef + + +define Package/ddns-scripts-cloudflare/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_cloudflare_com_v4.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/cloudflare.com-v4.json \ + $(1)/usr/share/ddns/default/ +endef + +define Package/ddns-scripts-cloudflare/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-freedns/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_freedns_42_pl.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/freedns.42.pl.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-freedns/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-godaddy/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_godaddy_com_v1.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/godaddy.com-v1.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-godaddy/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-digitalocean/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_digitalocean_com_v2.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/digitalocean.com-v2.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-digitalocean/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-noip/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_no-ip_com.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/no-ip.com.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-noip/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-nsupdate/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_nsupdate.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/bind-nsupdate.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-nsupdate/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-route53/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_route53_v1.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/route53-v1.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-route53/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-cnkuai/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_cnkuai_cn.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/cnkuai.cn.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-cnkuai/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +define Package/ddns-scripts-gandi/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) ./files/usr/lib/ddns/update_gandi_net.sh \ + $(1)/usr/lib/ddns + + $(INSTALL_DIR) $(1)/usr/share/ddns/default + $(INSTALL_DATA) ./files/usr/share/ddns/default/gandi.net.json \ + $(1)/usr/share/ddns/default +endef + +define Package/ddns-scripts-gandi/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + /etc/init.d/ddns stop +fi +exit 0 +endef + + +$(eval $(call BuildPackage,ddns-scripts)) +$(eval $(call BuildPackage,ddns-scripts-services)) +$(eval $(call BuildPackage,ddns-scripts-cloudflare)) +$(eval $(call BuildPackage,ddns-scripts-freedns)) +$(eval $(call BuildPackage,ddns-scripts-godaddy)) +$(eval $(call BuildPackage,ddns-scripts-digitalocean)) +$(eval $(call BuildPackage,ddns-scripts-noip)) +$(eval $(call BuildPackage,ddns-scripts-nsupdate)) +$(eval $(call BuildPackage,ddns-scripts-route53)) +$(eval $(call BuildPackage,ddns-scripts-cnkuai)) +$(eval $(call BuildPackage,ddns-scripts-gandi)) diff --git a/ddns-scripts/files/etc/config/ddns b/ddns-scripts/files/etc/config/ddns new file mode 100644 index 000000000..b45855f0d --- /dev/null +++ b/ddns-scripts/files/etc/config/ddns @@ -0,0 +1,32 @@ +# +# Please read https://openwrt.org/docs/guide-user/base-system/ddns +# +config ddns "global" + option ddns_dateformat "%F %R" +# option ddns_rundir "/var/run/ddns" +# option ddns_logdir "/var/log/ddns" + option ddns_loglines "250" + option upd_privateip "0" + + +config service "myddns_ipv4" + option service_name "dyndns.org" + option lookup_host "yourhost.example.com" + option domain "yourhost.example.com" + option username "your_username" + option password "your_password" + option interface "wan" + option ip_source "network" + option ip_network "wan" + +config service "myddns_ipv6" + option update_url "http://[USERNAME]:[PASSWORD]@your.provider.net/nic/update?hostname=[DOMAIN]&myip=[IP]" + option lookup_host "yourhost.example.com" + option domain "yourhost.example.com" + option username "your_username" + option password "your_password" + option use_ipv6 "1" + option interface "wan6" + option ip_source "network" + option ip_network "wan6" + diff --git a/ddns-scripts/files/etc/hotplug.d/iface/ddns b/ddns-scripts/files/etc/hotplug.d/iface/ddns new file mode 100644 index 000000000..9ef172deb --- /dev/null +++ b/ddns-scripts/files/etc/hotplug.d/iface/ddns @@ -0,0 +1,11 @@ +#!/bin/sh + +# there are other ACTIONs like ifupdate we don't need +case "$ACTION" in + ifup) # OpenWrt is giving a network not phys. Interface + /etc/init.d/ddns enabled && /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- start + ;; + ifdown) + /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- stop + ;; +esac diff --git a/ddns-scripts/files/etc/init.d/ddns b/ddns-scripts/files/etc/init.d/ddns new file mode 100644 index 000000000..5da360178 --- /dev/null +++ b/ddns-scripts/files/etc/init.d/ddns @@ -0,0 +1,24 @@ +#!/bin/sh /etc/rc.common +START=95 +STOP=10 + + +reload() { + /usr/lib/ddns/dynamic_dns_updater.sh -- reload + return 0 +} + +restart() { + /usr/lib/ddns/dynamic_dns_updater.sh -- stop + sleep 1 # give time to shutdown + /usr/lib/ddns/dynamic_dns_updater.sh -- start +} + +start() { + /usr/lib/ddns/dynamic_dns_updater.sh -- start +} + +stop() { + /usr/lib/ddns/dynamic_dns_updater.sh -- stop + return 0 +} diff --git a/ddns-scripts/files/usr/bin/ddns.sh b/ddns-scripts/files/usr/bin/ddns.sh new file mode 100644 index 000000000..921465f7e --- /dev/null +++ b/ddns-scripts/files/usr/bin/ddns.sh @@ -0,0 +1,172 @@ +#!/bin/sh +# +# Copyright (C) 2020 TDT AG +# +# This is free software, licensed under the GNU General Public License v2. +# See https://www.gnu.org/licenses/gpl-2.0.txt for more information. +# + +. /lib/functions.sh + +DDNS_PACKAGE_DIR="/usr/share/ddns" +URL="https://raw.githubusercontent.com/openwrt/packages/master/net/ddns-scripts/files" + +usage() { + local code="$1" + local msg="$2" + + echo "$msg" + echo "" + echo "Usage: $(basename "$0") " + echo "" + echo "Supported ddns :" + echo " service: Command for custom ddns service providers" + echo "" + echo "Supported ddns 'service' command :" + echo " update: Update local custom ddns service list" + echo " list-available: List all available custom service providers" + echo " list-installed: List all installed custom service providers" + echo " install : Install custom service provider" + echo " remove : Remove custom service provider" + echo " purge: Remove local custom ddns services" + + exit "$code" +} + +action_update() { + local cacert + + config_load ddns + config_get url global 'url' "${URL}${DDNS_PACKAGE_DIR}" + config_get cacert global 'cacert' "IGNORE" + url="${url}/list" + + mkdir -p "${DDNS_PACKAGE_DIR}" + + if [ "$cacert" = "IGNORE" ]; then + uclient-fetch \ + --no-check-certificate \ + "$url" \ + -O "${DDNS_PACKAGE_DIR}/list" + elif [ -f "$cacert" ]; then + uclient-fetch \ + --ca-certificate="${cacert}" \ + "$url" \ + -O "${DDNS_PACKAGE_DIR}/list" + elif [ -n "$cacert" ]; then + echo "Certification file not found ($cacert)" + exit 5 + fi +} + +action_list_available() { + if [ -f "${DDNS_PACKAGE_DIR}/list" ]; then + cat "${DDNS_PACKAGE_DIR}/list" + else + echo "No custom service list file found. Please download first" + exit 3 + fi +} + +action_list_installed() { + if [ -d "${DDNS_PACKAGE_DIR}/custom" ]; then + ls "${DDNS_PACKAGE_DIR}/custom" + else + echo "No custom services installed" + exit 4 + fi +} + +action_install() { + local service="$1" + + local url cacert + + config_load ddns + config_get url global 'url' "${URL}${DDNS_PACKAGE_DIR}/default" + config_get cacert global 'cacert' "IGNORE" + url="${url}/${service}.json" + + if [ -z "$service" ]; then + usage "4" "No custom service specified" + fi + + mkdir -p "${DDNS_PACKAGE_DIR}/custom" + + if [ "$cacert" = "IGNORE" ]; then + uclient-fetch \ + --no-check-certificate \ + "${url}" \ + -O "${DDNS_PACKAGE_DIR}/custom/${service}.json" + elif [ -f "$cacert" ]; then + uclient-fetch \ + --ca-certifcate="${cacert}" \ + "${url}" \ + -O "${DDNS_PACKAGE_DIR}/custom/${service}.json" + elif [ -n "$cacert" ]; then + echo "Certification file not found ($cacert)" + exit 5 + fi +} + +action_remove() { + local service="$1" + if [ -z "$service" ]; then + usage "4" "No custom service specified" + fi + + rm "${DDNS_PACKAGE_DIR}/custom/${service}.json" +} + +action_purge() { + rm -rf "${DDNS_PACKAGE_DIR}/custom" + rm -rf "${DDNS_PACKAGE_DIR}/list" +} + +sub_service() { + local action="$1" + local service="$2" + + case "$action" in + update) + action_update + ;; + list-available) + action_list_available + ;; + list-installed) + action_list_installed + ;; + purge) + action_purge + ;; + install) + action_install "$service" + ;; + remove) + action_remove "$service" + ;; + *) + usage "2" "Action not supported" + ;; + esac +} + +main() { + local cmd="$1" + local action="$2" + local service="$3" + + [ "$#" -eq 0 ] && usage "1" + + case "${cmd}" in + service) + sub_service "${action}" "${service}" + ;; + *) + usage "1" "Command not supported" + ;; + esac +} + +main "$@" diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh new file mode 100644 index 000000000..f36d11ca7 --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh @@ -0,0 +1,1396 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_functions.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +# Original written by Eric Paul Bishop, January 2008 +# (Loosely) based on the script on the one posted by exobyte in the forums here: +# http://forum.openwrt.org/viewtopic.php?id=14040 +# extended and partial rewritten +#.2014-2018 Christian Schoenebeck +# +# function timeout +# copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh +# @author Anthony Thyssen 6 April 2011 +# +# variables in small chars are read from /etc/config/ddns +# variables in big chars are defined inside these scripts as global vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. /lib/functions.sh +. /lib/functions/network.sh + +# GLOBAL VARIABLES # +if [ -f "/usr/share/ddns/version" ]; then + VERSION="$(cat "/usr/share/ddns/version")" +else + VERSION="unknown" +fi +SECTION_ID="" # hold config's section name +VERBOSE=0 # default mode is log to console, but easily changed with parameter +MYPROG=$(basename $0) # my program call name + +LOGFILE="" # logfile - all files are set in dynamic_dns_updater.sh +PIDFILE="" # pid file +UPDFILE="" # store UPTIME of last update +DATFILE="" # save stdout data of WGet and other external programs called +ERRFILE="" # save stderr output of WGet and other external programs called +IPFILE="" # store registered IP for read by LuCI status +TLDFILE=/usr/share/public_suffix_list.dat.gz # TLD file used by split_FQDN + +CHECK_SECONDS=0 # calculated seconds out of given +FORCE_SECONDS=0 # interval and unit +RETRY_SECONDS=0 # in configuration + +LAST_TIME=0 # holds the uptime of last successful update +CURR_TIME=0 # holds the current uptime +NEXT_TIME=0 # calculated time for next FORCED update +EPOCH_TIME=0 # seconds since 1.1.1970 00:00:00 + +REGISTERED_IP="" # holds the IP read from DNS +LOCAL_IP="" # holds the local IP read from the box + +URL_USER="" # url encoded $username from config file +URL_PASS="" # url encoded $password from config file +URL_PENC="" # url encoded $param_enc from config file + +UPD_ANSWER="" # Answer given by service on success + +ERR_LAST=0 # used to save $? return code of program and function calls +ERR_UPDATE=0 # error counter on different local and registered ip + +PID_SLEEP=0 # ProcessID of current background "sleep" + +# regular expression to detect IPv4 / IPv6 +# IPv4 0-9 1-3x "." 0-9 1-3x "." 0-9 1-3x "." 0-9 1-3x +IPV4_REGEX="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" +# IPv6 ( ( 0-9a-f 1-4char ":") min 1x) ( ( 0-9a-f 1-4char )optional) ( (":" 0-9a-f 1-4char ) min 1x) +IPV6_REGEX="\(\([0-9A-Fa-f]\{1,4\}:\)\{1,\}\)\(\([0-9A-Fa-f]\{1,4\}\)\{0,1\}\)\(\(:[0-9A-Fa-f]\{1,4\}\)\{1,\}\)" + +# characters that are dangerous to pass to a shell command line +SHELL_ESCAPE="[\"\'\`\$\!();><{}?|\[\]\*\\\\]" + +# dns character set. "-" must be the last character +DNS_CHARSET="[@a-zA-Z0-9._-]" + +# domains can have * for wildcard. "-" must be the last character +DNS_CHARSET_DOMAIN="[@a-zA-Z0-9._*-]" + +# detect if called by ddns-lucihelper.sh script, disable retrys (empty variable == false) +LUCI_HELPER=$(printf %s "$MYPROG" | grep -i "luci") + +# Name Server Lookup Programs +BIND_HOST=$(command -v host) +KNOT_HOST=$(command -v khost) +DRILL=$(command -v drill) +HOSTIP=$(command -v hostip) +NSLOOKUP=$(command -v nslookup) + +# Transfer Programs +WGET=$(command -v wget) +$WGET -V 2>/dev/null | grep -F -q +https && WGET_SSL=$WGET + +CURL=$(command -v curl) +# CURL_SSL not empty then SSL support available +CURL_SSL=$($CURL -V 2>/dev/null | grep -F "https") +# CURL_PROXY not empty then Proxy support available +CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy") + +UCLIENT_FETCH=$(command -v uclient-fetch) + +# Global configuration settings +# allow NON-public IP's +upd_privateip=$(uci -q get ddns.global.upd_privateip) || upd_privateip=0 + +# directory to store run information to. +ddns_rundir=$(uci -q get ddns.global.ddns_rundir) || ddns_rundir="/var/run/ddns" +[ -d $ddns_rundir ] || mkdir -p -m755 $ddns_rundir + +# directory to store log files +ddns_logdir=$(uci -q get ddns.global.ddns_logdir) || ddns_logdir="/var/log/ddns" +[ -d $ddns_logdir ] || mkdir -p -m755 $ddns_logdir + +# number of lines to before rotate logfile +ddns_loglines=$(uci -q get ddns.global.ddns_loglines) || ddns_loglines=250 +ddns_loglines=$((ddns_loglines + 1)) # correct sed handling + +# format to show date information in log and luci-app-ddns default ISO 8601 format +ddns_dateformat=$(uci -q get ddns.global.ddns_dateformat) || ddns_dateformat="%F %R" +DATE_PROG="date +'$ddns_dateformat'" + +# USE_CURL if GNU Wget and cURL installed normally Wget is used by do_transfer() +# to change this use global option use_curl '1' +USE_CURL=$(uci -q get ddns.global.use_curl) || USE_CURL=0 # read config +[ -n "$CURL" ] || USE_CURL=0 # check for cURL + +# loads all options for a given package and section +# also, sets all_option_variables to a list of the variable names +# $1 = ddns, $2 = SECTION_ID +load_all_config_options() +{ + local __PKGNAME="$1" + local __SECTIONID="$2" + local __VAR + local __ALL_OPTION_VARIABLES="" + + # this callback loads all the variables in the __SECTIONID section when we do + # config_load. We need to redefine the option_cb for different sections + # so that the active one isn't still active after we're done with it. For reference + # the $1 variable is the name of the option and $2 is the name of the section + config_cb() + { + if [ ."$2" = ."$__SECTIONID" ]; then + option_cb() + { + __ALL_OPTION_VARIABLES="$__ALL_OPTION_VARIABLES $1" + } + else + option_cb() { return 0; } + fi + } + + config_load "$__PKGNAME" + + # Given SECTION_ID not found so no data, so return 1 + [ -z "$__ALL_OPTION_VARIABLES" ] && return 1 + + for __VAR in $__ALL_OPTION_VARIABLES + do + config_get "$__VAR" "$__SECTIONID" "$__VAR" + done + return 0 +} + +# read's all service sections from ddns config +# $1 = Name of variable to store +load_all_service_sections() { + local __DATA="" + config_cb() + { + # only look for section type "service", ignore everything else + [ "$1" = "service" ] && __DATA="$__DATA $2" + } + config_load "ddns" + + eval "$1=\"$__DATA\"" + return +} + +# starts updater script for all given sections or only for the one given +# $1 = interface (Optional: when given only scripts are started +# configured for that interface) +# used by /etc/hotplug.d/iface/95-ddns on IFUP +# and by /etc/init.d/ddns start +start_daemon_for_all_ddns_sections() +{ + local __EVENTIF="$1" + local __SECTIONS="" + local __SECTIONID="" + local __IFACE="" + + load_all_service_sections __SECTIONS + for __SECTIONID in $__SECTIONS; do + config_get __IFACE "$__SECTIONID" interface "wan" + [ -z "$__EVENTIF" -o "$__IFACE" = "$__EVENTIF" ] || continue + if [ $VERBOSE -eq 0 ]; then # start in background + /usr/lib/ddns/dynamic_dns_updater.sh -v 0 -S "$__SECTIONID" -- start & + else + /usr/lib/ddns/dynamic_dns_updater.sh -v "$VERBOSE" -S "$__SECTIONID" -- start + fi + done +} + +# stop sections process incl. childs (sleeps) +# $1 = section +stop_section_processes() { + local __PID=0 + local __PIDFILE="$ddns_rundir/$1.pid" + [ $# -ne 1 ] && write_log 12 "Error calling 'stop_section_processes()' - wrong number of parameters" + + [ -e "$__PIDFILE" ] && { + __PID=$(cat $__PIDFILE) + ps | grep "^[\t ]*$__PID" >/dev/null 2>&1 && kill $__PID || __PID=0 # terminate it + } + [ $__PID -eq 0 ] # report if process was running +} + +# stop updater script for all defines sections or only for one given +# $1 = interface (optional) +# used by /etc/hotplug.d/iface/95-ddns on 'ifdown' +# and by /etc/init.d/ddns stop +# needed because we also need to kill "sleep" child processes +stop_daemon_for_all_ddns_sections() { + local __EVENTIF="$1" + local __SECTIONS="" + local __SECTIONID="" + local __IFACE="" + + load_all_service_sections __SECTIONS + for __SECTIONID in $__SECTIONS; do + config_get __IFACE "$__SECTIONID" interface "wan" + [ -z "$__EVENTIF" -o "$__IFACE" = "$__EVENTIF" ] || continue + stop_section_processes "$__SECTIONID" + done +} + +# reports to console, logfile, syslog +# $1 loglevel 7 == Debug to 0 == EMERG +# value +10 will exit the scripts +# $2..n text to report +write_log() { + local __LEVEL __EXIT __CMD __MSG __MSE + local __TIME=$(date +%H%M%S) + [ $1 -ge 10 ] && { + __LEVEL=$(($1-10)) + __EXIT=1 + } || { + __LEVEL=$1 + __EXIT=0 + } + shift # remove loglevel + [ $__EXIT -eq 0 ] && __MSG="$*" || __MSG="$* - TERMINATE" + case $__LEVEL in # create log message and command depending on loglevel + 0) __CMD="logger -p user.emerg -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME EMERG : $__MSG" ;; + 1) __CMD="logger -p user.alert -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME ALERT : $__MSG" ;; + 2) __CMD="logger -p user.crit -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME CRIT : $__MSG" ;; + 3) __CMD="logger -p user.err -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME ERROR : $__MSG" ;; + 4) __CMD="logger -p user.warn -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME WARN : $__MSG" ;; + 5) __CMD="logger -p user.notice -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME note : $__MSG" ;; + 6) __CMD="logger -p user.info -t ddns-scripts[$$] $SECTION_ID: $__MSG" + __MSG=" $__TIME info : $__MSG" ;; + 7) __MSG=" $__TIME : $__MSG";; + *) return;; + esac + + # verbose echo + [ $VERBOSE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG" + # write to logfile + if [ ${use_logfile:-1} -eq 1 -o $VERBOSE -gt 1 ]; then + if [ -n "$password" ]; then + # url encode __MSG, password already done + urlencode __MSE "$__MSG" + # replace encoded password inside encoded message + # and url decode (newline was encoded as %00) + __MSG=$( echo -e "$__MSE" \ + | sed -e "s/$URL_PASS/***PW***/g" \ + | sed -e "s/+/ /g; s/%00/\n/g; s/%/\\\\x/g" | xargs -0 printf "%b" ) + fi + printf "%s\n" "$__MSG" >> $LOGFILE + # VERBOSE > 1 then NO loop so NO truncate log to $ddns_loglines lines + [ $VERBOSE -gt 1 ] || sed -i -e :a -e '$q;N;'$ddns_loglines',$D;ba' $LOGFILE + fi + [ -n "$LUCI_HELPER" ] && return # nothing else todo when running LuCI helper script + [ $__LEVEL -eq 7 ] && return # no syslog for debug messages + __CMD=$(echo -e "$__CMD" | tr -d '\n' | tr '\t' ' ') # remove \n \t chars + [ $__EXIT -eq 1 ] && { + eval '$__CMD' # force syslog before exit + exit 1 + } + [ $use_syslog -eq 0 ] && return + [ $((use_syslog + __LEVEL)) -le 7 ] && eval '$__CMD' + + return +} + +# replace all special chars to their %hex value +# used for USERNAME and PASSWORD in update_url +# unchanged: "-"(minus) "_"(underscore) "."(dot) "~"(tilde) +# to verify: "'"(single quote) '"'(double quote) # because shell delimiter +# "$"(Dollar) # because used as variable output +# tested with the following string stored via Luci Application as password / username +# A B!"#AA$1BB%&'()*+,-./:;<=>?@[\]^_`{|}~ without problems at Dollar or quotes +urlencode() { + # $1 Name of Variable to store encoded string to + # $2 string to encode + local __ENC + + [ $# -ne 2 ] && write_log 12 "Error calling 'urlencode()' - wrong number of parameters" + + __ENC="$(awk -v str="$2" 'BEGIN{ORS="";for(i=32;i<=127;i++)lookup[sprintf("%c",i)]=i + for(k=1;k<=length(str);++k){enc=substr(str,k,1);if(enc!~"[-_.~a-zA-Z0-9]")enc=sprintf("%%%02x", lookup[enc]);print enc}}')" + + eval "$1=\"$__ENC\"" # transfer back to variable + return 0 +} + +# extract url or script for given DDNS Provider from +# $1 Name of the provider +# $2 Provider directory +# $3 Name of Variable to store url to +# $4 Name of Variable to store script to +# $5 Name of Variable to store service answer to +get_service_data() { + local provider="$1" + shift + local dir="$1" + shift + + . /usr/share/libubox/jshn.sh + local name data url answer script + + [ $# -ne 3 ] && write_log 12 "Error calling 'get_service_data()' - wrong number of parameters" + + [ -f "${dir}/${provider}.json" ] || { + eval "$1=\"\"" + eval "$2=\"\"" + eval "$3=\"\"" + return 1 + } + + json_load_file "${dir}/${provider}.json" + json_get_var name "name" + if [ "$use_ipv6" -eq "1" ]; then + json_select "ipv6" + else + json_select "ipv4" + fi + json_get_var data "url" + json_get_var answer "answer" + json_select ".." + json_cleanup + + # check if URL or SCRIPT is given + url=$(echo "$data" | grep "^http") + [ -z "$url" ] && script="/usr/lib/ddns/${data}" + + eval "$1=\"$url\"" + eval "$2=\"$script\"" + eval "$3=\"$answer\"" + return 0 +} + +# Calculate seconds from interval and unit +# $1 Name of Variable to store result in +# $2 Number and +# $3 Unit of time interval +get_seconds() { + [ $# -ne 3 ] && write_log 12 "Error calling 'get_seconds()' - wrong number of parameters" + case "$3" in + "days" ) eval "$1=$(( $2 * 86400 ))";; + "hours" ) eval "$1=$(( $2 * 3600 ))";; + "minutes" ) eval "$1=$(( $2 * 60 ))";; + * ) eval "$1=$2";; + esac + return 0 +} + +timeout() { + #.copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh + # only did the following changes + # - commented out "#!/bin/bash" and usage section + # - replace exit by return for usage as function + # - some reformatting + # + # timeout [-SIG] time [--] command args... + # + # Run the given command until completion, but kill it if it runs too long. + # Specifically designed to exit immediately (no sleep interval) and clean up + # nicely without messages or leaving any extra processes when finished. + # + # Example use + # timeout 5 countdown + # + # Based on notes in my "Shell Script Hints", section "Command Timeout" + # http://www.ict.griffith.edu.au/~anthony/info/shell/script.hints + # + # This script uses a lot of tricks to terminate both the background command, + # the timeout script, and even the sleep process. It also includes trap + # commands to prevent sub-shells reporting expected "Termination Errors". + # + # It took years of occasional trials, errors and testing to get a pure bash + # timeout command working as well as this does. + # + #.Anthony Thyssen 6 April 2011 + # +# PROGNAME=$(type $0 | awk '{print $3}') # search for executable on path +# PROGDIR=$(dirname $PROGNAME) # extract directory of program +# PROGNAME=$(basename $PROGNAME) # base name of program + + # output the script comments as docs +# Usage() { +# echo >&2 "$PROGNAME:" "$@" +# sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' "$PROGDIR/$PROGNAME" +# exit 10; +# } + + SIG=-TERM + + while [ $# -gt 0 ]; do + case "$1" in + --) + # forced end of user options + shift; + break ;; +# -\?|--help|--doc*) +# Usage ;; + [0-9]*) + TIMEOUT="$1" ;; + -*) + SIG="$1" ;; + *) + # unforced end of user options + break ;; + esac + shift # next option + done + + # run main command in backgrounds and get its pid + "$@" & + command_pid=$! + + # timeout sub-process abort countdown after ABORT seconds! also backgrounded + sleep_pid=0 + ( + # cleanup sleep process + trap 'kill -TERM $sleep_pid; return 1' 1 2 3 15 + # sleep timeout period in background + sleep $TIMEOUT & + sleep_pid=$! + wait $sleep_pid + # Abort the command + kill $SIG $command_pid >/dev/null 2>&1 + return 1 + ) & + timeout_pid=$! + + # Wait for main command to finished or be timed out + wait $command_pid + status=$? + + # Clean up timeout sub-shell - if it is still running! + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null + + # Uncomment to check if a LONG sleep still running (no sleep should be) + # sleep 1 + # echo "-----------" + # /bin/ps j # uncomment to show if abort "sleep" is still sleeping + + return $status +} + +# sanitize a variable +# $1 variable name +# $2 allowed shell pattern +# $3 disallowed shell pattern +sanitize_variable() { + local __VAR=$1 + eval __VALUE=\$$__VAR + local __ALLOWED=$2 + local __REJECT=$3 + + # removing all allowed should give empty string + if [ -n "$__ALLOWED" ]; then + [ -z "${__VALUE//$__ALLOWED}" ] || write_log 12 "sanitize on $__VAR found characters outside allowed subset" + fi + + # removing rejected pattern should give the same string as the input + if [ -n "$__REJECT" ]; then + [ "$__VALUE" = "${__VALUE//$__REJECT}" ] || write_log 12 "sanitize on $__VAR found rejected characters" + fi +} + +# verify given host and port is connectable +# $1 Host/IP to verify +# $2 Port to verify +verify_host_port() { + local __HOST=$1 + local __PORT=$2 + local __NC=$(command -v nc) + local __NCEXT=$($(command -v nc) --help 2>&1 | grep "\-w" 2>/dev/null) # busybox nc compiled with extensions + local __IP __IPV4 __IPV6 __RUNPROG __PROG __ERR + # return codes + # 1 system specific error + # 2 nslookup/host error + # 3 nc (netcat) error + # 4 unmatched IP version + + [ $# -ne 2 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters" + + # check if ip or FQDN was given + __IPV4=$(echo $__HOST | grep -m 1 -o "$IPV4_REGEX$") # do not detect ip in 0.0.0.0.example.com + __IPV6=$(echo $__HOST | grep -m 1 -o "$IPV6_REGEX") + # if FQDN given get IP address + [ -z "$__IPV4" -a -z "$__IPV6" ] && { + if [ -n "$BIND_HOST" ]; then # use BIND host if installed + __PROG="BIND host" + __RUNPROG="$BIND_HOST $__HOST >$DATFILE 2>$ERRFILE" + elif [ -n "$KNOT_HOST" ]; then # use Knot host if installed + __PROG="Knot host" + __RUNPROG="$KNOT_HOST $__HOST >$DATFILE 2>$ERRFILE" + elif [ -n "$DRILL" ]; then # use drill if installed + __PROG="drill" + __RUNPROG="$DRILL -V0 $__HOST A >$DATFILE 2>$ERRFILE" # IPv4 + __RUNPROG="$__RUNPROG; $DRILL -V0 $__HOST AAAA >>$DATFILE 2>>$ERRFILE" # IPv6 + elif [ -n "$HOSTIP" ]; then # use hostip if installed + __PROG="hostip" + __RUNPROG="$HOSTIP $__HOST >$DATFILE 2>$ERRFILE" # IPv4 + __RUNPROG="$__RUNPROG; $HOSTIP -6 $__HOST >>$DATFILE 2>>$ERRFILE" # IPv6 + else # use BusyBox nslookup + __PROG="BusyBox nslookup" + __RUNPROG="$NSLOOKUP $__HOST >$DATFILE 2>$ERRFILE" + fi + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + # command error + [ $__ERR -gt 0 ] && { + write_log 3 "DNS Resolver Error - $__PROG Error '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + return 2 + } + # extract IP address + if [ -n "$BIND_HOST" -o -n "$KNOT_HOST" ]; then # use BIND host or Knot host if installed + __IPV4="$(awk -F "address " '/has address/ {print $2; exit}' "$DATFILE")" + __IPV6="$(awk -F "address " '/has IPv6/ {print $2; exit}' "$DATFILE")" + elif [ -n "$DRILL" ]; then # use drill if installed + __IPV4="$(awk '/^'"$__HOST"'/ {print $5}' "$DATFILE" | grep -m 1 -o "$IPV4_REGEX")" + __IPV6="$(awk '/^'"$__HOST"'/ {print $5}' "$DATFILE" | grep -m 1 -o "$IPV6_REGEX")" + elif [ -n "$HOSTIP" ]; then # use hostip if installed + __IPV4="$(grep -m 1 -o "$IPV4_REGEX" "$DATFILE")" + __IPV6="$(grep -m 1 -o "$IPV6_REGEX" "$DATFILE")" + else # use BusyBox nslookup + __IPV4="$(sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($IPV4_REGEX\).*$/\\1/p }" "$DATFILE")" + __IPV6="$(sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($IPV6_REGEX\).*$/\\1/p }" "$DATFILE")" + fi + } + + # check IP version if forced + if [ $force_ipversion -ne 0 ]; then + __ERR=0 + [ $use_ipv6 -eq 0 -a -z "$__IPV4" ] && __ERR=4 + [ $use_ipv6 -eq 1 -a -z "$__IPV6" ] && __ERR=6 + [ $__ERR -gt 0 ] && { + [ -n "$LUCI_HELPER" ] && return 4 + write_log 14 "Verify host Error '4' - Forced IP Version IPv$__ERR don't match" + } + fi + + # verify nc command + # busybox nc compiled without -l option "NO OPT l!" -> critical error + $__NC --help 2>&1 | grep -i "NO OPT l!" >/dev/null 2>&1 && \ + write_log 12 "Busybox nc (netcat) compiled without '-l' option, error 'NO OPT l!'" + # busybox nc compiled with extensions + $__NC --help 2>&1 | grep "\-w" >/dev/null 2>&1 && __NCEXT="TRUE" + + # connectivity test + # run busybox nc to HOST PORT + # busybox might be compiled with "FEATURE_PREFER_IPV4_ADDRESS=n" + # then nc will try to connect via IPv6 if there is any IPv6 available on any host interface + # not worrying, if there is an IPv6 wan address + # so if not "force_ipversion" to use_ipv6 then connect test via ipv4, if available + [ $force_ipversion -ne 0 -a $use_ipv6 -ne 0 -o -z "$__IPV4" ] && __IP=$__IPV6 || __IP=$__IPV4 + + if [ -n "$__NCEXT" ]; then # BusyBox nc compiled with extensions (timeout support) + __RUNPROG="$__NC -w 1 $__IP $__PORT $DATFILE 2>$ERRFILE" + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + [ $__ERR -eq 0 ] && return 0 + write_log 3 "Connect error - BusyBox nc (netcat) Error '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + return 3 + else # nc compiled without extensions (no timeout support) + __RUNPROG="timeout 2 -- $__NC $__IP $__PORT $DATFILE 2>$ERRFILE" + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + [ $__ERR -eq 0 ] && return 0 + write_log 3 "Connect error - BusyBox nc (netcat) timeout Error '$__ERR'" + return 3 + fi +} + +# verify given DNS server if connectable +# $1 DNS server to verify +verify_dns() { + local __ERR=255 # last error buffer + local __CNT=0 # error counter + + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_dns()' - wrong number of parameters" + write_log 7 "Verify DNS server '$1'" + + while [ $__ERR -ne 0 ]; do + # DNS uses port 53 + verify_host_port "$1" "53" + __ERR=$? + if [ -n "$LUCI_HELPER" ]; then # no retry if called by LuCI helper script + return $__ERR + elif [ $__ERR -ne 0 -a $VERBOSE -gt 1 ]; then # VERBOSE > 1 then NO retry + write_log 4 "Verify DNS server '$1' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + elif [ $__ERR -ne 0 ]; then + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Verify DNS server '$1' failed after $retry_count retries" + + write_log 4 "Verify DNS server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + fi + done + return 0 +} + +# analyze and verify given proxy string +# $1 Proxy-String to verify +verify_proxy() { + # complete entry user:password@host:port + # inside user and password NO '@' of ":" allowed + # host and port only host:port + # host only host ERROR unsupported + # IPv4 address instead of host 123.234.234.123 + # IPv6 address instead of host [xxxx:....:xxxx] in square bracket + local __TMP __HOST __PORT + local __ERR=255 # last error buffer + local __CNT=0 # error counter + + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_proxy()' - wrong number of parameters" + write_log 7 "Verify Proxy server 'http://$1'" + + # try to split user:password "@" host:port + __TMP=$(echo $1 | awk -F "@" '{print $2}') + # no "@" found - only host:port is given + [ -z "$__TMP" ] && __TMP="$1" + # now lets check for IPv6 address + __HOST=$(echo $__TMP | grep -m 1 -o "$IPV6_REGEX") + # IPv6 host address found read port + if [ -n "$__HOST" ]; then + # IPv6 split at "]:" + __PORT=$(echo $__TMP | awk -F "]:" '{print $2}') + else + __HOST=$(echo $__TMP | awk -F ":" '{print $1}') + __PORT=$(echo $__TMP | awk -F ":" '{print $2}') + fi + # No Port detected - EXITING + [ -z "$__PORT" ] && { + [ -n "$LUCI_HELPER" ] && return 5 + write_log 14 "Invalid Proxy server Error '5' - proxy port missing" + } + + while [ $__ERR -gt 0 ]; do + verify_host_port "$__HOST" "$__PORT" + __ERR=$? + if [ -n "$LUCI_HELPER" ]; then # no retry if called by LuCI helper script + return $__ERR + elif [ $__ERR -gt 0 -a $VERBOSE -gt 1 ]; then # VERBOSE > 1 then NO retry + write_log 4 "Verify Proxy server '$1' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + elif [ $__ERR -gt 0 ]; then + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Verify Proxy server '$1' failed after $retry_count retries" + + write_log 4 "Verify Proxy server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + fi + done + return 0 +} + +do_transfer() { + # $1 # URL to use + local __URL="$1" + local __ERR=0 + local __CNT=0 # error counter + local __PROG __RUNPROG + + [ $# -ne 1 ] && write_log 12 "Error in 'do_transfer()' - wrong number of parameters" + + # Use ip_network as default for bind_network if not separately specified + [ -z "$bind_network" ] && [ "$ip_source" = "network" ] && [ "$ip_network" ] && bind_network="$ip_network" + + # lets prefer GNU Wget because it does all for us - IPv4/IPv6/HTTPS/PROXY/force IP version + if [ -n "$WGET_SSL" ] && [ $USE_CURL -eq 0 ]; then # except global option use_curl is set to "1" + __PROG="$WGET --hsts-file=/tmp/.wget-hsts -nv -t 1 -O $DATFILE -o $ERRFILE" # non_verbose no_retry outfile errfile + # force network/ip to use for communication + if [ -n "$bind_network" ]; then + local __BINDIP + # set correct program to detect IP + [ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" || __RUNPROG="network_get_ipaddr6" + eval "$__RUNPROG __BINDIP $bind_network" || \ + write_log 13 "Can not detect local IP using '$__RUNPROG $bind_network' - Error: '$?'" + write_log 7 "Force communication via IP '$__BINDIP'" + __PROG="$__PROG --bind-address=$__BINDIP" + fi + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # set certificate parameters + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then # idea from Ticket #15327 to ignore server cert + __PROG="$__PROG --no-check-certificate" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --ca-certificate=${cacert}" + elif [ -d "$cacert" ]; then + __PROG="$__PROG --ca-directory=${cacert}" + elif [ -n "$cacert" ]; then # it's not a file and not a directory but given + write_log 14 "No valid certificate(s) found at '$cacert' for HTTPS communication" + fi + fi + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + [ -z "$proxy" ] && __PROG="$__PROG --no-proxy" + + __RUNPROG="$__PROG '$__URL'" # build final command + __PROG="GNU Wget" # reuse for error logging + + # 2nd choice is cURL IPv4/IPv6/HTTPS + # libcurl might be compiled without Proxy or HTTPS Support + elif [ -n "$CURL" ]; then + __PROG="$CURL -RsS -o $DATFILE --stderr $ERRFILE" + # check HTTPS support + [ -z "$CURL_SSL" -a $use_https -eq 1 ] && \ + write_log 13 "cURL: libcurl compiled without https support" + # force network/interface-device to use for communication + if [ -n "$bind_network" ]; then + local __DEVICE + network_get_device __DEVICE $bind_network || \ + write_log 13 "Can not detect local device using 'network_get_device $bind_network' - Error: '$?'" + write_log 7 "Force communication via device '$__DEVICE'" + __PROG="$__PROG --interface $__DEVICE" + fi + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # set certificate parameters + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then # idea from Ticket #15327 to ignore server cert + __PROG="$__PROG --insecure" # but not empty better to use "IGNORE" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --cacert $cacert" + elif [ -d "$cacert" ]; then + __PROG="$__PROG --capath $cacert" + elif [ -n "$cacert" ]; then # it's not a file and not a directory but given + write_log 14 "No valid certificate(s) found at '$cacert' for HTTPS communication" + fi + fi + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + # or check if libcurl compiled with proxy support + if [ -z "$proxy" ]; then + __PROG="$__PROG --noproxy '*'" + elif [ -z "$CURL_PROXY" ]; then + # if libcurl has no proxy support and proxy should be used then force ERROR + write_log 13 "cURL: libcurl compiled without Proxy support" + fi + + __RUNPROG="$__PROG '$__URL'" # build final command + __PROG="cURL" # reuse for error logging + + # uclient-fetch possibly with ssl support if /lib/libustream-ssl.so installed + elif [ -n "$UCLIENT_FETCH" ]; then + # UCLIENT_FETCH_SSL not empty then SSL support available + UCLIENT_FETCH_SSL=$(find /lib /usr/lib -name libustream-ssl.so* 2>/dev/null) + __PROG="$UCLIENT_FETCH -q -O $DATFILE" + # force network/ip not supported + [ -n "$__BINDIP" ] && \ + write_log 14 "uclient-fetch: FORCE binding to specific address not supported" + # force ip version to use + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" # force IPv4/IPv6 + fi + # https possibly not supported + [ $use_https -eq 1 -a -z "$UCLIENT_FETCH_SSL" ] && \ + write_log 14 "uclient-fetch: no HTTPS support! Additional install one of ustream-ssl packages" + # proxy support + [ -z "$proxy" ] && __PROG="$__PROG -Y off" || __PROG="$__PROG -Y on" + # https & certificates + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then + __PROG="$__PROG --no-check-certificate" + elif [ -f "$cacert" ]; then + __PROG="$__PROG --ca-certificate=$cacert" + elif [ -n "$cacert" ]; then # it's not a file; nothing else supported + write_log 14 "No valid certificate file '$cacert' for HTTPS communication" + fi + fi + __RUNPROG="$__PROG '$__URL' 2>$ERRFILE" # build final command + __PROG="uclient-fetch" # reuse for error logging + + # Busybox Wget or any other wget in search $PATH (did not support neither IPv6 nor HTTPS) + elif [ -n "$WGET" ]; then + __PROG="$WGET -q -O $DATFILE" + # force network/ip not supported + [ -n "$__BINDIP" ] && \ + write_log 14 "BusyBox Wget: FORCE binding to specific address not supported" + # force ip version not supported + [ $force_ipversion -eq 1 ] && \ + write_log 14 "BusyBox Wget: Force connecting to IPv4 or IPv6 addresses not supported" + # https not supported + [ $use_https -eq 1 ] && \ + write_log 14 "BusyBox Wget: no HTTPS support" + # disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set) + [ -z "$proxy" ] && __PROG="$__PROG -Y off" + + __RUNPROG="$__PROG '$__URL' 2>$ERRFILE" # build final command + __PROG="Busybox Wget" # reuse for error logging + + else + write_log 13 "Neither 'Wget' nor 'cURL' nor 'uclient-fetch' installed or executable" + fi + + while : ; do + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG # DO transfer + __ERR=$? # save error code + [ $__ERR -eq 0 ] && return 0 # no error leave + [ -n "$LUCI_HELPER" ] && return 1 # no retry if called by LuCI helper script + + write_log 3 "$__PROG Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Transfer failed - Verbose Mode: $VERBOSE - NO retry on error" + return 1 + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Transfer failed after $retry_count retries" + + write_log 4 "Transfer failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'do_transfer()' - program coding error" +} + +send_update() { + # $1 # IP to set at DDNS service provider + local __IP + + [ $# -ne 1 ] && write_log 12 "Error calling 'send_update()' - wrong number of parameters" + + if [ $upd_privateip -eq 0 ]; then + # verify given IP / no private IPv4's / no IPv6 addr starting with fxxx of with ":" + [ $use_ipv6 -eq 0 ] && __IP=$(echo $1 | grep -v -E "(^0|^10\.|^100\.6[4-9]\.|^100\.[7-9][0-9]\.|^100\.1[0-1][0-9]\.|^100\.12[0-7]\.|^127|^169\.254|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168)") + [ $use_ipv6 -eq 1 ] && __IP=$(echo $1 | grep "^[0-9a-eA-E]") + else + __IP=$(echo $1 | grep -m 1 -o "$IPV4_REGEX") # valid IPv4 or + [ -z "$__IP" ] && __IP=$(echo $1 | grep -m 1 -o "$IPV6_REGEX") # IPv6 + fi + [ -z "$__IP" ] && { + write_log 3 "No or private or invalid IP '$1' given! Please check your configuration" + return 127 + } + + if [ -n "$update_script" ]; then + write_log 7 "parsing script '$update_script'" + . $update_script + else + local __URL __ERR + + # do replaces in URL + __URL=$(echo $update_url | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \ + -e "s#\[PARAMENC\]#$URL_PENC#g" -e "s#\[PARAMOPT\]#$param_opt#g" \ + -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g") + [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#') + + do_transfer "$__URL" || return 1 + + write_log 7 "DDNS Provider answered:${N}$(cat $DATFILE)" + + [ -z "$UPD_ANSWER" ] && return 0 # not set then ignore + + grep -i -E "$UPD_ANSWER" $DATFILE >/dev/null 2>&1 + return $? # "0" if found + fi +} + +get_local_ip () { + # $1 Name of Variable to store local IP (LOCAL_IP) + local __CNT=0 # error counter + local __RUNPROG __DATA __URL __ERR + + [ $# -ne 1 ] && write_log 12 "Error calling 'get_local_ip()' - wrong number of parameters" + write_log 7 "Detect local IP on '$ip_source'" + + while : ; do + if [ -n "$ip_network" -a "$ip_source" = "network" ]; then + # set correct program + network_flush_cache # force re-read data from ubus + [ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" \ + || __RUNPROG="network_get_ipaddr6" + eval "$__RUNPROG __DATA $ip_network" || \ + write_log 13 "Can not detect local IP using $__RUNPROG '$ip_network' - Error: '$?'" + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on network '$ip_network'" + elif [ -n "$ip_interface" -a "$ip_source" = "interface" ]; then + local __DATA4=""; local __DATA6="" + if [ -n "$(command -v ip)" ]; then # ip program installed + write_log 7 "#> ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE" + ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + # DATFILE (sample) + # 10: l2tp-inet: mtu 1456 qdisc fq_codel state UNKNOWN qlen 3\ link/ppp + # 10: l2tp-inet inet 95.30.176.51 peer 95.30.176.1/32 scope global l2tp-inet\ valid_lft forever preferred_lft forever + # 5: eth1: mtu 1500 qdisc fq_codel state UP qlen 1000\ link/ether 08:00:27:d0:10:32 brd ff:ff:ff:ff:ff:ff + # 5: eth1 inet 172.27.10.128/24 brd 172.27.10.255 scope global eth1\ valid_lft forever preferred_lft forever + # 5: eth1 inet 172.55.55.155/24 brd 172.27.10.255 scope global eth1\ valid_lft 12345sec preferred_lft 12345sec + # 5: eth1 inet6 2002:b0c7:f326::806b:c629:b8b9:433/128 scope global dynamic \ valid_lft 8026sec preferred_lft 8026sec + # 5: eth1 inet6 fd43:5368:6f6d:6500:806b:c629:b8b9:433/128 scope global dynamic \ valid_lft 8026sec preferred_lft 8026sec + # 5: eth1 inet6 fd43:5368:6f6d:6500:a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec + # 5: eth1 inet6 2002:b0c7:f326::a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec + + # remove remove remove replace replace + # link inet6 fxxx sec forever=>-1 / => ' ' to separate subnet from ip + sed "/link/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\// /g" $DATFILE | \ + awk '{ print $3" "$4" "$NF }' > $ERRFILE # temp reuse ERRFILE + # we only need inet? IP prefered time + + local __TIME4=0; local __TIME6=0 + local __TYP __ADR __TIME + while read __TYP __ADR __TIME; do + __TIME=${__TIME:-0} # supress shell errors on last (empty) line of DATFILE + # IPversion no "-1" record stored - now "-1" record or new time > oldtime + [ "$__TYP" = "inet6" -a $__TIME6 -ge 0 -a \( $__TIME -lt 0 -o $__TIME -gt $__TIME6 \) ] && { + __DATA6="$__ADR" + __TIME6="$__TIME" + } + [ "$__TYP" = "inet" -a $__TIME4 -ge 0 -a \( $__TIME -lt 0 -o $__TIME -gt $__TIME4 \) ] && { + __DATA4="$__ADR" + __TIME4="$__TIME" + } + done < $ERRFILE + else + write_log 3 "ip Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + else # use deprecated ifconfig + write_log 7 "#> ifconfig $ip_interface >$DATFILE 2>$ERRFILE" + ifconfig $ip_interface >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + __DATA4=$(awk ' + /inet addr:/ { # Filter IPv4 + # inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0 + $1=""; # remove inet + $3=""; # remove Bcast: ... + $4=""; # remove Mask: ... + FS=":"; # separator ":" + $0=$0; # reread to activate separator + $1=""; # remove addr + FS=" "; # set back separator to default " " + $0=$0; # reread to activate separator (remove whitespaces) + print $1; # print IPv4 addr + }' $DATFILE + ) + __DATA6=$(awk ' + /inet6/ && /: [0-9a-eA-E]/ { # Filter IPv6 exclude fxxx + # inet6 addr: 2001:db8::xxxx:xxxx/32 Scope:Global + FS="/"; # separator "/" + $0=$0; # reread to activate separator + $2=""; # remove everything behind "/" + FS=" "; # set back separator to default " " + $0=$0; # reread to activate separator + print $3; # print IPv6 addr + }' $DATFILE + ) + else + write_log 3 "ifconfig Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + fi + [ $use_ipv6 -eq 0 ] && __DATA="$__DATA4" || __DATA="$__DATA6" + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on interface '$ip_interface'" + elif [ -n "$ip_script" -a "$ip_source" = "script" ]; then + write_log 7 "#> $ip_script >$DATFILE 2>$ERRFILE" + eval $ip_script >$DATFILE 2>$ERRFILE + __ERR=$? + if [ $__ERR -eq 0 ]; then + __DATA=$(cat $DATFILE) + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected via script '$ip_script'" + else + write_log 3 "$ip_script Error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" # report error + fi + elif [ -n "$ip_url" -a "$ip_source" = "web" ]; then + do_transfer "$ip_url" + # use correct regular expression + [ $use_ipv6 -eq 0 ] \ + && __DATA=$(grep -m 1 -o "$IPV4_REGEX" $DATFILE) \ + || __DATA=$(grep -m 1 -o "$IPV6_REGEX" $DATFILE) + [ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on web at '$ip_url'" + else + write_log 12 "Error in 'get_local_ip()' - unhandled ip_source '$ip_source'" + fi + # valid data found return here + [ -n "$__DATA" ] && { + eval "$1=\"$__DATA\"" + return 0 + } + + [ -n "$LUCI_HELPER" ] && return 1 # no retry if called by LuCI helper script + + write_log 7 "Data detected:" + write_log 7 "$(cat $DATFILE)" + + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Get local IP via '$ip_source' failed - Verbose Mode: $VERBOSE - NO retry on error" + return 1 + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Get local IP via '$ip_source' failed after $retry_count retries" + write_log 4 "Get local IP via '$ip_source' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'get_local_ip()' - program coding error" +} + +get_registered_ip() { + # $1 Name of Variable to store public IP (REGISTERED_IP) + # $2 (optional) if set, do not retry on error + local __CNT=0 # error counter + local __ERR=255 + local __REGEX __PROG __RUNPROG __DATA __IP + # return codes + # 1 no IP detected + + [ $# -lt 1 -o $# -gt 2 ] && write_log 12 "Error calling 'get_registered_ip()' - wrong number of parameters" + [ $is_glue -eq 1 -a -z "$BIND_HOST" ] && write_log 14 "Lookup of glue records is only supported using BIND host" + write_log 7 "Detect registered/public IP" + + # set correct regular expression + [ $use_ipv6 -eq 0 ] && __REGEX="$IPV4_REGEX" || __REGEX="$IPV6_REGEX" + + if [ -n "$BIND_HOST" ]; then + __PROG="$BIND_HOST" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -t A" || __PROG="$__PROG -t AAAA" + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -T" # force TCP + [ $is_glue -eq 1 ] && __PROG="$__PROG -v" # use verbose output to get additional section + + __RUNPROG="$__PROG $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="BIND host" + elif [ -n "$KNOT_HOST" ]; then + __PROG="$KNOT_HOST" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -t A" || __PROG="$__PROG -t AAAA" + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -T" # force TCP + + __RUNPROG="$__PROG $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="Knot host" + elif [ -n "$DRILL" ]; then + __PROG="$DRILL -V0" # drill options name @server type + if [ $force_ipversion -eq 1 ]; then # force IP version + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG -4" || __PROG="$__PROG -6" + fi + [ $force_dnstcp -eq 1 ] && __PROG="$__PROG -t" || __PROG="$__PROG -u" # force TCP + __PROG="$__PROG $lookup_host" + [ -n "$dns_server" ] && __PROG="$__PROG @$dns_server" + [ $use_ipv6 -eq 0 ] && __PROG="$__PROG A" || __PROG="$__PROG AAAA" + + __RUNPROG="$__PROG >$DATFILE 2>$ERRFILE" + __PROG="drill" + elif [ -n "$HOSTIP" ]; then # hostip package installed + __PROG="$HOSTIP" + [ $force_dnstcp -ne 0 ] && \ + write_log 14 "hostip - no support for 'DNS over TCP'" + + # is IP given as dns_server ? + __IP=$(echo $dns_server | grep -m 1 -o "$IPV4_REGEX") + [ -z "$__IP" ] && __IP=$(echo $dns_server | grep -m 1 -o "$IPV6_REGEX") + + # we got NO ip for dns_server, so build command + [ -z "$__IP" -a -n "$dns_server" ] && { + __IP="\`$HOSTIP" + [ $use_ipv6 -eq 1 -a $force_ipversion -eq 1 ] && __IP="$__IP -6" + __IP="$__IP $dns_server | grep -m 1 -o" + [ $use_ipv6 -eq 1 -a $force_ipversion -eq 1 ] \ + && __IP="$__IP '$IPV6_REGEX'" \ + || __IP="$__IP '$IPV4_REGEX'" + __IP="$__IP \`" + } + + [ $use_ipv6 -eq 1 ] && __PROG="$__PROG -6" + [ -n "$dns_server" ] && __PROG="$__PROG -r $__IP" + __RUNPROG="$__PROG $lookup_host >$DATFILE 2>$ERRFILE" + __PROG="hostip" + elif [ -n "$NSLOOKUP" ]; then # last use BusyBox nslookup + NSLOOKUP_MUSL=$($(command -v nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl + [ $force_dnstcp -ne 0 ] && \ + write_log 14 "Busybox nslookup - no support for 'DNS over TCP'" + [ -n "$NSLOOKUP_MUSL" -a -n "$dns_server" ] && \ + write_log 14 "Busybox compiled with musl - nslookup don't support the use of DNS Server" + [ $force_ipversion -ne 0 ] && \ + write_log 5 "Busybox nslookup - no support to 'force IP Version' (ignored)" + + __RUNPROG="$NSLOOKUP $lookup_host $dns_server >$DATFILE 2>$ERRFILE" + __PROG="BusyBox nslookup" + else # there must be an error + write_log 12 "Error in 'get_registered_ip()' - no supported Name Server lookup software accessible" + fi + + while : ; do + write_log 7 "#> $__RUNPROG" + eval $__RUNPROG + __ERR=$? + if [ $__ERR -ne 0 ]; then + write_log 3 "$__PROG error: '$__ERR'" + write_log 7 "$(cat $ERRFILE)" + else + if [ -n "$BIND_HOST" -o -n "$KNOT_HOST" ]; then + if [ $is_glue -eq 1 ]; then + __DATA=$(cat $DATFILE | grep "^$lookup_host" | grep -om1 "$__REGEX" ) + else + __DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' ) + fi + elif [ -n "$DRILL" ]; then + __DATA=$(cat $DATFILE | awk '/^'"$lookup_host"'/ {print $5; exit}' ) + elif [ -n "$HOSTIP" ]; then + __DATA=$(cat $DATFILE | grep -om1 "$__REGEX") + elif [ -n "$NSLOOKUP" ]; then + __DATA=$(cat $DATFILE | sed -ne "/^Name:/,\$ { s/^Address[0-9 ]\{0,\}: \($__REGEX\).*$/\\1/p }" ) + fi + [ -n "$__DATA" ] && { + write_log 7 "Registered IP '$__DATA' detected" + [ -z "$IPFILE" ] || echo "$__DATA" > $IPFILE + eval "$1=\"$__DATA\"" # valid data found + return 0 # leave here + } + write_log 4 "NO valid IP found" + __ERR=127 + fi + [ -z "$IPFILE" ] || echo "" > $IPFILE + + [ -n "$LUCI_HELPER" ] && return $__ERR # no retry if called by LuCI helper script + [ -n "$2" ] && return $__ERR # $2 is given -> no retry + [ $VERBOSE -gt 1 ] && { + # VERBOSE > 1 then NO retry + write_log 4 "Get registered/public IP for '$lookup_host' failed - Verbose Mode: $VERBOSE - NO retry on error" + return $__ERR + } + + __CNT=$(( $__CNT + 1 )) # increment error counter + # if error count > retry_count leave here + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \ + write_log 14 "Get registered/public IP for '$lookup_host' failed after $retry_count retries" + + write_log 4 "Get registered/public IP for '$lookup_host' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP # enable trap-handler + PID_SLEEP=0 + done + # we should never come here there must be a programming error + write_log 12 "Error in 'get_registered_ip()' - program coding error" +} + +get_uptime() { + # $1 Variable to store result in + [ $# -ne 1 ] && write_log 12 "Error calling 'verify_host_port()' - wrong number of parameters" + local __UPTIME=$(cat /proc/uptime) + eval "$1=\"${__UPTIME%%.*}\"" +} + +trap_handler() { + # $1 trap signal + # $2 optional (exit status) + local __PIDS __PID + local __ERR=${2:-0} + local __OLD_IFS=$IFS + local __NEWLINE_IFS=' +' # __NEWLINE_IFS + + [ $PID_SLEEP -ne 0 ] && kill -$1 $PID_SLEEP 2>/dev/null # kill pending sleep if exist + + case $1 in + 0) if [ $__ERR -eq 0 ]; then + write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)${N}" + else + write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)${N}" + fi ;; + 1) write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)" + # reload config via starting the script again + /usr/lib/ddns/dynamic_dns_updater.sh -v "0" -S "$__SECTIONID" -- start || true + exit 0 ;; # and leave this one + 2) write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)${N}";; + 3) write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)${N}";; + 15) write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)${N}";; + *) write_log 13 "Unhandled signal '$1' in 'trap_handler()'";; + esac + + __PIDS=$(pgrep -P $$) # get my childs (pgrep prints with "newline") + IFS=$__NEWLINE_IFS + for __PID in $__PIDS; do + kill -$1 $__PID # terminate it + done + IFS=$__OLD_IFS + + # remove out and err file + [ -f $DATFILE ] && rm -f $DATFILE + [ -f $ERRFILE ] && rm -f $ERRFILE + + # exit with correct handling: + # remove trap handling settings and send kill to myself + trap - 0 1 2 3 15 + [ $1 -gt 0 ] && kill -$1 $$ +} + +split_FQDN() { + # $1 FQDN to split + # $2 name of variable to store TLD + # $3 name of variable to store (reg)Domain + # $4 name of variable to store Host/Subdomain + + [ $# -ne 4 ] && write_log 12 "Error calling 'split_FQDN()' - wrong number of parameters" + [ -z "$1" ] && write_log 12 "Error calling 'split_FQDN()' - missing FQDN to split" + [ -f $TLDFILE ] || write_log 12 "Error calling 'split_FQDN()' - missing file '$TLDFILE'" + + local _HOST _FDOM _CTLD _FTLD + local _SET="$@" # save given function parameters + + local _PAR=$(echo "$1" | tr [A-Z] [a-z] | tr "." " ") # to lower and replace DOT with SPACE + set -- $_PAR # set new as function parameters + _PAR="" # clear variable for later reuse + while [ -n "$1" ] ; do # as long we have parameters + _PAR="$1 $_PAR" # invert order of parameters + shift + done + set -- $_PAR # use new as function parameters + _PAR="" # clear variable + + while [ -n "$1" ] ; do # as long we have parameters + if [ -z "$_CTLD" ]; then # first loop + _CTLD="$1" # CURRENT TLD to look at + shift + else + _CTLD="$1.$_CTLD" # Next TLD to look at + shift + fi + # check if TLD exact match in tld_names.dat, save TLD + zcat $TLDFILE | grep -E "^$_CTLD$" >/dev/null 2>&1 && { + _FTLD="$_CTLD" # save found + _FDOM="$1" # save domain next step might be invalid + continue + } + # check if match any "*" in tld_names.dat, + zcat $TLDFILE | grep -E "^\*.$_CTLD$" >/dev/null 2>&1 && { + [ -z "$1" ] && break # no more data break + # check if next level TLD match excludes "!" in tld_names.dat + if zcat $TLDFILE | grep -E "^!$1.$_CTLD$" >/dev/null 2>&1 ; then + _FTLD="$_CTLD" # Yes + else + _FTLD="$1.$_CTLD" + shift + fi + _FDOM="$1"; shift + } + [ -n "$_FTLD" ] && break # we have something valid, break + done + + # the leftover parameters are the HOST/SUBDOMAIN + while [ -n "$1" ]; do + _HOST="$1 $_HOST" # remember we need to invert + shift + done + _HOST=$(echo $_HOST | tr " " ".") # insert DOT + + set -- $_SET # set back parameters from function call + [ -n "$_FTLD" ] && { + eval "$2=$_FTLD" # set TLD + eval "$3=$_FDOM" # set registrable domain + eval "$4=$_HOST" # set HOST/SUBDOMAIN + return 0 + } + eval "$2=''" # clear TLD + eval "$3=''" # clear registrable domain + eval "$4=''" # clear HOST/SUBDOMAIN + return 1 +} + +expand_ipv6() { + # Original written for bash by + #.Author: Florian Streibelt + # Date: 08.04.2012 + # License: Public Domain, but please be fair and + # attribute the original author(s) and provide + # a link to the original source for corrections: + #. https://github.com/mutax/IPv6-Address-checks + + # $1 IPv6 to expand + # $2 name of variable to store expanded IPv6 + [ $# -ne 2 ] && write_log 12 "Error calling 'expand_ipv6()' - wrong number of parameters" + + INPUT="$(echo "$1" | tr 'A-F' 'a-f')" + [ "$INPUT" = "::" ] && INPUT="::0" # special case :: + + O="" + + while [ "$O" != "$INPUT" ]; do + O="$INPUT" + + # fill all words with zeroes + INPUT=$( echo "$INPUT" | sed -e 's|:\([0-9a-f]\{3\}\):|:0\1:|g' \ + -e 's|:\([0-9a-f]\{3\}\)$|:0\1|g' \ + -e 's|^\([0-9a-f]\{3\}\):|0\1:|g' \ + -e 's|:\([0-9a-f]\{2\}\):|:00\1:|g' \ + -e 's|:\([0-9a-f]\{2\}\)$|:00\1|g' \ + -e 's|^\([0-9a-f]\{2\}\):|00\1:|g' \ + -e 's|:\([0-9a-f]\):|:000\1:|g' \ + -e 's|:\([0-9a-f]\)$|:000\1|g' \ + -e 's|^\([0-9a-f]\):|000\1:|g' ) + + done + + # now expand the :: + ZEROES="" + + echo "$INPUT" | grep -qs "::" + if [ "$?" -eq 0 ]; then + GRPS="$( echo "$INPUT" | sed 's|[0-9a-f]||g' | wc -m )" + GRPS=$(( GRPS-1 )) # remove carriage return + MISSING=$(( 8-GRPS )) + while [ $MISSING -gt 0 ]; do + ZEROES="$ZEROES:0000" + MISSING=$(( MISSING-1 )) + done + + # be careful where to place the : + INPUT=$( echo "$INPUT" | sed -e 's|\(.\)::\(.\)|\1'$ZEROES':\2|g' \ + -e 's|\(.\)::$|\1'$ZEROES':0000|g' \ + -e 's|^::\(.\)|'$ZEROES':0000:\1|g;s|^:||g' ) + fi + + # an expanded address has 39 chars + CR + if [ $(echo $INPUT | wc -m) != 40 ]; then + write_log 4 "Error in 'expand_ipv6()' - invalid IPv6 found: '$1' expanded: '$INPUT'" + eval "$2='invalid'" + return 1 + fi + + # echo the fully expanded version of the address + eval "$2=$INPUT" + return 0 +} diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh new file mode 100644 index 000000000..ab3eb78e7 --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh @@ -0,0 +1,172 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_lucihelper.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +#.2014-2018 Christian Schoenebeck +# This script is used by luci-app-ddns +# +# variables in small chars are read from /etc/config/ddns as parameter given here +# variables in big chars are defined inside these scripts as gloval vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here + +usage() { + cat << EOF + +Usage: + $MYPROG [options] -- command + +Commands: + get_local_ip using given INTERFACE or NETWORK or SCRIPT or URL + get_registered_ip for given FQDN + verify_dns given DNS-SERVER + verify_proxy given PROXY + start start given SECTION + reload force running ddns processes to reload changed configuration + restart restart all ddns processes + +Parameters: + -6 => use_ipv6=1 (default 0) + -d DNS-SERVER => dns_server=SERVER[:PORT] + -f => force_ipversion=1 (default 0) + -g => is_glue=1 (default 0) + -i INTERFACE => ip_interface=INTERFACE; ip_source="interface" + -l FQDN => lookup_host=FQDN + -n NETWORK => ip_network=NETWORK; ip_source="network" + -p PROXY => proxy=[USER:PASS@]PROXY:PORT + -s SCRIPT => ip_script=SCRIPT; ip_source="script" + -t => force_dnstcp=1 (default 0) + -u URL => ip_url=URL; ip_source="web" + -S SECTION SECTION to start + + -h => show this help and exit + -L => use_logfile=1 (default 0) + -v LEVEL => VERBOSE=LEVEL (default 0) + -V => show version and exit + +EOF +} + +usage_err() { + printf %s\\n "$MYPROG: $@" >&2 + usage >&2 + exit 255 +} + +# preset some variables, wrong or not set in ddns-functions.sh +SECTION_ID="lucihelper" +LOGFILE="$ddns_logdir/$SECTION_ID.log" +DATFILE="$ddns_rundir/$SECTION_ID.$$.dat" # save stdout data of WGet and other extern programs called +ERRFILE="$ddns_rundir/$SECTION_ID.$$.err" # save stderr output of WGet and other extern programs called +DDNSPRG="/usr/lib/ddns/dynamic_dns_updater.sh" +VERBOSE=0 # no console logging +# global variables normally set by reading DDNS UCI configuration +use_syslog=0 # no syslog +use_logfile=0 # no logfile + +use_ipv6=0 # Use IPv6 - default IPv4 +force_ipversion=0 # Force IP Version - default 0 - No +force_dnstcp=0 # Force TCP on DNS - default 0 - No +is_glue=0 # Is glue record - default 0 - No +use_https=0 # not needed but must be set + +while getopts ":6d:fghi:l:n:p:s:S:tu:Lv:V" OPT; do + case "$OPT" in + 6) use_ipv6=1;; + d) dns_server="$OPTARG";; + f) force_ipversion=1;; + g) is_glue=1;; + i) ip_interface="$OPTARG"; ip_source="interface";; + l) lookup_host="$OPTARG";; + n) ip_network="$OPTARG"; ip_source="network";; + p) proxy="$OPTARG";; + s) ip_script="$OPTARG"; ip_source="script";; + t) force_dnstcp=1;; + u) ip_url="$OPTARG"; ip_source="web";; + h) usage; exit 255;; + L) use_logfile=1;; + v) VERBOSE=$OPTARG;; + S) SECTION=$OPTARG;; + V) printf %s\\n "ddns-scripts $VERSION"; exit 255;; + :) usage_err "option -$OPTARG missing argument";; + \?) usage_err "invalid option -$OPTARG";; + *) usage_err "unhandled option -$OPT $OPTARG";; + esac +done +shift $((OPTIND - 1 )) # OPTIND is 1 based + +[ $# -eq 0 ] && usage_err "missing command" + +__RET=0 +case "$1" in + get_registered_ip) + [ -z "$lookup_host" ] && usage_err "command 'get_registered_ip': 'lookup_host' not set" + write_log 7 "-----> get_registered_ip IP" + [ -z "$SECTION" ] || IPFILE="$ddns_rundir/$SECTION.ip" + IP="" + get_registered_ip IP + __RET=$? + [ $__RET -ne 0 ] && IP="" + printf "%s" "$IP" + ;; + verify_dns) + [ -z "$dns_server" ] && usage_err "command 'verify_dns': 'dns_server' not set" + write_log 7 "-----> verify_dns '$dns_server'" + verify_dns "$dns_server" + __RET=$? + ;; + verify_proxy) + [ -z "$proxy" ] && usage_err "command 'verify_proxy': 'proxy' not set" + write_log 7 "-----> verify_proxy '$proxy'" + verify_proxy "$proxy" + __RET=$? + ;; + get_local_ip) + [ -z "$ip_source" ] && usage_err "command 'get_local_ip': 'ip_source' not set" + [ -n "$proxy" -a "$ip_source" = "web" ] && { + # proxy defined, used for ip_source=web + export HTTP_PROXY="http://$proxy" + export HTTPS_PROXY="http://$proxy" + export http_proxy="http://$proxy" + export https_proxy="http://$proxy" + } + # don't need IP only the return code + IP="" + if [ "$ip_source" = "web" -o "$ip_source" = "script" ]; then + # we wait only 3 seconds for an + # answer from "web" or "script" + write_log 7 "-----> timeout 3 -- get_local_ip IP" + timeout 3 -- get_local_ip IP + else + write_log 7 "-----> get_local_ip IP" + get_local_ip IP + fi + __RET=$? + ;; + start) + [ -z "$SECTION" ] && usage_err "command 'start': 'SECTION' not set" + if [ $VERBOSE -eq 0 ]; then # start in background + $DDNSPRG -v 0 -S $SECTION -- start & + else + $DDNSPRG -v $VERBOSE -S $SECTION -- start + fi + ;; + reload) + $DDNSPRG -- reload + ;; + restart) + $DDNSPRG -- stop + sleep 1 + $DDNSPRG -- start + ;; + *) + __RET=255 + ;; +esac + +# remove out and err file +[ -f $DATFILE ] && rm -f $DATFILE +[ -f $ERRFILE ] && rm -f $ERRFILE +return $__RET diff --git a/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh new file mode 100644 index 000000000..8176fa74c --- /dev/null +++ b/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh @@ -0,0 +1,436 @@ +#!/bin/sh +# /usr/lib/ddns/dynamic_dns_updater.sh +# +#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 +# Original written by Eric Paul Bishop, January 2008 +# (Loosely) based on the script on the one posted by exobyte in the forums here: +# http://forum.openwrt.org/viewtopic.php?id=14040 +# extended and partial rewritten +#.2014-2018 Christian Schoenebeck +# +# variables in small chars are read from /etc/config/ddns +# variables in big chars are defined inside these scripts as global vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +. $(dirname $0)/dynamic_dns_functions.sh # global vars are also defined here + +usage() { + cat << EOF + +Usage: + $MYPROG [options] -- command + +Commands: +start Start SECTION or NETWORK or all +stop Stop NETWORK or all + +Parameters: + -n NETWORK Start/Stop sections in background monitoring NETWORK, force VERBOSE=0 + -S SECTION SECTION to start + use either -N NETWORK or -S SECTION + + -h show this help and exit + -V show version and exit + -v LEVEL VERBOSE=LEVEL (default 1) + '0' NO output to console + '1' output to console + '2' output to console AND logfile + + run once WITHOUT retry on error + '3' output to console AND logfile + + run once WITHOUT retry on error + + NOT sending update to DDNS service + +EOF +} + +usage_err() { + printf %s\\n "$MYPROG: $@" >&2 + usage >&2 + exit 1 +} + +while getopts ":hv:n:S:V" OPT; do + case "$OPT" in + h) usage; exit 0;; + v) VERBOSE=$OPTARG;; + n) NETWORK=$OPTARG;; + S) SECTION_ID=$OPTARG;; + V) printf %s\\n "ddns-scripts $VERSION"; exit 0;; + :) usage_err "option -$OPTARG missing argument";; + \?) usage_err "invalid option -$OPTARG";; + *) usage_err "unhandled option -$OPT $OPTARG";; + esac +done +shift $((OPTIND - 1 )) # OPTIND is 1 based + +[ -n "$NETWORK" -a -n "$SECTION_ID" ] && usage_err "use either option '-N' or '-S' not both" +[ $# -eq 0 ] && usage_err "missing command" +[ $# -gt 1 ] && usage_err "to much commands" + +case "$1" in + start) + if [ -n "$NETWORK" ]; then + start_daemon_for_all_ddns_sections "$NETWORK" + exit 0 + fi + if [ -z "$SECTION_ID" ]; then + start_daemon_for_all_ddns_sections + exit 0 + fi + ;; + stop) + if [ -n "$INTERFACE" ]; then + stop_daemon_for_all_ddns_sections "$NETWORK" + exit 0 + else + stop_daemon_for_all_ddns_sections + exit 0 + fi + exit 1 + ;; + reload) + killall -1 dynamic_dns_updater.sh 2>/dev/null + exit $? + ;; + *) usage_err "unknown command - $1";; +esac + +# set file names +PIDFILE="$ddns_rundir/$SECTION_ID.pid" # Process ID file +UPDFILE="$ddns_rundir/$SECTION_ID.update" # last update successful send (system uptime) +DATFILE="$ddns_rundir/$SECTION_ID.dat" # save stdout data of WGet and other extern programs called +ERRFILE="$ddns_rundir/$SECTION_ID.err" # save stderr output of WGet and other extern programs called +IPFILE="$ddns_rundir/$SECTION_ID.ip" # +LOGFILE="$ddns_logdir/$SECTION_ID.log" # log file + +# VERBOSE > 1 delete logfile if exist to create an empty one +# only with this data of this run for easier diagnostic +# new one created by write_log function +[ $VERBOSE -gt 1 -a -f $LOGFILE ] && rm -f $LOGFILE + +# TRAP handler +trap "trap_handler 0 \$?" 0 # handle script exit with exit status +trap "trap_handler 1" 1 # SIGHUP Hangup / reload config +trap "trap_handler 2" 2 # SIGINT Terminal interrupt +trap "trap_handler 3" 3 # SIGQUIT Terminal quit +# trap "trap_handler 9" 9 # SIGKILL no chance to trap +trap "trap_handler 15" 15 # SIGTERM Termination + +################################################################################ +# Leave this comment here, to clearly document variable names that are expected/possible +# Use load_all_config_options to load config options, which is a much more flexible solution. +# +# config_load "ddns" +# config_get $SECTION_ID