diff --git a/package/lean/UnblockNeteaseMusic/Makefile b/package/lean/UnblockNeteaseMusic/Makefile index 847d11aff1..639e9a1968 100644 --- a/package/lean/UnblockNeteaseMusic/Makefile +++ b/package/lean/UnblockNeteaseMusic/Makefile @@ -11,14 +11,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=UnblockNeteaseMusic -PKG_VERSION:=0.22.1 +PKG_VERSION:=0.22.3 PKG_RELEASE:=1 PKG_LICENSE:=MIT PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/nondanee/UnblockNeteaseMusic.git -PKG_SOURCE_VERSION:=c727245b8de201b91ae859c6ae1412c77ef25cf0 +PKG_SOURCE_VERSION:=ee9d883b968b78842ab626f4f8051b40d4e7ff47 PKG_SOURCE_SUBDIR:=$(PKG_NAME) PKG_SOURCE:=$(PKG_SOURCE_SUBDIR)-$(PKG_VERSION).tar.gz @@ -31,9 +31,8 @@ define Package/$(PKG_NAME) SECTION:=net CATEGORY:=Network TITLE:=Revive unavailable songs for Netease Cloud Music - DEPENDS:=+node + DEPENDS:=+node +libopenssl URL:=https://github.com/nondanee/UnblockNeteaseMusic/releases - SUBMENU:=NeteaseMusic PKGARCH:=all endef diff --git a/package/lean/amule/Makefile b/package/lean/amule/Makefile index 2d66d714f3..50ccca8a30 100644 --- a/package/lean/amule/Makefile +++ b/package/lean/amule/Makefile @@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=aMule -PKG_VERSION:=20190827 -PKG_RELEASE:=1 -PKG_REV=2a1b092 +PKG_VERSION:=2.3.2 +PKG_RELEASE:=2 +PKG_REV=4b87b20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REV).tar.bz2 diff --git a/package/lean/amule/patches/001-amule-dlp.patch b/package/lean/amule/patches/001-amule-dlp.patch new file mode 100644 index 0000000000..5a37a27a64 --- /dev/null +++ b/package/lean/amule/patches/001-amule-dlp.patch @@ -0,0 +1,1548 @@ +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/package/lean/amule/patches/003_enable_upnp_cross_compile.patch b/package/lean/amule/patches/003_enable_upnp_cross_compile.patch new file mode 100644 index 0000000000..462e490c08 --- /dev/null +++ b/package/lean/amule/patches/003_enable_upnp_cross_compile.patch @@ -0,0 +1,23 @@ +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/package/lean/amule/patches/004_file_name_conversion.patch b/package/lean/amule/patches/004_file_name_conversion.patch new file mode 100644 index 0000000000..2c511d0ceb --- /dev/null +++ b/package/lean/amule/patches/004_file_name_conversion.patch @@ -0,0 +1,78 @@ +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/package/lean/amule/patches/005_best_keyword_kad_search.patch b/package/lean/amule/patches/005_best_keyword_kad_search.patch new file mode 100644 index 0000000000..c450a9f8e9 --- /dev/null +++ b/package/lean/amule/patches/005_best_keyword_kad_search.patch @@ -0,0 +1,174 @@ +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/package/lean/amule/patches/006_update-libupnp.patch b/package/lean/amule/patches/006_update-libupnp.patch new file mode 100644 index 0000000000..a66c33bad6 --- /dev/null +++ b/package/lean/amule/patches/006_update-libupnp.patch @@ -0,0 +1,365 @@ +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/package/lean/autocore/Makefile b/package/lean/autocore/Makefile index d29a938c3b..e63c874a9c 100644 --- a/package/lean/autocore/Makefile +++ b/package/lean/autocore/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=autocore PKG_VERSION:=1 -PKG_RELEASE:=19 +PKG_RELEASE:=26 include $(INCLUDE_DIR)/package.mk @@ -30,6 +30,9 @@ endef define Package/autocore/install $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/autocore $(1)/etc/init.d/autocore + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DIR) $(1)/sbin + $(CP) ./files/sbin/* $(1)/sbin endef $(eval $(call BuildPackage,autocore)) diff --git a/package/lean/autocore/files/autocore b/package/lean/autocore/files/autocore index f4fbc5ce69..b67cb69561 100755 --- a/package/lean/autocore/files/autocore +++ b/package/lean/autocore/files/autocore @@ -5,58 +5,48 @@ START=99 start() { - rfc=4096 - cc=$(grep -c processor /proc/cpuinfo) - rsfe=$(echo $cc*$rfc | bc) - sysctl -w net.core.rps_sock_flow_entries=$rsfe - for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus) - do - echo $cc > $fileRps - done - - for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt) - do - echo $rfc > $fileRfc - done + rfc=4096 + cc=$(grep -c processor /proc/cpuinfo) + rsfe=$(echo $cc*$rfc | bc) + sysctl -w net.core.rps_sock_flow_entries=$rsfe + for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus) + do + echo $cc > $fileRps + done - for fileRps in $(ls /sys/class/net/eth*/queues/tx-*/xps_cpus) - do - echo $cc > $fileRps - done - - a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq) - b=$(echo -n ' : ') - c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l) - d=$(echo -n ' Core ') - e=$(cat /proc/cpuinfo | grep 'processor' | wc -l) - f=$(echo -n ' Thread ') - g=${a}${b}${c}${d}${e}${f} - echo $g > /tmp/sysinfo/model - - ethtool -K eth0 rx-checksum on >/dev/null 2>&1 - ethtool -K eth0 tx-checksum-ip-generic on >/dev/null 2>&1 - ethtool -K eth0 tso on >/dev/null 2>&1 - ethtool -K eth0 ufo on >/dev/null 2>&1 - ethtool -K eth0 gso on >/dev/null 2>&1 - - ethtool -K eth1 rx-checksum on >/dev/null 2>&1 - ethtool -K eth1 tx-checksum-ip-generic on >/dev/null 2>&1 - ethtool -K eth1 tso on >/dev/null 2>&1 - ethtool -K eth1 ufo on >/dev/null 2>&1 - ethtool -K eth1 gso on >/dev/null 2>&1 - - ethtool -K eth2 rx-checksum on >/dev/null 2>&1 - ethtool -K eth2 tx-checksum-ip-generic on >/dev/null 2>&1 - ethtool -K eth2 tso on >/dev/null 2>&1 - ethtool -K eth2 ufo on >/dev/null 2>&1 - ethtool -K eth2 gso on >/dev/null 2>&1 - - ethtool -K eth3 rx-checksum on >/dev/null 2>&1 - ethtool -K eth3 tx-checksum-ip-generic on >/dev/null 2>&1 - ethtool -K eth3 tso on >/dev/null 2>&1 - ethtool -K eth3 ufo on >/dev/null 2>&1 - ethtool -K eth3 gso on >/dev/null 2>&1 + for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt) + do + echo $rfc > $fileRfc + done + + for fileRps in $(ls /sys/class/net/eth*/queues/tx-*/xps_cpus) + do + echo $cc > $fileRps + done + + a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq) + b=$(echo -n ' : ') + c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l) + d=$(echo -n ' Core ') + e=$(cat /proc/cpuinfo | grep 'processor' | wc -l) + f=$(echo -n ' Thread ') + g=${a}${b}${c}${d}${e}${f} + + mkdir -p /tmp/sysinfo + echo $g > /tmp/sysinfo/model + + a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.") + b=$(echo "$a" | wc -l) + for i in $(seq 1 $b) + do + c=$(echo "$a" | sed -n ${i}p) + ethtool -K $c rx-checksum on >/dev/null 2>&1 + ethtool -K $c tx-checksum-ip-generic on >/dev/null 2>&1 || ( + ethtool -K $c tx-checksum-ipv4 on >/dev/null 2>&1 + ethtool -K $c tx-checksum-ipv6 on >/dev/null 2>&1) + ethtool -K $c tx-scatter-gather on >/dev/null 2>&1 + ethtool -K $c gso on >/dev/null 2>&1 + ethtool -K $c tso on >/dev/null 2>&1 + ethtool -K $c ufo on >/dev/null 2>&1 + done } - - - diff --git a/package/lean/autocore/files/sbin/cpuinfo b/package/lean/autocore/files/sbin/cpuinfo new file mode 100755 index 0000000000..19ea5fb29d --- /dev/null +++ b/package/lean/autocore/files/sbin/cpuinfo @@ -0,0 +1,25 @@ +#!/bin/sh + +info() +{ + MHz=`grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'` + #获取CPU工作频率 + + sensors >/dev/null + + if [ $? -eq 0 ];then + a=`sensors | grep 'Core 0' | cut -c10-24` + #获取CPU核心1温度 + + else + a="" + fi +} + +out() +{ + info + echo "$MHz MHz $a " +} + +out diff --git a/package/lean/autocore/files/sbin/ethinfo b/package/lean/autocore/files/sbin/ethinfo new file mode 100755 index 0000000000..ee27a655c0 --- /dev/null +++ b/package/lean/autocore/files/sbin/ethinfo @@ -0,0 +1,39 @@ +#!/bin/sh + +a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.") +b=$(echo "$a" | wc -l) +rm -f /tmp/state/ethinfo + +echo -n "[" > /tmp/state/ethinfo + +for i in $(seq 1 $b) +do + h=$(echo '{"name":' ) + c=$(echo "$a" | sed -n ${i}p) + d=$(ethtool $c) + + e=$(echo "$d" | grep "Link detected" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g') + if [ $e = yes ]; then + l=1 + else + l=0 + fi + + f=$(echo "$d" | grep "Speed" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g' | tr -d "Unknown!") + [ -z "$f" ] && f=" - " + + g=$(echo "$d" | grep "Duplex" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g') + if [ "$g" == "Full" ]; then + x=1 + else + x=0 + fi + + echo -n "$h \"$c\", \"status\": $l, \"speed\": \"$f\", \"duplex\": $x}," >> /tmp/state/ethinfo +done + +sed -i 's/.$//' /tmp/state/ethinfo + +echo -n "]" >> /tmp/state/ethinfo + +cat /tmp/state/ethinfo diff --git a/package/lean/ddns-scripts_dnspod/Makefile b/package/lean/ddns-scripts_dnspod/Makefile new file mode 100644 index 0000000000..3f564bd482 --- /dev/null +++ b/package/lean/ddns-scripts_dnspod/Makefile @@ -0,0 +1,78 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ddns-scripts_dnspod +PKG_VERSION:=1.0.1 +PKG_RELEASE:=1 + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Small_5 + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=net + CATEGORY:=Network + SUBMENU:=IP Addresses and Names + TITLE:=DDNS extension for Dnspod.com/Dnspod.cn + PKGARCH:=all + DEPENDS:=+ddns-scripts +wget +ca-certificates +endef + +define Package/$(PKG_NAME)/description + Dynamic DNS Client scripts extension for Dnspod.com/Dnspod.cn +endef + +define Build/Configure +endef + +define Build/Compile + $(CP) ./*.sh $(PKG_BUILD_DIR) +endef + +define Package/$(PKG_NAME)/preinst + #!/bin/sh + # if NOT run buildroot then stop service + [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1 + exit 0 # suppress errors +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/lib/ddns + $(INSTALL_BIN) $(PKG_BUILD_DIR)/*.sh $(1)/usr/lib/ddns +endef + +define Package/$(PKG_NAME)/postinst + #!/bin/sh + # remove old services file entries + /bin/sed -i '/dnspod\.com/d' $${IPKG_INSTROOT}/etc/ddns/services >/dev/null 2>&1 + /bin/sed -i '/dnspod\.cn/d' $${IPKG_INSTROOT}/etc/ddns/services >/dev/null 2>&1 + /bin/sed -i '/dnspod\.com/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6 >/dev/null 2>&1 + /bin/sed -i '/dnspod\.cn/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6 >/dev/null 2>&1 + # and create new + printf "%s\\t\\t%s\\n" '"dnspod.com"' '"update_dnspod_com.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services + printf "%s\\t\\t%s\\n" '"dnspod.cn"' '"update_dnspod_cn.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services + printf "%s\\t\\t%s\\n" '"dnspod.com"' '"update_dnspod_com.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6 + printf "%s\\t\\t%s\\n" '"dnspod.cn"' '"update_dnspod_cn.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6 + # on real system restart service if enabled + [ -z "$${IPKG_INSTROOT}" ] && { + /etc/init.d/ddns enabled && \ + /etc/init.d/ddns start >/dev/null 2>&1 + } + exit 0 # suppress errors +endef + +define Package/$(PKG_NAME)/prerm + #!/bin/sh + # if NOT run buildroot then stop service + [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1 + # remove services file entries + /bin/sed -i '/dnspod\.com/d' $${IPKG_INSTROOT}/etc/ddns/services >/dev/null 2>&1 + /bin/sed -i '/dnspod\.cn/d' $${IPKG_INSTROOT}/etc/ddns/services >/dev/null 2>&1 + /bin/sed -i '/dnspod\.com/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6 >/dev/null 2>&1 + /bin/sed -i '/dnspod\.cn/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6 >/dev/null 2>&1 + exit 0 # suppress errors +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/ddns-scripts_dnspod/update_dnspod_cn.sh b/package/lean/ddns-scripts_dnspod/update_dnspod_cn.sh new file mode 100644 index 0000000000..ec2e0a9294 --- /dev/null +++ b/package/lean/ddns-scripts_dnspod/update_dnspod_cn.sh @@ -0,0 +1,151 @@ +#!/bin/sh + +#检查传入参数 +[ -z "$username" ] && write_log 14 "Configuration error! [User name] cannot be empty" +[ -z "$password" ] && write_log 14 "Configuration error! [Password] cannot be empty" + +#检查外部调用工具 +[ -n "$WGET_SSL" ] || write_log 13 "GNU Wget support is required to use Alibaba Cloud API. Please install first" + +# 变量声明 +local __URLBASE __HOST __DOMAIN __TYPE __CMDBASE __POST __POST1 __RECIP __RECID __value __TTL +__URLBASE="https://dnsapi.cn/" + +# 从 $domain 分离主机和域名 +[ "${domain:0:2}" == "@." ] && domain="${domain/./}" # 主域名处理 +[ "$domain" == "${domain/@/}" ] && domain="${domain/./@}" # 未找到分隔符,兼容常用域名格式 +__HOST="${domain%%@*}" +__DOMAIN="${domain#*@}" +[ -z "$__HOST" -o "$__HOST" == "$__DOMAIN" ] && __HOST="@" + +# 设置记录类型 +[ $use_ipv6 -eq 0 ] && __TYPE="A" || __TYPE="AAAA" + +# 构造基本通信命令 +build_command() { + __CMDBASE="$WGET_SSL -nv -t 1 -O $DATFILE -o $ERRFILE" + # 绑定用于通信的主机/IP + if [ -n "$bind_network" ]; then + local bind_ip run_prog + [ $use_ipv6 -eq 0 ] && run_prog="network_get_ipaddr" || run_prog="network_get_ipaddr6" + eval "$run_prog bind_ip $bind_network" || \ + write_log 13 "Unable to get local IP address with '$run_prog $ bind_network' - error code: '$?'" + write_log 7 "Forced use of IP '$bind_ip' communication" + __CMDBASE="$__CMDBASE --bind-address=$bind_ip" + fi + # 强制设定IP版本 + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __CMDBASE="$__CMDBASE -4" || __CMDBASE="$__CMDBASE -6" + fi + # 设置CA证书参数 + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then + __CMDBASE="$__CMDBASE --no-check-certificate" + elif [ -f "$cacert" ]; then + __CMDBASE="$__CMDBASE --ca-certificate=${cacert}" + elif [ -d "$cacert" ]; then + __CMDBASE="$__CMDBASE --ca-directory=${cacert}" + elif [ -n "$cacert" ]; then + write_log 14 "A valid certificate for HTTPS communication was not found in '$cacert'" + fi + fi + # 如果没有设置,禁用代理 (这可能是 .wgetrc 或环境设置错误) + [ -z "$proxy" ] && __CMDBASE="$__CMDBASE --no-proxy" + __CMDBASE="$__CMDBASE --post-data" +} + +# 用于Dnspod API的通信函数 +dnspod_transfer() { + local __A=$1 + local __CNT=0 + local __ERR=0 + local __B PID_SLEEP + case "$__A" in + 0) + __B="$__CMDBASE '$__POST' ${__URLBASE}Record.List" + ;; + 1) + __B="$__CMDBASE '$__POST1' ${__URLBASE}Record.Create" + ;; + 2) + __B="$__CMDBASE '$__POST1&record_id=$__RECID&ttl=$__TTL' ${__URLBASE}Record.Modify" + ;; + esac + + while : ; do + write_log 7 "#> $__B" + eval $__B + __ERR=`jsonfilter -i $DATFILE -e "@.status.code"` + + [ $__ERR -eq 1 ] && return 0 + [ $__ERR -ne 0 ] && write_log 3 "Error message:[$(jsonfilter -i $DATFILE -e "@.status.message")]" + + if [ $VERBOSE -gt 1 ]; then + write_log 4 "Transfer failed - detailed mode: $VERBOSE - Do not try again after an error" + return 1 + fi + + __CNT=$(( $__CNT + 1 )) + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && write_log 14 "Transfer failed after $retry_count retries" + + write_log 4 "Transfer failed - $__CNT Try again in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP + PID_SLEEP=0 + done +} + +#添加解析记录 +add_domain() { +dnspod_transfer 1 +write_log 7 "Add new parsing record [${__HOST}.${__DOMAIN}],[type:$__TYPE],[ip:$__IP] successfully!" +return 0 +} + +#修改解析记录 +update_domain() { +dnspod_transfer 2 +write_log 7 "Modify new parsing record [${__HOST}.${__DOMAIN}],[type:$__TYPE],[ip:$__IP],[TTL:$__TTL] successfully!" +return 0 +} + +#获取域名解析记录 +describe_domain() { + ret=0 + __POST="login_token=$username,$password&format=json&domain=$__DOMAIN" + __POST1="$__POST&sub_domain=$__HOST&value=$__IP&record_type=$__TYPE&record_line_id=0" + dnspod_transfer 0 + __value=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].name"` + if [ "$__value" == "" ]; then + write_log 7 "Parsing record:[${__HOST}.${__DOMAIN}] does not exist" + ret=1 + else + __value=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].type"` + if [ "$__value" != "$__TYPE" ]; then + write_log 7 "Current parsing [type:$__TYPE], get mismatched [type:$__value]" + ret=2 + else + __RECID=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].id"` + write_log 7 "Get parsing recordID:[$__RECID]" + __RECIP=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].value"` + if [ "$__RECIP" != "$__IP" ]; then + write_log 7 "Address needs to be modified, local address:[$__IP]" + ret=2 + fi + fi + __TTL=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].ttl"` + fi +} + +build_command +describe_domain +if [ $ret == 1 ];then + sleep 3 && add_domain +elif [ $ret == 2 ];then + sleep 3 && update_domain +else + write_log 7 "Local IP:[$__IP] parsing records IP:[$__RECIP] address does not need to be modified" +fi + +return 0 diff --git a/package/lean/ddns-scripts_dnspod/update_dnspod_com.sh b/package/lean/ddns-scripts_dnspod/update_dnspod_com.sh new file mode 100644 index 0000000000..576ce4fbc0 --- /dev/null +++ b/package/lean/ddns-scripts_dnspod/update_dnspod_com.sh @@ -0,0 +1,161 @@ +#!/bin/sh + +#检查传入参数 +[ -z "$username" ] && write_log 14 "Configuration error! [User name] cannot be empty" +[ -z "$password" ] && write_log 14 "Configuration error! [Password] cannot be empty" + +#检查外部调用工具 +[ -n "$WGET_SSL" ] || write_log 13 "GNU Wget support is required to use Alibaba Cloud API. Please install first" + +# 变量声明 +local __URLBASE __HOST __DOMAIN __TYPE __CMDBASE __TOKEN __POST __POST1 __RECIP __RECID __value __TTL +__URLBASE="https://api.dnspod.com/" + +# 从 $domain 分离主机和域名 +[ "${domain:0:2}" == "@." ] && domain="${domain/./}" # 主域名处理 +[ "$domain" == "${domain/@/}" ] && domain="${domain/./@}" # 未找到分隔符,兼容常用域名格式 +__HOST="${domain%%@*}" +__DOMAIN="${domain#*@}" +[ -z "$__HOST" -o "$__HOST" == "$__DOMAIN" ] && __HOST="@" + +# 设置记录类型 +[ $use_ipv6 -eq 0 ] && __TYPE="A" || __TYPE="AAAA" + +# 构造基本通信命令 +build_command() { + __CMDBASE="$WGET_SSL -nv -t 1 -O $DATFILE -o $ERRFILE" + # 绑定用于通信的主机/IP + if [ -n "$bind_network" ]; then + local bind_ip run_prog + [ $use_ipv6 -eq 0 ] && run_prog="network_get_ipaddr" || run_prog="network_get_ipaddr6" + eval "$run_prog bind_ip $bind_network" || \ + write_log 13 "Unable to get local IP address with '$run_prog $ bind_network' - error code: '$?'" + write_log 7 "Forced use of IP '$bind_ip' communication" + __CMDBASE="$__CMDBASE --bind-address=$bind_ip" + fi + # 强制设定IP版本 + if [ $force_ipversion -eq 1 ]; then + [ $use_ipv6 -eq 0 ] && __CMDBASE="$__CMDBASE -4" || __CMDBASE="$__CMDBASE -6" + fi + # 设置CA证书参数 + if [ $use_https -eq 1 ]; then + if [ "$cacert" = "IGNORE" ]; then + __CMDBASE="$__CMDBASE --no-check-certificate" + elif [ -f "$cacert" ]; then + __CMDBASE="$__CMDBASE --ca-certificate=${cacert}" + elif [ -d "$cacert" ]; then + __CMDBASE="$__CMDBASE --ca-directory=${cacert}" + elif [ -n "$cacert" ]; then + write_log 14 "A valid certificate for HTTPS communication was not found in '$cacert'" + fi + fi + # 如果没有设置,禁用代理 (这可能是 .wgetrc 或环境设置错误) + [ -z "$proxy" ] && __CMDBASE="$__CMDBASE --no-proxy" + __CMDBASE="$__CMDBASE --post-data" +} + +# 用于Dnspod API的通信函数 +dnspod_transfer() { + local __A=$1 + local __CNT=0 + local __ERR=0 + local __B __C PID_SLEEP + case "$__A" in + 0) + __B="$__CMDBASE 'login_email=$username&login_password=$password&format=json' ${__URLBASE}Auth" + __C=$__B + ;; + 1) + __B="$__CMDBASE '$__POST' ${__URLBASE}Record.List" + __C=1 + ;; + 2) + __B="$__CMDBASE '$__POST1' ${__URLBASE}Record.Create" + __C=1 + ;; + 3) + __B="$__CMDBASE '$__POST1&record_id=$__RECID&ttl=$__TTL' ${__URLBASE}Record.Modify" + __C=1 + ;; + esac + + while : ; do + [ $__C -eq 1 ] && __C=$(echo -e "$__B" | sed -e "s/${__TOKEN#*,}/***PW***/g") + write_log 7 "#> $__C" + eval $__B + __ERR=`jsonfilter -i $DATFILE -e "@.status.code"` + + [ $__ERR -eq 1 ] && return 0 + [ $__ERR -ne 0 ] && write_log 3 "Error message:[$(jsonfilter -i $DATFILE -e "@.status.message")]" + + if [ $VERBOSE -gt 1 ]; then + write_log 4 "Transfer failed - detailed mode: $VERBOSE - Do not try again after an error" + return 1 + fi + + __CNT=$(( $__CNT + 1 )) + [ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && write_log 14 "Transfer failed after $retry_count retries" + + write_log 4 "Transfer failed - $__CNT Try again in $RETRY_SECONDS seconds" + sleep $RETRY_SECONDS & + PID_SLEEP=$! + wait $PID_SLEEP + PID_SLEEP=0 + done +} + +#添加解析记录 +add_domain() { +dnspod_transfer 2 +write_log 7 "Add new parsing record [${__HOST}.${__DOMAIN}],[type:$__TYPE],[ip:$__IP] successfully!" +return 0 +} + +#修改解析记录 +update_domain() { +dnspod_transfer 3 +write_log 7 "Modify new parsing record [${__HOST}.${__DOMAIN}],[type:$__TYPE],[ip:$__IP],[TTL:$__TTL] successfully!" +return 0 +} + +#获取域名解析记录 +describe_domain() { + ret=0 + dnspod_transfer 0 + __TOKEN=`jsonfilter -i $DATFILE -e "@.user_token"` + __POST="user_token=$__TOKEN&format=json&domain=$__DOMAIN" + __POST1="$__POST&sub_domain=$__HOST&value=$__IP&record_type=$__TYPE&record_line=default" + dnspod_transfer 1 + __value=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].name"` + if [ "$__value" == "" ]; then + write_log 7 "Parsing record:[${__HOST}.${__DOMAIN}] does not exist" + ret=1 + else + __value=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].type"` + if [ "$__value" != "$__TYPE" ]; then + write_log 7 "Current parsing [type:$__TYPE], get mismatched [type:$__value]" + ret=2 + else + __RECID=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].id"` + write_log 7 "Get parsing recordID:[$__RECID]" + __RECIP=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].value"` + if [ "$__RECIP" != "$__IP" ]; then + write_log 7 "Address needs to be modified, local address:[$__IP]" + ret=2 + fi + fi + __TTL=`jsonfilter -i $DATFILE -e "@.records[@.name='$__HOST'].ttl"` + fi +} + +build_command +describe_domain +if [ $ret == 1 ];then + sleep 3 && add_domain +elif [ $ret == 2 ];then + sleep 3 && update_domain +else + write_log 7 "Local IP:[$__IP] parsing records IP:[$__RECIP] address does not need to be modified" +fi + +return 0 diff --git a/package/lean/default-settings/Makefile b/package/lean/default-settings/Makefile index d9281955d8..1f32f3f213 100644 --- a/package/lean/default-settings/Makefile +++ b/package/lean/default-settings/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=default-settings PKG_VERSION:=1.1 -PKG_RELEASE:=47 +PKG_RELEASE:=51 PKG_LICENSE:=GPLv3 PKG_LICENSE_FILES:=LICENSE diff --git a/package/lean/default-settings/files/openwrt_banner b/package/lean/default-settings/files/openwrt_banner index adfb18e14a..f45bafcb26 100644 --- a/package/lean/default-settings/files/openwrt_banner +++ b/package/lean/default-settings/files/openwrt_banner @@ -8,5 +8,5 @@ │ # │ │ " │ │─────────────────────────────────────────────────│ -│ OpenWrt SNAPSHOT, Mod 19.11 By CTCGFW │ +│ OpenWrt SNAPSHOT, Mod 20.02 By CTCGFW │ └─────────────────────────────────────────────────┘ diff --git a/package/lean/default-settings/files/zzz-default-settings b/package/lean/default-settings/files/zzz-default-settings index a21fda748f..820a2184bf 100755 --- a/package/lean/default-settings/files/zzz-default-settings +++ b/package/lean/default-settings/files/zzz-default-settings @@ -27,25 +27,13 @@ sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/usb_printer.lua sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/xunlei.lua sed -i 's/services/nas/g' /usr/lib/lua/luci/view/minidlna_status.htm -uci set minidlna.config.enabled=0 -uci commit minidlna -/etc/init.d/minidlna enable -/etc/init.d/minidlna stop - ln -sf /sbin/ip /usr/bin/ip -#sed -i 's/downloads.openwrt.org/openwrt.proxy.ustclug.org/g' /etc/opkg/distfeeds.conf -sed -i 's/http/https/g' /etc/opkg/distfeeds.conf -sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow -sed -i 's|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g' /etc/passwd - +sed -i 's#http://downloads.openwrt.org#https://mirrors.ustc.edu.cn/lede#g' /etc/opkg/distfeeds.conf sed -i "s/# //g" /etc/opkg/distfeeds.conf -uci set dhcp.lan.ra='server' -uci set dhcp.lan.dhcpv6='server' -uci set dhcp.lan.ra_management='1' -uci set dhcp.lan.ra_default='1' -uci commit dhcp +sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow +sed -i 's|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g' /etc/passwd sed -i '/REDIRECT --to-ports 53/d' /etc/firewall.user echo "iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user @@ -58,13 +46,11 @@ wifi up sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release echo "DISTRIB_REVISION=''" >> /etc/openwrt_release sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release -echo "DISTRIB_DESCRIPTION='OpenWrt SNAPSHOT Mod19.11 By CTCGFW'" >> /etc/openwrt_release +echo "DISTRIB_DESCRIPTION='OpenWrt SNAPSHOT Mod20.02 By CTCGFW'" >> /etc/openwrt_release sed -i '/log-facility/d' /etc/dnsmasq.conf echo "log-facility=/dev/null" >> /etc/dnsmasq.conf -sed -i 's/cbi.submit\"] = true/cbi.submit\"] = \"1\"/g' /usr/lib/lua/luci/dispatcher.lua - rm -rf /tmp/luci-modulecache/ rm -f /tmp/luci-indexcache diff --git a/package/lean/ipv6-helper/Makefile b/package/lean/ipv6-helper/Makefile index 8be88ca5b7..ae4242f995 100644 --- a/package/lean/ipv6-helper/Makefile +++ b/package/lean/ipv6-helper/Makefile @@ -23,7 +23,7 @@ define Package/ipv6helper SECTION:=ipv6 TITLE:=IPv6 Helper and Dynamic Update he.net of ip PKGARCH:=all - DEPENDS:=+luci-proto-ipv6 +wget +ip6tables +kmod-ipt-nat6 +odhcpd-ipv6only +odhcp6c +6in4 + DEPENDS:=+luci-proto-ipv6 +wget +ip6tables +ip6tables-mod-nat +kmod-ipt-nat6 +kmod-nf-nat6 +odhcpd-ipv6only +odhcp6c +6in4 endef define Package/ipv6helper/description diff --git a/package/lean/libcryptopp/Makefile b/package/lean/libcryptopp/Makefile index 60ea74ddcd..f37b6088be 100644 --- a/package/lean/libcryptopp/Makefile +++ b/package/lean/libcryptopp/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libcryptopp -PKG_VERSION:=8.2.0 +PKG_VERSION:=5.6.4 PKG_RELEASE:=1 PKG_SOURCE:=cryptopp$(subst .,,$(PKG_VERSION)).zip PKG_SOURCE_URL:=http://www.cryptopp.com/ -PKG_MD5SUM:=8a8bcb436af83e16d2227bd4ac642243 +PKG_MD5SUM:=4ee7e5cdd4a45a14756c169eaf2a77fc PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION) @@ -36,15 +36,20 @@ define Package/package/libcryptopp abstract base classes. endef +#CONFIGURE_ARGS += \ +# --enable-static \ +# --enable-shared + +#TARGET_LDFLAGS += \ +# -lpthread CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS="$(FPIC)" CMAKE_OPTIONS += -DBUILD_STATIC=ON CMAKE_OPTIONS += -DBUILD_SHARED=ON UNPACK_CMD=cd $(PKG_BUILD_DIR) && unzip "$(DL_DIR)/$(PKG_SOURCE)" define Build/Prepare - [ ! -f $(BUILD_DIR)/$(PKG_NAME)/CRYPTOPP_8_2_0.zip ] && wget https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_2_0.zip -O $(BUILD_DIR)/$(PKG_NAME)/CRYPTOPP_8_2_0.zip && unzip -o $(BUILD_DIR)/$(PKG_NAME)/CRYPTOPP_8_2_0.zip -d $(BUILD_DIR)/$(PKG_NAME) && cd $(BUILD_DIR)/$(PKG_NAME)/cryptopp-cmake-CRYPTOPP_8_2_0 && cp CMakeLists.txt cryptopp-config.cmake $(PKG_BUILD_DIR) $(Build/Prepare/Default) - cd $(PKG_BUILD_DIR) && rm -f GNUmakefile GNUmakefile-cross + cd $(PKG_BUILD_DIR) && rm -f GNUmakefile GNUmakefile-cross endef define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include/cryptopp diff --git a/package/lean/luci-app-adbyby-plus/Makefile b/package/lean/luci-app-adbyby-plus/Makefile index a1fe276522..622b7e222f 100644 --- a/package/lean/luci-app-adbyby-plus/Makefile +++ b/package/lean/luci-app-adbyby-plus/Makefile @@ -10,7 +10,7 @@ LUCI_DEPENDS:=+adbyby +wget +ipset +coreutils +coreutils-nohup +dnsmasq-full LUCI_PKGARCH:=all PKG_NAME:=luci-app-adbyby-plus PKG_VERSION:=2.0 -PKG_RELEASE:=41 +PKG_RELEASE:=42 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-frpc/luasrc/model/cbi/frp/config.lua b/package/lean/luci-app-frpc/luasrc/model/cbi/frp/config.lua index e9499c8c97..48bfe72509 100644 --- a/package/lean/luci-app-frpc/luasrc/model/cbi/frp/config.lua +++ b/package/lean/luci-app-frpc/luasrc/model/cbi/frp/config.lua @@ -38,7 +38,7 @@ e:depends("domain_type","both_dtype") e = t:taboption("base",ListValue, "stcp_role", translate("STCP Role")) e.default = "server" e:value("server",translate("STCP Server")) -e:value("vistor",translate("STCP Vistor")) +e:value("visitor",translate("STCP Vistor")) e:depends("type","stcp") e = t:taboption("base",Value, "remote_port", translate("Remote Port")) e.datatype = "port" @@ -67,7 +67,7 @@ e.default = "abcdefg" e:depends("type","stcp") e = t:taboption("base",Value, "stcp_servername", translate("STCP Server Name"), translate("STCP Server Name is Service Remark Name of STCP Server")) e.default = "secret_tcp" -e:depends("stcp_role","vistor") +e:depends("stcp_role","visitor") e = t:taboption("other",Flag, "enable_locations", translate("Enable URL routing"), translate("Frp support forward http requests to different backward web services by url routing.")) e:depends("type","http") e = t:taboption("other",Value, "locations ", translate("URL routing"), translate("Http requests with url prefix /news will be forwarded to this service.")) diff --git a/package/lean/luci-app-frpc/root/etc/init.d/frp b/package/lean/luci-app-frpc/root/etc/init.d/frp index 66f7881dcc..ced13f7bb3 100755 --- a/package/lean/luci-app-frpc/root/etc/init.d/frp +++ b/package/lean/luci-app-frpc/root/etc/init.d/frp @@ -80,7 +80,7 @@ conf_proxy_add() { [ -n "$plugin_unix_path" ] && echo "plugin_unix_path=$plugin_unix_path" >>$tmpconf [ -n "$stcp_role" ] && { - if [ "$stcp_role" == "vistor" ]; then + if [ "$stcp_role" == "visitor" ]; then echo "role=$stcp_role" >>$tmpconf [ -n "$local_ip" ] && echo "bind_addr=$local_ip" >>$tmpconf [ -n "$local_port" ] && echo "bind_port=$local_port" >>$tmpconf diff --git a/package/lean/luci-app-guest-wifi/luasrc/controller/guest-wifi.lua b/package/lean/luci-app-guest-wifi/luasrc/controller/guest-wifi.lua index 41534b0dff..887512f6a6 100644 --- a/package/lean/luci-app-guest-wifi/luasrc/controller/guest-wifi.lua +++ b/package/lean/luci-app-guest-wifi/luasrc/controller/guest-wifi.lua @@ -1,6 +1,8 @@ module("luci.controller.guest-wifi", package.seeall) function index() + require("luci.i18n") + luci.i18n.loadc("guest-wifi") if not nixio.fs.access("/etc/config/guest-wifi") then return end diff --git a/package/lean/luci-app-nps/Makefile b/package/lean/luci-app-nps/Makefile index 11e25ed058..b677bcdeed 100644 --- a/package/lean/luci-app-nps/Makefile +++ b/package/lean/luci-app-nps/Makefile @@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for Nps LUCI_DEPENDS:=+wget +npc LUCI_PKGARCH:=all PKG_VERSION:=1.1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-nps/root/etc/config/nps b/package/lean/luci-app-nps/root/etc/config/nps index 5b166cd1d1..b5b8be8782 100755 --- a/package/lean/luci-app-nps/root/etc/config/nps +++ b/package/lean/luci-app-nps/root/etc/config/nps @@ -1,6 +1,6 @@ -config npc 'config' - option enabled '1' +config nps + option enabled '0' option server_addr '1.1.1.1' option server_port '8024' option protocol 'tcp' diff --git a/package/lean/luci-app-nps/root/etc/init.d/nps b/package/lean/luci-app-nps/root/etc/init.d/nps index e9ab09f96d..525d06935f 100755 --- a/package/lean/luci-app-nps/root/etc/init.d/nps +++ b/package/lean/luci-app-nps/root/etc/init.d/nps @@ -24,6 +24,7 @@ nps_header() { echo "server_addr=${server_addr}:${server_port}" >>$tmpconf echo "conn_type=${protocol}" >>$tmpconf echo "vkey=${vkey}" >>$tmpconf + echo "auto_reconnection=true" >>$tmpconf nps_write_bool compress $1 nps_write_bool crypt $1 @@ -51,10 +52,9 @@ start_service() { if [ "$Enabled" = "1" ];then logger -t FRPC 'Starting Nps service' - #service_start /usr/bin/npc -config=$tmpconf -log_level=$Log_level -log_path=$LOGFILE procd_open_instance - procd_set_param command /usr/bin/npc -config=$tmpconf -log_level=$Log_level - procd_set_param file $tmpconf + procd_set_param command /usr/bin/npc -config=$tmpconf -log_level=$Log_level -log_path=$LOGFILE + #procd_set_param file $tmpconf procd_set_param respawn procd_set_param stdout 1 procd_set_param stderr 1 @@ -62,3 +62,9 @@ start_service() { fi } +reload_service() +{ + stop + start +} + diff --git a/package/lean/luci-app-softethervpn/Makefile b/package/lean/luci-app-softethervpn/Makefile index 12f9c4a659..236ed1e7ba 100644 --- a/package/lean/luci-app-softethervpn/Makefile +++ b/package/lean/luci-app-softethervpn/Makefile @@ -6,10 +6,10 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI support for SoftEtherVPN -LUCI_DEPENDS:=+zlib +libpthread +librt +libreadline +libncurses +libiconv-full +kmod-tun +libopenssl +softethervpn-bridge +softethervpn-client +softethervpn-server +LUCI_DEPENDS:=+zlib +libpthread +librt +libreadline +libncurses +libiconv-full +kmod-tun +libopenssl +softethervpn5-bridge +softethervpn5-client +softethervpn5-server LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua b/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua index 1c0054c291..5529c82fb0 100644 --- a/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua +++ b/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua @@ -10,5 +10,5 @@ o.template="softethervpn/status" o.value=translate("Collecting data...") o=s:option(Flag,"enable",translate("Enabled")) o.rmempty=false -o=s:option(DummyValue,"moreinfo",translate("控制台下载:
Windows-x86_x64-intel.exe

macos-x86-32bit.pkg
")) +o=s:option(DummyValue,"moreinfo",translate("控制台下载:
Windows-x86_x64-intel.exe

macos-x86-32bit.pkg
")) return m diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 2f66356c3a..e924ed427d 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -1,15 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus +PKG_RELEASE:=136 PKG_VERSION:=1 -PKG_RELEASE:=131 - -PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks include $(INCLUDE_DIR)/package.mk @@ -17,42 +10,42 @@ define Package/$(PKG_NAME)/config config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks bool "Include Shadowsocks New Version" default y if x86_64 - + config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray bool "Include V2ray" default y if x86_64 - + config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan bool "Include Trojan" default y if x86_64 - + config PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun bool "Include Kcptun" default n - + config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server bool "Include ShadowsocksR Server" default y if x86_64 - + config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks bool "Include ShadowsocksR Socks and Tunnel" default y if x86_64 endef define Package/luci-app-ssr-plus - SECTION:=luci + SECTION:=luci CATEGORY:=LuCI SUBMENU:=3. Applications - TITLE:=SS/SSR/V2Ray LuCI interface + TITLE:=SS/SSR/V2Ray/Trojan LuCI interface PKGARCH:=all - DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \ - +PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \ - +PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:openwrt-kcptun-client \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local + DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget +lua \ + +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \ + +PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \ + +PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \ + +PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \ + +PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \ + +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \ + +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local endef define Build/Prepare @@ -67,11 +60,37 @@ define Package/luci-app-ssr-plus/conffiles endef define Package/luci-app-ssr-plus/install - $(INSTALL_DIR) $(1)/usr/lib/lua/luci - cp -pR ./luasrc/* $(1)/usr/lib/lua/luci - $(INSTALL_DIR) $(1)/ - cp -pR ./root/* $(1)/ + #lua + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/shadowsocksr $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n + #etc + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/dnsmasq.oversea + $(INSTALL_DIR) $(1)/etc/dnsmasq.ssr + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/etc/uci-defaults + #usr + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/usr/share/shadowsocksr + #root/etc + $(INSTALL_DATA) ./root/etc/china_ssr.txt $(1)/etc/china_ssr.txt + $(INSTALL_CONF) ./root/etc/config/shadowsocksr $(1)/etc/config/shadowsocksr + $(INSTALL_DATA) ./root/etc/config/*.list $(1)/etc/config/ + $(INSTALL_DATA) ./root/etc/dnsmasq.oversea/* $(1)/etc/dnsmasq.oversea/ + $(INSTALL_DATA) ./root/etc/dnsmasq.ssr/* $(1)/etc/dnsmasq.ssr/ + $(INSTALL_BIN) ./root/etc/init.d/* $(1)/etc/init.d/ + $(INSTALL_BIN) ./root/etc/uci-defaults/* $(1)/etc/uci-defaults/ + #root/usr + $(INSTALL_BIN) ./root/usr/bin/* $(1)/usr/bin/ + $(INSTALL_BIN) ./root/usr/share/shadowsocksr/*.sh $(1)/usr/share/shadowsocksr/ + $(INSTALL_DATA) ./root/usr/share/shadowsocksr/*.lua $(1)/usr/share/shadowsocksr/ + #luasrc + $(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/ + $(INSTALL_DATA) ./luasrc/model/cbi/shadowsocksr/*.lua $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr/ + $(INSTALL_DATA) ./luasrc/view/shadowsocksr/* $(1)/usr/lib/lua/luci/view/shadowsocksr/ po2lmo ./po/zh-cn/ssr-plus.po $(1)/usr/lib/lua/luci/i18n/ssr-plus.zh-cn.lmo endef @@ -80,7 +99,6 @@ define Package/luci-app-ssr-plus/postinst if [ -z "$${IPKG_INSTROOT}" ]; then ( . /etc/uci-defaults/luci-ssr-plus ) && rm -f /etc/uci-defaults/luci-ssr-plus rm -f /tmp/luci-indexcache - chmod 755 /etc/init.d/shadowsocksr >/dev/null 2>&1 /etc/init.d/shadowsocksr enable >/dev/null 2>&1 fi exit 0 @@ -89,8 +107,8 @@ endef define Package/luci-app-ssr-plus/prerm #!/bin/sh if [ -z "$${IPKG_INSTROOT}" ]; then - /etc/init.d/shadowsocksr disable - /etc/init.d/shadowsocksr stop + /etc/init.d/shadowsocksr disable + /etc/init.d/shadowsocksr stop fi exit 0 endef diff --git a/package/lean/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua b/package/lean/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua index 7ec5d37cf4..cb7aa7e8b2 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/controller/shadowsocksr.lua @@ -7,63 +7,67 @@ function index() if not nixio.fs.access("/etc/config/shadowsocksr") then return end - - - entry({"admin", "services", "shadowsocksr"},alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true - - entry({"admin", "services", "shadowsocksr", "client"},cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true - + entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true + entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply=true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true - - entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"),_("Access Control"), 30).leaf = true - + entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true -- entry({"admin", "services", "shadowsocksr", "list"},form("shadowsocksr/list"),_("GFW List"), 40).leaf = true - entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true - if nixio.fs.access("/usr/bin/ssr-server") then - entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true + entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true end - entry({"admin", "services", "shadowsocksr", "status"},form("shadowsocksr/status"),_("Status"), 70).leaf = true - entry({"admin", "services", "shadowsocksr", "check"}, call("check_status")) entry({"admin", "services", "shadowsocksr", "refresh"}, call("refresh_data")) + entry({"admin", "services", "shadowsocksr", "subscribe"}, call("subscribe")) entry({"admin", "services", "shadowsocksr", "checkport"}, call("check_port")) - entry({"admin", "services", "shadowsocksr", "log"},form("shadowsocksr/log"),_("Log"), 80).leaf = true - entry({"admin", "services", "shadowsocksr","run"},call("act_status")).leaf=true - entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf=true - +end + +function subscribe() + luci.sys.call("/usr/bin/lua /usr/share/shadowsocksr/subscribe.lua >> /tmp/ssrplus.log 2>&1") + luci.http.prepare_content("application/json") + luci.http.write_json({ ret = 1 }) end function act_status() - local e={} - e.running=luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null")==0 - luci.http.prepare_content("application/json") - luci.http.write_json(e) + local e={} + e.running=luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) end function act_ping() - local e={} - e.index=luci.http.formvalue("index") - e.ping=luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'"%luci.http.formvalue("domain")) - luci.http.prepare_content("application/json") - luci.http.write_json(e) + local e = {} + local domain = luci.http.formvalue("domain") + local port = luci.http.formvalue("port") + e.index = luci.http.formvalue("index") + e.ping = luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'" % domain) + local iret = luci.sys.call(" ipset add ss_spec_wan_ac " .. domain .. " 2>/dev/null") + local socket = nixio.socket("inet", "stream") + socket:setopt("socket", "rcvtimeo", 3) + socket:setopt("socket", "sndtimeo", 3) + e.socket = socket:connect(domain, port) + socket:close() + if (iret == 0) then + luci.sys.call(" ipset del ss_spec_wan_ac " .. domain) + end + luci.http.prepare_content("application/json") + luci.http.write_json(e) end function check_status() -local set ="/usr/bin/ssr-check www." .. luci.http.formvalue("set") .. ".com 80 3 1" -sret=luci.sys.call(set) -if sret== 0 then - retstring ="0" -else - retstring ="1" -end -luci.http.prepare_content("application/json") -luci.http.write_json({ ret=retstring }) + local set = "/usr/bin/ssr-check www." .. luci.http.formvalue("set") .. ".com 80 3 1" + sret = luci.sys.call(set) + if sret == 0 then + retstring ="0" + else + retstring ="1" + end + luci.http.prepare_content("application/json") + luci.http.write_json({ ret=retstring }) end function refresh_data() @@ -71,85 +75,83 @@ local set =luci.http.formvalue("set") local icount =0 if set == "gfw_data" then - if nixio.fs.access("/usr/bin/wget-ssl") then - refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64" - else - refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64" - end - sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") - if sret== 0 then - luci.sys.call("/usr/bin/ssr-gfw") - icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l") - if tonumber(icount)>1000 then - oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l") - if tonumber(icount) ~= tonumber(oldcount) then - luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf") - retstring=tostring(math.ceil(tonumber(icount)/2)) - else - retstring ="0" - end - else - retstring ="-1" - end - luci.sys.exec("rm -f /tmp/gfwnew.txt ") - else - retstring ="-1" - end -elseif set == "ip_data" then - refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt" - sret=luci.sys.call(refresh_cmd) - icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l") - if sret== 0 and tonumber(icount)>1000 then - oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l") - if tonumber(icount) ~= tonumber(oldcount) then - luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt") - retstring=tostring(tonumber(icount)) - else - retstring ="0" - end - - else - retstring ="-1" - end - luci.sys.exec("rm -f /tmp/china_ssr.txt ") +if nixio.fs.access("/usr/bin/wget-ssl") then + refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64" + else + refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64" + end + sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") + if sret== 0 then + luci.sys.call("/usr/bin/ssr-gfw") + icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l") + if tonumber(icount)>1000 then + oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l") + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf") + retstring=tostring(math.ceil(tonumber(icount)/2)) + else + retstring ="0" + end + else + retstring ="-1" + end + luci.sys.exec("rm -f /tmp/gfwnew.txt ") else - local need_process = 0 - if nixio.fs.access("/usr/bin/wget-ssl") then - refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf" - need_process = 1 - else - refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf" - end - sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") - if sret== 0 then - if need_process == 1 then - luci.sys.call("/usr/bin/ssr-ad") - end - icount = luci.sys.exec("cat /tmp/ad.conf | wc -l") - if tonumber(icount)>1000 then - if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then - oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l") - else - oldcount=0 - end - - if tonumber(icount) ~= tonumber(oldcount) then - luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf") - retstring=tostring(math.ceil(tonumber(icount))) - if oldcount==0 then - luci.sys.call("/etc/init.d/dnsmasq restart") - end - else - retstring ="0" - end - else - retstring ="-1" - end - luci.sys.exec("rm -f /tmp/ad.conf ") - else - retstring ="-1" - end -end + retstring ="-1" +end +elseif set == "ip_data" then +refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt" +sret=luci.sys.call(refresh_cmd) +icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l") +if sret== 0 and tonumber(icount)>1000 then + oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l") + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt") + retstring=tostring(tonumber(icount)) + else + retstring ="0" + end +else + retstring ="-1" +end +luci.sys.exec("rm -f /tmp/china_ssr.txt ") +else + local need_process = 0 + if nixio.fs.access("/usr/bin/wget-ssl") then + refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf" + need_process = 1 +else + refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf" +end +sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") +if sret== 0 then + if need_process == 1 then + luci.sys.call("/usr/bin/ssr-ad") + end + icount = luci.sys.exec("cat /tmp/ad.conf | wc -l") + if tonumber(icount)>1000 then + if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then + oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l") + else + oldcount=0 + end + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf") + retstring=tostring(math.ceil(tonumber(icount))) + if oldcount==0 then + luci.sys.call("/etc/init.d/dnsmasq restart") + end + else + retstring ="0" + end + else + retstring ="-1" + end + luci.sys.exec("rm -f /tmp/ad.conf") +else + retstring ="-1" +end +end luci.http.prepare_content("application/json") luci.http.write_json({ ret=retstring ,retcount=icount}) end @@ -163,9 +165,7 @@ local server_name = "" local shadowsocksr = "shadowsocksr" local uci = luci.model.uci.cursor() local iret=1 - uci:foreach(shadowsocksr, "servers", function(s) - if s.alias then server_name=s.alias elseif s.server and s.server_port then @@ -181,12 +181,11 @@ uci:foreach(shadowsocksr, "servers", function(s) retstring =retstring .. "[" .. server_name .. "] OK.
" else retstring =retstring .. "[" .. server_name .. "] Error.
" - end + end if iret== 0 then luci.sys.call(" ipset del ss_spec_wan_ac " .. s.server) end end) - luci.http.prepare_content("application/json") luci.http.write_json({ ret=retstring }) end diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 5c76574240..cc96529a7f 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -10,15 +10,14 @@ uci:foreach(shadowsocksr, "servers", function(s) end end) -local key_table = {} -for key,_ in pairs(server_table) do - table.insert(key_table,key) -end +local key_table = {} +for key,_ in pairs(server_table) do + table.insert(key_table,key) +end table.sort(key_table) - m = Map(shadowsocksr) - +-- [[ global ]]-- s = m:section(TypedSection, "global", translate("Server failsafe auto swith settings")) s.anonymous = true @@ -38,6 +37,18 @@ o.datatype = "uinteger" o:depends("enable_switch", "1") o.default = 5 +o = s:option(Value, "switch_try_count", translate("Check Try Count")) +o.datatype = "uinteger" +o:depends("enable_switch", "1") +o.default = 3 + +-- [[ adblock ]]-- +s = m:section(TypedSection, "global", translate("adblock settings")) +s.anonymous = true + +o = s:option(Flag, "adblock", translate("Enable adblock")) +o.rmempty = false + -- [[ SOCKS5 Proxy ]]-- if nixio.fs.access("/usr/bin/ssr-local") then s = m:section(TypedSection, "socks5_proxy", translate("SOCKS5 Proxy")) @@ -55,5 +66,4 @@ o.default = 1080 o.rmempty = false end - return m diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index abe8cf90ca..74821fa98b 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -10,12 +10,12 @@ local sid = arg[1] local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid") local function isKcptun(file) - if not fs.access(file, "rwx", "rx", "rx") then - fs.chmod(file, 755) - end + if not fs.access(file, "rwx", "rx", "rx") then + fs.chmod(file, 755) + end - local str = sys.exec(file .. " -v | awk '{printf $1}'") - return (str:lower() == "kcptun") + local str = sys.exec(file .. " -v | awk '{printf $1}'") + return (str:lower() == "kcptun") end @@ -31,7 +31,7 @@ local encrypt_methods = { "aes-256-cfb", "aes-128-ctr", "aes-192-ctr", - "aes-256-ctr", + "aes-256-ctr", "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", @@ -95,17 +95,17 @@ obfs = { } local securitys = { - "auto", - "none", - "aes-128-gcm", - "chacha20-poly1305" + "auto", + "none", + "aes-128-gcm", + "chacha20-poly1305" } m = Map(shadowsocksr, translate("Edit ShadowSocksR Server")) m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers") if m.uci:get(shadowsocksr, sid) ~= "servers" then - luci.http.redirect(m.redirect) + luci.http.redirect(m.redirect) return end @@ -114,7 +114,7 @@ s = m:section(NamedSection, sid, "servers") s.anonymous = true s.addremove = false -o = s:option(DummyValue,"ssr_url","SS/SSR/V2RAY/TROJAN URL") +o = s:option(DummyValue,"ssr_url","SS/SSR/V2RAY/TROJAN URL") o.rawhtml = true o.template = "shadowsocksr/ssrurl" o.value =sid @@ -124,7 +124,7 @@ o:value("ssr", translate("ShadowsocksR")) if nixio.fs.access("/usr/bin/ss-redir") then o:value("ss", translate("Shadowsocks New Version")) end -if nixio.fs.access("/usr/bin/v2ray/v2ray") then +if nixio.fs.access("/usr/bin/v2ray/v2ray") or nixio.fs.access("/usr/bin/v2ray") then o:value("v2ray", translate("V2Ray")) end if nixio.fs.access("/usr/sbin/trojan") then @@ -341,9 +341,9 @@ o:depends("type", "v2ray") o:depends("type", "trojan") o = s:option(Value, "tls_host", translate("TLS Host")) +--o:depends("type", "trojan") o:depends("tls", "1") o.rmempty = true -o:depends("type", "trojan") -- [[ Mux ]]-- o = s:option(Flag, "mux", translate("Mux")) @@ -388,14 +388,14 @@ function o.validate(self, value, section) local kcp_file="/usr/bin/kcptun-client" local enable = kcp_enable:formvalue(section) or kcp_enable.disabled if enable == kcp_enable.enabled then - if not fs.access(kcp_file) then - return nil, translate("Haven't a Kcptun executable file") - elseif not isKcptun(kcp_file) then - return nil, translate("Not a Kcptun executable file") - end - end + if not fs.access(kcp_file) then + return nil, translate("Haven't a Kcptun executable file") + elseif not isKcptun(kcp_file) then + return nil, translate("Not a Kcptun executable file") + end + end - return value + return value end o:depends("type", "ssr") o:depends("type", "ss") diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua index 28d803cad6..939098f43f 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua @@ -21,12 +21,12 @@ uci:foreach(shadowsocksr, "servers", function(s) end end) -local key_table = {} -for key,_ in pairs(server_table) do - table.insert(key_table,key) -end +local key_table = {} +for key,_ in pairs(server_table) do + table.insert(key_table,key) +end -table.sort(key_table) +table.sort(key_table) -- [[ Global Setting ]]-- s = m:section(TypedSection, "global") diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua index 3cd320ef33..5a89013d35 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/control.lua @@ -21,25 +21,25 @@ s:tab("lan_ac", translate("LAN IP AC")) o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Bypassed Host List")) o.datatype = "ipaddr" luci.ip.neighbors({ family = 4 }, function(entry) - if entry.reachable then - o:value(entry.dest:string()) - end + if entry.reachable then + o:value(entry.dest:string()) + end end) o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List")) o.datatype = "ipaddr" luci.ip.neighbors({ family = 4 }, function(entry) - if entry.reachable then - o:value(entry.dest:string()) - end + if entry.reachable then + o:value(entry.dest:string()) + end end) o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List")) o.datatype = "ipaddr" luci.ip.neighbors({ family = 4 }, function(entry) - if entry.reachable then - o:value(entry.dest:string()) - end + if entry.reachable then + o:value(entry.dest:string()) + end end) -- Part of Self @@ -85,4 +85,4 @@ o.remove = function(self, section, value) NXFS.writefile(blockconf, "") end -return m \ No newline at end of file +return m diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/list.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/list.lua index f0625b6048..34d30aabb9 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/list.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/list.lua @@ -20,4 +20,4 @@ function f.handle(self, state, data) return true end -return f \ No newline at end of file +return f diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua index 914e7e1f62..7492bd1878 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/log.lua @@ -1,6 +1,3 @@ -local fs = require "nixio.fs" -local conffile = "/tmp/ssrpro.log" - f = SimpleForm("logview") f.reset = false f.submit = false @@ -8,8 +5,12 @@ t = f:field(TextValue, "conf") t.rmempty = true t.rows = 20 function t.cfgvalue() - luci.sys.exec("[ -f /tmp/ssrplus.log ] && sed '1!G;h;$!d' /tmp/ssrplus.log > /tmp/ssrpro.log") - return fs.readfile(conffile) or "" +local logs = luci.util.execi("cat /tmp/ssrplus.log") +local s = "" +for line in logs do +s = line .. "\n" .. s +end +return s end t.readonly="readonly" diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua index 76ec0f0ac0..c1c29373da 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server-config.lua @@ -15,7 +15,7 @@ local encrypt_methods = { "aes-256-cfb", "aes-128-ctr", "aes-192-ctr", - "aes-256-ctr", + "aes-256-ctr", "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", @@ -44,7 +44,7 @@ m = Map(shadowsocksr, translate("Edit ShadowSocksR Server")) m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/server") if m.uci:get(shadowsocksr, sid) ~= "server_config" then - luci.http.redirect(m.redirect) + luci.http.redirect(m.redirect) return end diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua index fcec57bc33..08d2196dcc 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/server.lua @@ -6,7 +6,6 @@ local shadowsocksr = "shadowsocksr" local uci = luci.model.uci.cursor() local ipkg = require("luci.model.ipkg") - m = Map(shadowsocksr, translate("ShadowSocksR Server")) local encrypt_methods = { @@ -19,7 +18,7 @@ local encrypt_methods = { "aes-256-cfb", "aes-128-ctr", "aes-192-ctr", - "aes-256-ctr", + "aes-256-ctr", "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", @@ -52,16 +51,10 @@ obfs = { "tls1.2_ticket_fastauth", } - - - - -- [[ Global Setting ]]-- sec = m:section(TypedSection, "server_global", translate("Global Setting")) sec.anonymous = true - - o = sec:option(Flag, "enable_server", translate("Enable Server")) o.rmempty = false @@ -90,7 +83,6 @@ function o.cfgvalue(...) return Value.cfgvalue(...) or "?" end - o = sec:option(DummyValue, "encrypt_method", translate("Encrypt Method")) function o.cfgvalue(...) local v = Value.cfgvalue(...) @@ -102,13 +94,9 @@ function o.cfgvalue(...) return Value.cfgvalue(...) or "?" end - - o = sec:option(DummyValue, "obfs", translate("Obfs")) function o.cfgvalue(...) return Value.cfgvalue(...) or "?" end - - return m diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua index fa0c336fa2..4d11547a2c 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/servers.lua @@ -37,7 +37,7 @@ o.rmempty = true o = s:option(Button,"update_Sub",translate("Update Subscribe List")) o.inputstyle = "reload" o.description = translate("Update subscribe url list first") -o.write = function() +o.write = function() luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) end @@ -45,23 +45,29 @@ o = s:option(Flag, "proxy", translate("Through proxy update")) o.rmempty = false o.description = translate("Through proxy update list, Not Recommended ") -o = s:option(Button,"update",translate("Update All Subscribe Severs")) -o.inputstyle = "apply" -o.write = function() - luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) -end +o = s:option(Button,"subscribe", translate("Update All Subscribe Severs")) +o.rawhtml = true +o.template = "shadowsocksr/subscribe" + + +-- o.inputstyle = "apply" +-- o.write = function() +-- luci.sys.call("lua /root/subscribe.lua >>/tmp/ssrplus.log 2>&1") +-- -- luci.sys.call("echo 123 >>/tmp/ssrplus.log 2>&1") +-- -- luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1") +-- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) +-- end o = s:option(Button,"delete",translate("Delete all severs")) o.inputstyle = "reset" o.description = string.format(translate("Server Count") .. ": %d", server_count) o.write = function() - uci:delete_all("shadowsocksr", "servers", function(s) return true end) - uci:save("shadowsocksr") - luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop") - luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) - return +uci:delete_all("shadowsocksr", "servers", function(s) return true end) +uci:save("shadowsocksr") +luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop") +luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) +return end -- [[ Servers Manage ]]-- @@ -75,7 +81,7 @@ function s.create(...) local sid = TypedSection.create(...) if sid then luci.http.redirect(s.extedit % sid) - return + return end end @@ -113,7 +119,11 @@ function o.cfgvalue(...) return Value.cfgvalue(...) or "0" end -o = s:option(DummyValue,"server",translate("Ping Latency")) +o = s:option(DummyValue, "server_port", translate("Socket Connected")) +o.template="shadowsocksr/socket" +o.width="10%" + +o = s:option(DummyValue, "server", translate("Ping Latency")) o.template="shadowsocksr/ping" o.width="10%" diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua index 9163c742f0..46fb68de91 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua @@ -15,9 +15,10 @@ local gfw_count=0 local ad_count=0 local ip_count=0 local gfwmode=0 +local ucic = luci.model.uci.cursor() if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then -gfwmode=1 +gfwmode=1 end local shadowsocksr = "shadowsocksr" @@ -32,27 +33,27 @@ local sys = require "luci.sys" local kcptun_version=translate("Unknown") local kcp_file="/usr/bin/kcptun-client" if not fs.access(kcp_file) then - kcptun_version=translate("Not exist") +kcptun_version=translate("Not exist") else - if not fs.access(kcp_file, "rwx", "rx", "rx") then - fs.chmod(kcp_file, 755) - end - kcptun_version=sys.exec(kcp_file .. " -v | awk '{printf $3}'") - if not kcptun_version or kcptun_version == "" then - kcptun_version = translate("Unknown") - end - +if not fs.access(kcp_file, "rwx", "rx", "rx") then +fs.chmod(kcp_file, 755) +end +kcptun_version=sys.exec(kcp_file .. " -v | awk '{printf $3}'") +if not kcptun_version or kcptun_version == "" then +kcptun_version = translate("Unknown") end -if gfwmode==1 then - gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2 - if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then - ad_count=tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")) - end end - -if nixio.fs.access("/etc/china_ssr.txt") then - ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l") + +if gfwmode == 1 then +gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2 +if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then +ad_count=tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")) +end +end + +if nixio.fs.access("/etc/china_ssr.txt") then +ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l") end local icount=sys.exec("busybox ps -w | grep ssr-reudp |grep -v grep| wc -l") @@ -65,10 +66,9 @@ reudp_run=1 end end - if luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") == 0 then redir_run=1 -end +end if luci.sys.call("pidof ssr-local >/dev/null") == 0 then sock5_run=1 @@ -76,25 +76,25 @@ end if luci.sys.call("pidof kcptun-client >/dev/null") == 0 then kcptun_run=1 -end +end if luci.sys.call("pidof ssr-server >/dev/null") == 0 then server_run=1 -end +end if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") == 0 then tunnel_run=1 -end +end -if luci.sys.call("pidof pdnsd >/dev/null") == 0 then -pdnsd_run=1 -end +if luci.sys.call("pidof pdnsd >/dev/null") == 0 then +pdnsd_run=1 +end m = SimpleForm("Version") m.reset = false m.submit = false -s=m:field(DummyValue,"redir_run",translate("Global Client")) +s=m:field(DummyValue,"redir_run",translate("Global Client")) s.rawhtml = true if redir_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off @@ -102,7 +102,7 @@ else s.value = translate("Not Running") end -s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay")) +s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay")) s.rawhtml = true if reudp_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off @@ -111,15 +111,15 @@ s.value = translate("Not Running") end s=m:field(DummyValue,"pdnsd_run",translate("PDNSD")) -s.rawhtml = true -if pdnsd_run == 1 then +s.rawhtml = true +if pdnsd_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off -else +else s.value = translate("Not Running") -end +end if nixio.fs.access("/usr/bin/ssr-local") then -s=m:field(DummyValue,"sock5_run",translate("SOCKS5 Proxy")) +s=m:field(DummyValue,"sock5_run",translate("SOCKS5 Proxy")) s.rawhtml = true if sock5_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off @@ -129,7 +129,7 @@ end end if nixio.fs.access("/usr/bin/ssr-server") then -s=m:field(DummyValue,"server_run",translate("Global SSR Server")) +s=m:field(DummyValue,"server_run",translate("Global SSR Server")) s.rawhtml = true if server_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off @@ -139,11 +139,11 @@ end end if nixio.fs.access("/usr/bin/kcptun-client") then -s=m:field(DummyValue,"kcp_version",translate("KcpTun Version")) +s=m:field(DummyValue,"kcp_version",translate("KcpTun Version")) s.rawhtml = true s.value =kcptun_version -s=m:field(DummyValue,"kcptun_run",translate("KcpTun")) +s=m:field(DummyValue,"kcptun_run",translate("KcpTun")) s.rawhtml = true if kcptun_run == 1 then s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off @@ -153,22 +153,28 @@ end end s=m:field(DummyValue,"google",translate("Google Connectivity")) -s.value = translate("No Check") +s.value = translate("No Check") s.template = "shadowsocksr/check" -s=m:field(DummyValue,"baidu",translate("Baidu Connectivity")) -s.value = translate("No Check") +s=m:field(DummyValue,"baidu",translate("Baidu Connectivity")) +s.value = translate("No Check") s.template = "shadowsocksr/check" -if gfwmode==1 then -s=m:field(DummyValue,"gfw_data",translate("GFW List Data")) +if gfwmode == 1 then +s=m:field(DummyValue,"gfw_data",translate("GFW List Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value =tostring(math.ceil(gfw_count)) .. " " .. translate("Records") - end -s=m:field(DummyValue,"ip_data",translate("China IP Data")) +if ucic:get_first(shadowsocksr, 'global', 'adblock', '') == '1' then +s=m:field(DummyValue,"ad_data",translate("Advertising Data")) +s.rawhtml = true +s.template = "shadowsocksr/refresh" +s.value =ad_count .. " " .. translate("Records") +end + +s=m:field(DummyValue,"ip_data",translate("China IP Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" s.value =ip_count .. " " .. translate("Records") diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm index bd78926118..c4b0b89bc6 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/check.htm @@ -1,7 +1,5 @@ <%+cbi/valueheader%> - - - <%=self.value%> diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm index ed91a2f22c..dd46ed500f 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/checkport.htm @@ -1,11 +1,10 @@ <%+cbi/valueheader%> - <%=self.value%> - - - <%+cbi/valuefooter%> \ No newline at end of file diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm index 00da6cd6d9..02a3ae6209 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/refresh.htm @@ -1,11 +1,9 @@ <%+cbi/valueheader%> - - - <%=self.value%> - <%+cbi/valuefooter%> \ No newline at end of file diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm index 9652837efa..e25e25cb18 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/server_list.htm @@ -2,23 +2,61 @@ Copyright 2018-2019 Lienol Licensed to the public under the Apache License 2.0. -%> - <% local dsp = require "luci.dispatcher" -%> - \ No newline at end of file diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/socket.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/socket.htm new file mode 100644 index 0000000000..6cba5bc856 --- /dev/null +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/socket.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> +connecting +<%+cbi/valuefooter%> diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm index bc7f287172..8136c0f5cf 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm @@ -1,227 +1,237 @@ <%+cbi/valueheader%> - - - <%+cbi/valuefooter%> diff --git a/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/subscribe.htm b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/subscribe.htm new file mode 100644 index 0000000000..4d53beeb00 --- /dev/null +++ b/package/lean/luci-app-ssr-plus/luasrc/view/shadowsocksr/subscribe.htm @@ -0,0 +1,18 @@ +<%+cbi/valueheader%> + + + +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index e028dcb7b0..d5b5036d14 100644 --- a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -271,7 +271,6 @@ msgstr "正在检查.." msgid "Proxy Check" msgstr "代理检查" - msgid "GFW List Data" msgstr "【GFW列表】数据库" @@ -320,6 +319,12 @@ msgstr "自动切换检查周期(秒)" msgid "Check timout(second)" msgstr "切换检查超时时间(秒)" +msgid "Check Try Count" +msgstr "切换检查重试次数" + +msgid "Enable adblock" +msgstr "启用广告屏蔽" + msgid "Enable Process Deamon" msgstr "启用进程自动守护" @@ -461,6 +466,9 @@ msgstr "游戏模式UDP中继服务器" msgid "Game Mode UDP Relay" msgstr "游戏模式UDP中继" +msgid "adblock settings" +msgstr "广告屏蔽设置" + msgid "Server failsafe auto swith settings" msgstr "服务器节点故障自动切换设置" @@ -512,6 +520,9 @@ msgstr "所有端口(默认)" msgid "Only Common Ports" msgstr "仅常用端口(不走P2P流量到代理)" +msgid "Socket Connected" +msgstr "连接测试" + msgid "Ping Latency" msgstr "Ping延迟" diff --git a/package/lean/luci-app-ssr-plus/root/etc/china_ssr.txt b/package/lean/luci-app-ssr-plus/root/etc/china_ssr.txt index b182fc7615..cf0c7c5ffb 100644 --- a/package/lean/luci-app-ssr-plus/root/etc/china_ssr.txt +++ b/package/lean/luci-app-ssr-plus/root/etc/china_ssr.txt @@ -119,7 +119,6 @@ 27.116.44.0/22 27.121.72.0/21 27.121.120.0/21 -27.123.232.0/22 27.128.0.0/15 27.131.220.0/22 27.144.0.0/16 @@ -158,7 +157,6 @@ 36.255.164.0/22 36.255.172.0/22 36.255.176.0/22 -36.255.220.0/22 39.0.0.0/24 39.0.2.0/23 39.0.4.0/22 @@ -425,7 +423,6 @@ 43.228.148.0/22 43.228.152.0/22 43.228.188.0/22 -43.229.16.0/22 43.229.40.0/22 43.229.48.0/22 43.229.56.0/22 @@ -696,7 +693,6 @@ 43.239.172.0/22 43.239.176.0/22 43.240.0.0/22 -43.240.48.0/22 43.240.56.0/22 43.240.60.0/22 43.240.68.0/22 @@ -707,6 +703,7 @@ 43.240.128.0/22 43.240.132.0/22 43.240.136.0/22 +43.240.144.0/22 43.240.156.0/22 43.240.160.0/22 43.240.164.0/22 @@ -910,7 +907,6 @@ 43.248.244.0/22 43.249.4.0/22 43.249.8.0/22 -43.249.24.0/22 43.249.120.0/22 43.249.132.0/22 43.249.136.0/22 @@ -952,7 +948,6 @@ 43.250.244.0/22 43.251.4.0/22 43.251.8.0/22 -43.251.12.0/22 43.251.36.0/22 43.251.100.0/22 43.251.116.0/22 @@ -1036,8 +1031,7 @@ 45.65.28.0/22 45.112.132.0/22 45.112.188.0/22 -45.112.208.0/22 -45.112.212.0/22 +45.112.208.0/21 45.112.216.0/22 45.112.220.0/22 45.112.228.0/22 @@ -1092,7 +1086,6 @@ 45.115.236.0/22 45.115.244.0/22 45.115.248.0/22 -45.116.12.0/22 45.116.16.0/22 45.116.24.0/22 45.116.32.0/22 @@ -1128,7 +1121,6 @@ 45.121.72.0/22 45.121.92.0/22 45.121.96.0/22 -45.121.104.0/22 45.121.172.0/22 45.121.176.0/22 45.121.212.0/22 @@ -1229,7 +1221,6 @@ 45.124.176.0/22 45.124.208.0/22 45.124.248.0/22 -45.124.252.0/22 45.125.12.0/22 45.125.16.0/22 45.125.24.0/22 @@ -1481,9 +1472,6 @@ 45.253.232.0/22 45.253.236.0/22 45.253.240.0/22 -45.253.244.0/22 -45.253.248.0/22 -45.253.252.0/22 45.254.0.0/22 45.254.4.0/22 45.254.8.0/22 @@ -1795,7 +1783,6 @@ 61.29.128.0/18 61.29.192.0/19 61.29.224.0/20 -61.29.240.0/20 61.45.128.0/18 61.45.224.0/20 61.47.128.0/18 @@ -1890,12 +1877,15 @@ 101.2.172.0/22 101.4.0.0/14 101.16.0.0/12 -101.32.0.0/14 +101.33.128.0/17 +101.34.0.0/15 101.36.0.0/17 101.36.128.0/17 101.37.0.0/16 101.38.0.0/15 -101.40.0.0/13 +101.40.0.0/15 +101.42.0.0/15 +101.44.0.0/14 101.48.0.0/15 101.50.8.0/22 101.50.12.0/22 @@ -2053,7 +2043,6 @@ 103.12.184.0/22 103.12.232.0/22 103.13.12.0/22 -103.13.72.0/23 103.13.124.0/22 103.13.144.0/22 103.13.196.0/22 @@ -2428,7 +2417,6 @@ 103.35.180.0/22 103.35.200.0/22 103.35.220.0/22 -103.36.20.0/22 103.36.28.0/22 103.36.36.0/22 103.36.56.0/22 @@ -2538,7 +2526,6 @@ 103.40.44.0/22 103.40.88.0/22 103.40.100.0/22 -103.40.112.0/22 103.40.192.0/22 103.40.212.0/22 103.40.220.0/22 @@ -2583,7 +2570,6 @@ 103.43.208.0/22 103.43.220.0/22 103.43.224.0/22 -103.43.232.0/22 103.43.240.0/22 103.44.56.0/22 103.44.80.0/22 @@ -2719,7 +2705,6 @@ 103.47.136.0/22 103.47.140.0/22 103.47.212.0/22 -103.48.20.0/22 103.48.52.0/22 103.48.92.0/22 103.48.144.0/22 @@ -3175,7 +3160,6 @@ 103.76.72.0/22 103.76.84.0/22 103.76.92.0/22 -103.76.104.0/22 103.76.216.0/22 103.76.220.0/22 103.76.224.0/22 @@ -3828,8 +3812,21 @@ 103.124.216.0/22 103.125.20.0/22 103.125.44.0/22 +103.125.132.0/22 +103.125.164.0/22 +103.125.196.0/22 +103.125.236.0/22 +103.125.248.0/22 +103.126.0.0/22 +103.126.16.0/22 +103.126.44.0/22 +103.126.100.0/22 +103.126.124.0/22 +103.126.128.0/22 +103.126.132.0/22 +103.126.208.0/22 +103.126.241.0/24 103.129.52.0/22 -103.129.148.0/22 103.130.132.0/22 103.130.152.0/24 103.130.160.0/22 @@ -3842,6 +3839,160 @@ 103.131.224.0/22 103.131.228.0/22 103.131.240.0/22 +103.132.60.0/22 +103.132.64.0/22 +103.132.68.0/22 +103.132.72.0/22 +103.132.76.0/22 +103.132.80.0/22 +103.132.104.0/22 +103.132.108.0/22 +103.132.112.0/22 +103.132.116.0/22 +103.132.120.0/22 +103.132.160.0/22 +103.132.164.0/22 +103.132.188.0/22 +103.132.208.0/22 +103.132.212.0/22 +103.132.234.0/23 +103.133.12.0/22 +103.133.40.0/22 +103.133.128.0/22 +103.133.136.0/22 +103.133.176.0/22 +103.133.232.0/22 +103.134.12.0/24 +103.134.196.0/22 +103.135.80.0/22 +103.135.124.0/22 +103.135.148.0/22 +103.135.156.0/22 +103.135.160.0/22 +103.135.164.0/22 +103.135.176.0/22 +103.135.184.0/22 +103.135.192.0/22 +103.135.196.0/22 +103.135.236.0/22 +103.136.128.0/22 +103.136.232.0/22 +103.137.58.0/23 +103.137.60.0/24 +103.137.76.0/22 +103.137.136.0/23 +103.137.149.0/24 +103.137.180.0/22 +103.137.236.0/22 +103.138.2.0/23 +103.138.12.0/23 +103.138.80.0/22 +103.138.134.0/23 +103.138.156.0/23 +103.138.208.0/23 +103.138.220.0/23 +103.138.246.0/23 +103.138.248.0/23 +103.139.0.0/23 +103.139.2.0/23 +103.139.22.0/23 +103.139.113.0/24 +103.139.134.0/23 +103.139.136.0/23 +103.139.172.0/23 +103.139.200.0/23 +103.139.204.0/23 +103.139.212.0/23 +103.140.8.0/23 +103.140.14.0/23 +103.140.46.0/23 +103.140.70.0/23 +103.140.126.0/23 +103.140.140.0/23 +103.140.144.0/23 +103.140.152.0/23 +103.140.192.0/23 +103.140.194.0/23 +103.140.228.0/23 +103.141.10.0/23 +103.141.36.0/23 +103.141.58.0/23 +103.141.128.0/23 +103.141.186.0/23 +103.141.190.0/23 +103.141.242.0/23 +103.142.0.0/23 +103.142.28.0/23 +103.142.58.0/23 +103.142.82.0/23 +103.142.96.0/23 +103.142.102.0/23 +103.142.122.0/23 +103.142.126.0/24 +103.142.128.0/23 +103.142.140.0/23 +103.142.154.0/23 +103.142.156.0/23 +103.142.172.0/23 +103.142.180.0/23 +103.142.186.0/23 +103.142.190.0/23 +103.142.220.0/23 +103.142.230.0/24 +103.142.234.0/23 +103.142.238.0/23 +103.142.248.0/23 +103.143.16.0/23 +103.143.18.0/23 +103.143.31.0/24 +103.143.74.0/23 +103.143.120.0/23 +103.143.124.0/23 +103.143.132.0/23 +103.143.134.0/23 +103.143.174.0/23 +103.143.228.0/23 +103.144.40.0/23 +103.144.52.0/23 +103.144.66.0/23 +103.144.70.0/23 +103.144.72.0/23 +103.144.88.0/24 +103.144.108.0/23 +103.144.136.0/23 +103.144.148.0/23 +103.144.158.0/23 +103.144.240.0/23 +103.145.38.0/23 +103.145.40.0/23 +103.145.42.0/23 +103.145.60.0/23 +103.145.72.0/23 +103.145.80.0/23 +103.145.86.0/23 +103.145.92.0/23 +103.145.94.0/23 +103.145.98.0/23 +103.145.106.0/23 +103.145.122.0/23 +103.145.188.0/23 +103.145.190.0/23 +103.146.6.0/23 +103.146.72.0/23 +103.146.88.0/23 +103.146.90.0/23 +103.146.124.0/23 +103.146.126.0/23 +103.146.138.0/23 +103.146.147.0/24 +103.146.230.0/23 +103.146.236.0/23 +103.146.252.0/23 +103.147.12.0/23 +103.147.124.0/23 +103.147.198.0/23 +103.147.206.0/23 +103.147.211.0/24 103.192.0.0/22 103.192.4.0/22 103.192.8.0/22 @@ -4560,7 +4711,6 @@ 103.227.228.0/22 103.228.12.0/22 103.228.28.0/22 -103.228.68.0/22 103.228.88.0/22 103.228.128.0/22 103.228.136.0/22 @@ -4902,7 +5052,8 @@ 106.4.0.0/14 106.8.0.0/15 106.11.0.0/16 -106.12.0.0/14 +106.12.0.0/15 +106.14.0.0/15 106.16.0.0/12 106.32.0.0/12 106.48.0.0/15 @@ -5064,6 +5215,8 @@ 113.208.128.0/17 113.209.0.0/16 113.212.0.0/18 +113.212.64.0/22 +113.212.88.0/22 113.212.100.0/22 113.212.184.0/21 113.213.0.0/17 @@ -5093,7 +5246,6 @@ 114.117.0.0/16 114.118.0.0/16 114.119.0.0/17 -114.119.128.0/18 114.119.192.0/21 114.119.200.0/22 114.119.204.0/22 @@ -5204,9 +5356,11 @@ 116.204.132.0/22 116.204.168.0/22 116.204.216.0/22 +116.204.232.0/22 +116.204.236.0/22 +116.204.244.0/22 116.205.0.0/16 116.206.92.0/22 -116.206.100.0/22 116.206.176.0/22 116.207.0.0/16 116.208.0.0/14 @@ -5237,7 +5391,10 @@ 117.32.0.0/13 117.40.0.0/14 117.44.0.0/15 -117.48.0.0/14 +117.48.0.0/17 +117.48.128.0/17 +117.49.0.0/16 +117.50.0.0/15 117.53.48.0/20 117.53.176.0/20 117.57.0.0/16 @@ -5316,7 +5473,20 @@ 118.186.0.0/15 118.188.0.0/16 118.190.0.0/16 -118.191.0.0/16 +118.191.0.0/21 +118.191.8.0/22 +118.191.12.0/24 +118.191.16.0/21 +118.191.64.0/20 +118.191.80.0/22 +118.191.128.0/19 +118.191.176.0/20 +118.191.192.0/20 +118.191.208.0/24 +118.191.216.0/22 +118.191.223.0/24 +118.191.224.0/24 +118.191.240.0/20 118.192.0.0/16 118.193.0.0/21 118.193.8.0/21 @@ -5346,7 +5516,6 @@ 119.2.128.0/17 119.3.0.0/16 119.4.0.0/14 -119.8.0.0/16 119.10.0.0/17 119.15.136.0/21 119.16.0.0/16 @@ -5512,17 +5681,17 @@ 122.9.0.0/16 122.10.128.0/22 122.10.132.0/23 -122.10.134.0/23 122.10.136.0/23 -122.10.138.0/23 -122.10.140.0/22 -122.10.144.0/20 -122.10.160.0/19 -122.10.192.0/20 +122.10.164.0/22 +122.10.168.0/21 +122.10.176.0/20 +122.10.192.0/22 +122.10.200.0/21 122.10.208.0/21 122.10.216.0/22 -122.10.220.0/22 -122.10.224.0/19 +122.10.228.0/22 +122.10.232.0/21 +122.10.240.0/22 122.11.0.0/17 122.12.0.0/16 122.13.0.0/16 @@ -5627,6 +5796,8 @@ 123.242.196.0/22 123.244.0.0/14 123.249.0.0/16 +123.253.108.0/22 +123.253.240.0/22 123.254.96.0/22 123.254.100.0/22 124.6.64.0/18 @@ -5652,7 +5823,8 @@ 124.64.0.0/15 124.66.0.0/17 124.67.0.0/16 -124.68.0.0/14 +124.68.0.0/15 +124.70.0.0/15 124.72.0.0/16 124.73.0.0/16 124.74.0.0/15 @@ -6064,7 +6236,6 @@ 180.233.144.0/22 180.235.64.0/19 180.235.112.0/22 -180.235.136.0/22 182.16.144.0/22 182.16.148.0/22 182.16.192.0/19 @@ -6122,7 +6293,9 @@ 183.182.0.0/19 183.184.0.0/13 183.192.0.0/10 +185.203.36.0/22 188.131.128.0/17 +192.51.188.0/24 192.55.46.0/24 192.55.68.0/22 192.102.204.0/23 @@ -6146,12 +6319,15 @@ 192.140.208.0/22 192.140.212.0/22 192.144.128.0/17 +192.197.113.0/24 193.112.0.0/16 198.175.100.0/22 +199.212.57.0/24 202.0.100.0/23 202.0.122.0/23 202.0.176.0/22 202.3.128.0/23 +202.3.134.0/24 202.4.128.0/19 202.4.252.0/22 202.5.208.0/22 @@ -6174,6 +6350,7 @@ 202.8.12.0/24 202.8.24.0/24 202.8.77.0/24 +202.8.120.0/22 202.8.128.0/19 202.8.192.0/20 202.9.32.0/24 @@ -6359,6 +6536,7 @@ 202.52.34.0/24 202.52.47.0/24 202.52.143.0/24 +202.52.144.0/24 202.53.140.0/24 202.53.143.0/24 202.57.192.0/22 @@ -6369,6 +6547,7 @@ 202.57.216.0/22 202.57.240.0/20 202.58.0.0/24 +202.58.101.0/24 202.58.104.0/22 202.58.112.0/22 202.59.0.0/24 @@ -6493,6 +6672,7 @@ 202.92.252.0/22 202.93.0.0/22 202.93.252.0/22 +202.94.68.0/24 202.94.74.0/24 202.94.81.0/24 202.94.92.0/22 @@ -6954,7 +7134,6 @@ 203.8.0.0/24 203.8.8.0/24 203.8.23.0/24 -203.8.24.0/21 203.8.70.0/24 203.8.82.0/24 203.8.86.0/23 @@ -7018,7 +7197,6 @@ 203.12.66.0/24 203.12.70.0/23 203.12.87.0/24 -203.12.88.0/21 203.12.100.0/23 203.12.103.0/24 203.12.114.0/24 @@ -7026,7 +7204,6 @@ 203.12.130.0/24 203.12.137.0/24 203.12.196.0/22 -203.12.200.0/21 203.12.211.0/24 203.12.219.0/24 203.12.226.0/24 @@ -7034,7 +7211,6 @@ 203.13.18.0/24 203.13.24.0/24 203.13.44.0/23 -203.13.80.0/21 203.13.88.0/23 203.13.92.0/22 203.13.173.0/24 @@ -7050,7 +7226,6 @@ 203.14.114.0/23 203.14.118.0/24 203.14.162.0/24 -203.14.184.0/21 203.14.192.0/24 203.14.194.0/23 203.14.214.0/24 @@ -7676,6 +7851,7 @@ 203.86.250.0/24 203.86.254.0/23 203.88.32.0/19 +203.88.100.0/22 203.88.192.0/19 203.89.0.0/22 203.89.8.0/21 @@ -7862,9 +8038,9 @@ 203.212.80.0/20 203.215.232.0/21 203.217.164.0/22 -203.222.192.0/20 203.223.0.0/20 203.223.16.0/21 +204.52.191.0/24 210.2.0.0/20 210.2.16.0/20 210.5.0.0/19 @@ -7992,7 +8168,6 @@ 211.164.0.0/14 212.64.0.0/17 212.129.128.0/17 -216.250.108.0/22 218.0.0.0/16 218.1.0.0/16 218.2.0.0/15 diff --git a/package/lean/luci-app-ssr-plus/root/etc/config/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/config/shadowsocksr index 7741d69088..2e5e5822de 100644 --- a/package/lean/luci-app-ssr-plus/root/etc/config/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/config/shadowsocksr @@ -9,6 +9,8 @@ config global option enable_switch '1' option switch_timeout '5' option switch_time '667' + option switch_try_count '3' + option adblock '0' config socks5_proxy option server 'nil' diff --git a/package/lean/luci-app-ssr-plus/root/etc/dnsmasq.ssr/gfw_list.conf b/package/lean/luci-app-ssr-plus/root/etc/dnsmasq.ssr/gfw_list.conf index 97fc505ab1..e69de29bb2 100644 --- a/package/lean/luci-app-ssr-plus/root/etc/dnsmasq.ssr/gfw_list.conf +++ b/package/lean/luci-app-ssr-plus/root/etc/dnsmasq.ssr/gfw_list.conf @@ -1,2 +0,0 @@ -server=/.t66y.com/127.0.0.1#5335 -ipset=/.t66y.com/gfwlist diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 783b1ff24b..c82ea6eb9b 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -45,8 +45,8 @@ add_cron() { sed -i '/shadowsocksr/d' $CRON_FILE sed -i '/ssrplus.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/ssrplus.log' >> $CRON_FILE - [ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/share/shadowsocksr/subscribe.sh" >> $CRON_FILE - [ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 5 * * * /usr/share/shadowsocksr/update.sh" >> $CRON_FILE + [ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/bin/lua /usr/share/shadowsocksr/subscribe.lua" >> $CRON_FILE + [ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/bin/lua /usr/share/shadowsocksr/update.lua" >> $CRON_FILE crontab $CRON_FILE } @@ -60,73 +60,72 @@ del_cron() run_mode=$(uci_get_by_type global run_mode) gen_config_file() { - local host=$(uci_get_by_name $1 server) - if echo $host|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then - hostip=${host} - elif [ "$host" != "${host#*:[0-9a-fA-F]}" ] ;then - hostip=${host} - else - hostip=`ping ${host} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1` - if echo $hostip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then - hostip=${hostip} - else - hostip=`cat /etc/ssr_ip` - fi - fi - [ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1" - - if [ $2 = "0" ] ;then - config_file=$CONFIG_FILE - elif [ $2 = "1" ]; then - config_file=$CONFIG_UDP_FILE - else - config_file=$CONFIG_SOCK5_FILE - fi - if [ $(uci_get_by_name $1 fast_open 0) = "1" ] ;then - fastopen="true"; - else - fastopen="false"; - fi + local host=$(uci_get_by_name $1 server) + if echo $host|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then + hostip=${host} + elif [ "$host" != "${host#*:[0-9a-fA-F]}" ] ;then + hostip=${host} + else + hostip=`ping ${host} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1` + if echo $hostip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then + hostip=${hostip} + else + hostip=`cat /etc/ssr_ip` + fi + fi + [ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1" + + if [ $2 = "0" ] ;then + config_file=$CONFIG_FILE + elif [ $2 = "1" ]; then + config_file=$CONFIG_UDP_FILE + else + config_file=$CONFIG_SOCK5_FILE + fi + if [ $(uci_get_by_name $1 fast_open 0) = "1" ] ;then + fastopen="true"; + else + fastopen="false"; + fi local stype=$(uci_get_by_name $1 type) if [ "$stype" == "ss" ] ;then cat <<-EOF >$config_file - { - "server": "$hostip", - "server_port": $(uci_get_by_name $1 server_port), - "local_address": "0.0.0.0", - "local_port": $(uci_get_by_name $1 local_port), - "password": "$(uci_get_by_name $1 password)", - "timeout": $(uci_get_by_name $1 timeout 60), - "method": "$(uci_get_by_name $1 encrypt_method_ss)", - "reuse_port": true, - "fast_open": $fastopen - } +{ +"server": "$hostip", +"server_port": $(uci_get_by_name $1 server_port), +"local_address": "0.0.0.0", +"local_port": $(uci_get_by_name $1 local_port), +"password": "$(uci_get_by_name $1 password)", +"timeout": $(uci_get_by_name $1 timeout 60), +"method": "$(uci_get_by_name $1 encrypt_method_ss)", +"reuse_port": true, +"fast_open": $fastopen +} EOF - elif [ "$stype" == "ssr" ] ;then - cat <<-EOF >$config_file - { - - "server": "$hostip", - "server_port": $(uci_get_by_name $1 server_port), - "local_address": "0.0.0.0", - "local_port": $(uci_get_by_name $1 local_port), - "password": "$(uci_get_by_name $1 password)", - "timeout": $(uci_get_by_name $1 timeout 60), - "method": "$(uci_get_by_name $1 encrypt_method)", - "protocol": "$(uci_get_by_name $1 protocol)", - "protocol_param": "$(uci_get_by_name $1 protocol_param)", - "obfs": "$(uci_get_by_name $1 obfs)", - "obfs_param": "$(uci_get_by_name $1 obfs_param)", - "reuse_port": true, - "fast_open": $fastopen - } +elif [ "$stype" == "ssr" ] ;then +cat <<-EOF >$config_file +{ +"server": "$hostip", +"server_port": $(uci_get_by_name $1 server_port), +"local_address": "0.0.0.0", +"local_port": $(uci_get_by_name $1 local_port), +"password": "$(uci_get_by_name $1 password)", +"timeout": $(uci_get_by_name $1 timeout 60), +"method": "$(uci_get_by_name $1 encrypt_method)", +"protocol": "$(uci_get_by_name $1 protocol)", +"protocol_param": "$(uci_get_by_name $1 protocol_param)", +"obfs": "$(uci_get_by_name $1 obfs)", +"obfs_param": "$(uci_get_by_name $1 obfs_param)", +"reuse_port": true, +"fast_open": $fastopen +} EOF - elif [ "$stype" == "v2ray" ] ;then - lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp $(uci_get_by_name $1 local_port) > /var/etc/v2-ssr-retcp.json - sed -i 's/\\//g' /var/etc/v2-ssr-retcp.json - elif [ "$stype" == "trojan" ] ;then - lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER nat $(uci_get_by_name $1 local_port) > /var/etc/trojan-ssr-retcp.json - sed -i 's/\\//g' /var/etc/trojan-ssr-retcp.json + elif [ "$stype" == "v2ray" ] ;then + lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp $(uci_get_by_name $1 local_port) > /var/etc/v2-ssr-retcp.json + sed -i 's/\\//g' /var/etc/v2-ssr-retcp.json + elif [ "$stype" == "trojan" ] ;then + lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER nat $(uci_get_by_name $1 local_port) > /var/etc/trojan-ssr-retcp.json + sed -i 's/\\//g' /var/etc/trojan-ssr-retcp.json fi } @@ -140,26 +139,26 @@ get_arg_out() { start_rules() { local server=$(uci_get_by_name $GLOBAL_SERVER server) #resolve name - if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then - server=${server} + if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then + server=${server} elif [ "$server" != "${server#*:[0-9a-fA-F]}" ] ;then - server=${server} + server=${server} else - server=`ping ${server} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1` - if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then - echo $server >/etc/ssr_ip - else - server=`cat /etc/ssr_ip` - fi + server=`ping ${server} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1` + if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then + echo $server >/etc/ssr_ip + else + server=`cat /etc/ssr_ip` + fi fi - + kcp_server=$server - + local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable 0) if [ $kcp_enable = "1" ] ;then - kcp_flag=1 - fi - + kcp_flag=1 + fi + local local_port=$(uci_get_by_name $GLOBAL_SERVER local_port) local lan_ac_ips=$(uci_get_by_type access_control lan_ac_ips) local lan_ac_mode="b" @@ -171,31 +170,31 @@ start_rules() { local udp_server=$(uci_get_by_name $UDP_RELAY_SERVER server) local udp_local_port=$(uci_get_by_name $UDP_RELAY_SERVER local_port) fi - + if [ -n "$lan_ac_ips" ]; then case "$lan_ac_mode" in w|W|b|B) local ac_ips="$lan_ac_mode$lan_ac_ips";; esac fi - + #deal gfw firewall rule - local gfwmode="" + local gfwmode="" if [ "$run_mode" = "gfw" ]; then - gfwmode="-g" + gfwmode="-g" elif [ "$run_mode" = "router" ]; then - gfwmode="-r" + gfwmode="-r" elif [ "$run_mode" = "oversea" ]; then - gfwmode="-c" + gfwmode="-c" elif [ "$run_mode" = "all" ]; then - gfwmode="-z" + gfwmode="-z" fi - + local dports=$(uci_get_by_type global dports 1) - if [ $dports = "1" ] ;then - proxyport=" " + if [ $dports = "1" ] ;then + proxyport=" " else - proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443 " - fi + proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443 " + fi /usr/bin/ssr-rules \ -s "$server" \ @@ -210,64 +209,65 @@ start_rules() { -G "$(uci_get_by_type access_control lan_gm_ips)" \ -D "$proxyport" \ $(get_arg_out) $gfwmode $ARG_UDP - + return $? } start_pdnsd() { local usr_dns="$1" - local usr_port="$2" - + local usr_port="$2" + local tcp_dns_list="208.67.222.222, 208.67.220.220" [ -z "$usr_dns" ] && usr_dns="8.8.8.8" [ -z "$usr_port" ] && usr_port="53" - [ -d /var/etc ] || mkdir -p /var/etc + [ -d /var/etc ] || mkdir -p /var/etc + + if [ ! -d /var/pdnsd ];then + mkdir -p /var/pdnsd + echo -ne "pd13\000\000\000\000" >/var/pdnsd/pdnsd.cache + chown -R nobody:nogroup /var/pdnsd + fi - if [ ! -d /var/pdnsd ];then - mkdir -p /var/pdnsd - echo -ne "pd13\000\000\000\000" >/var/pdnsd/pdnsd.cache - chown -R nobody:nogroup /var/pdnsd - fi - cat > /var/etc/pdnsd.conf </dev/null 2>&1 - done - echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >> /tmp/ssrplus.log - elif [ "$stype" == "v2ray" ] ;then - $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & - echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >> /tmp/ssrplus.log - elif [ "$stype" == "trojan" ] ;then - $sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 & - echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) Started!" >> /tmp/ssrplus.log + local last_config_file=$CONFIG_FILE + local pid_file="/var/run/ssr-retcp.pid" + for i in $(seq 1 $threads) + do + $sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1 + done + echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >> /tmp/ssrplus.log + elif [ "$stype" == "v2ray" ] ;then + $sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 & + echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >> /tmp/ssrplus.log + elif [ "$stype" == "trojan" ] ;then + $sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 & + echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) Started!" >> /tmp/ssrplus.log fi - + if [ -n "$UDP_RELAY_SERVER" ] ;then - redir_udp=1 - if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then - case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in - 1|on|true|yes|enabled) ARG_OTA="-A";; - *) ARG_OTA="";; - esac - gen_config_file $UDP_RELAY_SERVER 1 - last_config_file=$CONFIG_UDP_FILE - pid_file="/var/run/ssr-reudp.pid" - $ucmd -c $last_config_file $ARG_OTA -U -f /var/run/ssr-reudp.pid >/dev/null 2>&1 - elif [ "$utype" == "v2ray" ] ; then - lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json - sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json - $ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 & - elif [ "$stype" == "trojan" ] ;then - lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER client 10801 > /var/etc/trojan-ssr-reudp.json - sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json - $ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 & - ipt2socks -U -4 -b 0.0.0.0 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 & - fi - fi + redir_udp=1 + if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then + case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in + 1|on|true|yes|enabled) ARG_OTA="-A";; + *) ARG_OTA="";; + esac + gen_config_file $UDP_RELAY_SERVER 1 + last_config_file=$CONFIG_UDP_FILE + pid_file="/var/run/ssr-reudp.pid" + $ucmd -c $last_config_file $ARG_OTA -U -f /var/run/ssr-reudp.pid >/dev/null 2>&1 + elif [ "$utype" == "v2ray" ] ; then + lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json + sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json + $ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 & + elif [ "$stype" == "trojan" ] ;then + lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER client 10801 > /var/etc/trojan-ssr-reudp.json + sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json + $ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 & + ipt2socks -U -4 -b 0.0.0.0 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 & + fi + fi #deal with dns - - if [ "$(uci_get_by_type global pdnsd_enable)" = "1" ] ;then - local dnsstr="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)" - local dnsserver=`echo "$dnsstr"|awk -F ':' '{print $1}'` - local dnsport=`echo "$dnsstr"|awk -F ':' '{print $2}'` - if [ "$run_mode" = "gfw" ]; then - ipset add gfwlist $dnsserver 2>/dev/null - elif [ "$run_mode" = "oversea" ]; then - ipset add oversea $dnsserver 2>/dev/null - else - ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null - fi - start_pdnsd $dnsserver $dnsport - pdnsd_enable_flag=1 - fi - + + if [ "$(uci_get_by_type global pdnsd_enable)" = "1" ] ;then + local dnsstr="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)" + local dnsserver=`echo "$dnsstr"|awk -F ':' '{print $1}'` + local dnsport=`echo "$dnsstr"|awk -F ':' '{print $2}'` + if [ "$run_mode" = "gfw" ]; then + ipset add gfwlist $dnsserver 2>/dev/null + elif [ "$run_mode" = "oversea" ]; then + ipset add oversea $dnsserver 2>/dev/null + else + ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null + fi + start_pdnsd $dnsserver $dnsport + pdnsd_enable_flag=1 + fi + if [ "$(uci_get_by_type global enable_switch)" = "1" ] ;then if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable)" = "1" ] ;then if [ -z "$switch_server" ] ;then @@ -400,23 +402,23 @@ start_redir() { gen_service_file() { if [ $(uci_get_by_name $1 fast_open) = "1" ] ;then - fastopen="true"; + fastopen="true"; else - fastopen="false"; - fi + fastopen="false"; + fi cat <<-EOF >$2 - { - "server": "0.0.0.0", - "server_port": $(uci_get_by_name $1 server_port), - "password": "$(uci_get_by_name $1 password)", - "timeout": $(uci_get_by_name $1 timeout 60), - "method": "$(uci_get_by_name $1 encrypt_method)", - "protocol": "$(uci_get_by_name $1 protocol)", - "protocol_param": "$(uci_get_by_name $1 protocol_param)", - "obfs": "$(uci_get_by_name $1 obfs)", - "obfs_param": "$(uci_get_by_name $1 obfs_param)", - "fast_open": $fastopen - } +{ +"server": "0.0.0.0", +"server_port": $(uci_get_by_name $1 server_port), +"password": "$(uci_get_by_name $1 password)", +"timeout": $(uci_get_by_name $1 timeout 60), +"method": "$(uci_get_by_name $1 encrypt_method)", +"protocol": "$(uci_get_by_name $1 protocol)", +"protocol_param": "$(uci_get_by_name $1 protocol_param)", +"obfs": "$(uci_get_by_name $1 obfs)", +"obfs_param": "$(uci_get_by_name $1 obfs_param)", +"fast_open": $fastopen +} EOF } @@ -424,8 +426,8 @@ start_service() { [ $(uci_get_by_name $1 enable) = "0" ] && return 1 let server_count=server_count+1 if [ $server_count = 1 ] ;then -iptables -N SSR-SERVER-RULE && \ -iptables -t filter -I INPUT -j SSR-SERVER-RULE + iptables -N SSR-SERVER-RULE && \ + iptables -t filter -I INPUT -j SSR-SERVER-RULE fi gen_service_file $1 /var/etc/${NAME}_${server_count}.json @@ -435,27 +437,27 @@ iptables -t filter -A SSR-SERVER-RULE -p udp --dport $(uci_get_by_name $1 server return 0 } gen_serv_include() { -FWI=$(uci get firewall.shadowsocksr.path 2>/dev/null) +FWI=$(uci get firewall.shadowsocksr.path 2>/dev/null) [ -n "$FWI" ] || return 0 if [ ! -f $FWI ] ;then -echo '#!/bin/sh' >$FWI + echo '#!/bin/sh' >$FWI fi extract_rules() { echo "*filter" -iptables-save -t filter | grep SSR-SERVER-RULE|sed -e "s/^-A INPUT/-I INPUT/" +iptables-save -t filter | grep SSR-SERVER-RULE|sed -e "s/^-A INPUT/-I INPUT/" echo 'COMMIT' } - cat <<-EOF >>$FWI - iptables-save -c | grep -v "SSR-SERVER" | iptables-restore -c - iptables-restore -n <<-EOT - $(extract_rules) - EOT +cat <<-EOF >>$FWI +iptables-save -c | grep -v "SSR-SERVER" | iptables-restore -c +iptables-restore -n <<-EOT +$(extract_rules) +EOT EOF } start_server() { - SERVER_ENABLE=$(uci_get_by_type server_global enable_server) - [ "$SERVER_ENABLE" = 0 ] && return 0 + SERVER_ENABLE=$(uci_get_by_type server_global enable_server) + [ "$SERVER_ENABLE" = 0 ] && return 0 mkdir -p /var/run /var/etc config_load $NAME @@ -473,7 +475,7 @@ start_local() { -l $(uci_get_by_type socks5_proxy local_port 1080) \ -b $(uci_get_by_type socks5_proxy local_address 0.0.0.0) \ -f /var/run/ssr-local.pid >/dev/null 2>&1 - local_enable=1 + local_enable=1 } rules() { @@ -482,18 +484,18 @@ rules() { UDP_RELAY_SERVER=$(uci_get_by_type global udp_relay_server) [ "$UDP_RELAY_SERVER" = "same" ] && UDP_RELAY_SERVER=$GLOBAL_SERVER if start_rules ;then - return 0 + return 0 else - return 1 + return 1 fi } -start() { +start() { if [ -z "$switch_server" ] ;then - GLOBAL_SERVER=$(uci_get_by_type global global_server) + GLOBAL_SERVER=$(uci_get_by_type global global_server) else - GLOBAL_SERVER=$switch_server - switch_enable=1 + GLOBAL_SERVER=$switch_server + switch_enable=1 fi if rules ;then @@ -509,22 +511,24 @@ EOF conf-dir=/tmp/dnsmasq.oversea EOF fi - /etc/init.d/dnsmasq restart >/dev/null 2>&1 + if [ $(uci_get_by_type global adblock) = 0 ] ;then + rm -f /tmp/dnsmasq.ssr/ad.conf + fi /usr/share/shadowsocksr/gfw2ipset.sh + /etc/init.d/dnsmasq restart >/dev/null 2>&1 fi fi - start_server + start_server start_local - + if [ $(uci_get_by_type global monitor_enable) = 1 ] ;then - let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable - if [ $total_count -gt 0 ] - then - #param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw - service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable - fi + let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable + if [ $total_count -gt 0 ] ;then + #param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw + service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable + fi fi - + ENABLE_SERVER=$(uci_get_by_type global global_server) [ "$ENABLE_SERVER" = "nil" ] && return 1 } @@ -537,15 +541,15 @@ stop() { /usr/bin/ssr-rules -f srulecount=`iptables -L|grep SSR-SERVER-RULE|wc -l` if [ $srulecount -gt 0 ] ;then - iptables -F SSR-SERVER-RULE - iptables -t filter -D INPUT -j SSR-SERVER-RULE - iptables -X SSR-SERVER-RULE 2>/dev/null + iptables -F SSR-SERVER-RULE + iptables -t filter -D INPUT -j SSR-SERVER-RULE + iptables -X SSR-SERVER-RULE 2>/dev/null fi if [ -z "$switch_server" ] ;then - kill -9 $(busybox ps -w | grep ssr-switch | grep -v grep | awk '{print $1}') >/dev/null 2>&1 + kill -9 $(busybox ps -w | grep ssr-switch | grep -v grep | awk '{print $1}') >/dev/null 2>&1 fi if [ $(uci_get_by_type global monitor_enable) = 1 ] ;then - kill -9 $(busybox ps -w | grep ssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1 + kill -9 $(busybox ps -w | grep ssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1 fi killall -q -9 ssr-monitor killall -q -9 ss-redir @@ -556,15 +560,11 @@ stop() { killall -q -9 ssr-server killall -q -9 kcptun-client killall -q -9 ssr-local - if [ -f /var/run/pdnsd.pid ] ;then - kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1 - else - kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1 - fi - + killall -q -9 pdnsd + if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf /etc/init.d/dnsmasq restart >/dev/null 2>&1 - fi - del_cron + fi + del_cron } diff --git a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-gfw b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-gfw index dffebbaca2..89a2da431a 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-gfw +++ b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-gfw @@ -5,7 +5,7 @@ generate_china_banned() cat $1 | base64 -d > /tmp/gfwlist.txt rm -f $1 - sed -i '/^@@|/d' /tmp/gfwlist.txt + sed -i '/^@@|/d' /tmp/gfwlist.txt cat /tmp/gfwlist.txt | sort -u | sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' | diff --git a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-monitor b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-monitor index abf077f578..62c65dde4e 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-monitor +++ b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-monitor @@ -46,10 +46,10 @@ sock5_port=$(uci_get_by_type socks5_proxy local_port 1080) if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then server=${server} else - server=`cat /etc/ssr_ip` + server=`cat /etc/ssr_ip` fi -while [ "1" = "1" ] #ѭ +while [ "1" = "1" ] #死循环 do sleep 30 #redir tcp @@ -57,7 +57,7 @@ do icount=`busybox ps -w | grep ssr-retcp |grep -v grep| wc -l` if [ $icount = 0 ] ;then logger -t "$NAME" "ssr redir tcp error.restart!" - /etc/init.d/shadowsocksr restart + /etc/init.d/shadowsocksr restart exit 0 fi fi @@ -80,53 +80,53 @@ do fi fi #server - if [ $server_process_count -gt 0 ] ;then - icount=`busybox ps -w | grep ssr-server |grep -v grep| wc -l` - if [ $icount -lt $server_process_count ] #̹ҵ - then - logger -t "$NAME" "ssr server error.restart!" - killall -q -9 ssr-server - for i in `seq $server_process_count` - do - /usr/bin/ssr-server -c /var/etc/shadowsocksr_$i.json -u -f /var/run/ssr-server$i.pid - done - fi - fi + if [ $server_process_count -gt 0 ] ;then + icount=`busybox ps -w | grep ssr-server |grep -v grep| wc -l` + if [ $icount -lt $server_process_count ] #如果进程挂掉就重启它 + then + logger -t "$NAME" "ssr server error.restart!" + killall -q -9 ssr-server + for i in `seq $server_process_count` + do + /usr/bin/ssr-server -c /var/etc/shadowsocksr_$i.json -u -f /var/run/ssr-server$i.pid + done + fi + fi #kcptun - if [ $kcp_process -gt 0 ] ;then - icount=`busybox ps -w | grep kcptun-client |grep -v grep| wc -l` - if [ $icount -lt $kcp_process ] #̹ҵ - then - logger -t "$NAME" "ssr kcptun error.restart!" - killall -q -9 kcptun-client + if [ $kcp_process -gt 0 ] ;then + icount=`busybox ps -w | grep kcptun-client |grep -v grep| wc -l` + if [ $icount -lt $kcp_process ] #如果进程挂掉就重启它 + then + logger -t "$NAME" "ssr kcptun error.restart!" + killall -q -9 kcptun-client ( /usr/bin/kcptun-client -r $server:$kcp_port -l :$server_port $password $kcp_param &) - fi - fi + fi + fi #local - if [ $local_process -gt 0 ] ;then - icount=`busybox ps -w | grep ssr-local |grep -v grep| wc -l` - if [ $icount -lt $local_process ] #̹ҵ - then - logger -t "$NAME" "ssr local error.restart!" - killall -q -9 ssr-local + if [ $local_process -gt 0 ] ;then + icount=`busybox ps -w | grep ssr-local |grep -v grep| wc -l` + if [ $icount -lt $local_process ] #如果进程挂掉就重启它 + then + logger -t "$NAME" "ssr local error.restart!" + killall -q -9 ssr-local ( /usr/bin/ssr-local -c /var/etc/shadowsocksr_s.json -u -l $sock5_port -f /var/run/ssr-local.pid &) - fi - fi + fi + fi #pdnsd if [ $pdnsd_process -gt 0 ] ;then icount=`busybox ps -w | grep pdnsd |grep -v grep| wc -l` - if [ $icount -lt $pdnsd_process ] #̹ҵ + if [ $icount -lt $pdnsd_process ] #如果进程挂掉就重启它 then logger -t "$NAME" "pdnsd tunnel error.restart!" - if [ -f /var/run/pdnsd.pid ] ;then - kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1 - else - kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1 - fi + if [ -f /var/run/pdnsd.pid ] ;then + kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1 + else + kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1 + fi ( /usr/sbin/pdnsd -c /var/etc/pdnsd.conf -d &) - fi - fi + fi + fi done diff --git a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-rules b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-rules index bad796dd18..6a97f8f139 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-rules +++ b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-rules @@ -13,32 +13,32 @@ FWI=$(uci get firewall.shadowsocksr.path 2>/dev/null) # firewall include file usage() { cat <<-EOF - Usage: ssr-rules [options] +Usage: ssr-rules [options] - Valid options are: +Valid options are: - -s ip address of shadowsocksr remote server - -l port number of shadowsocksr local server - -S ip address of shadowsocksr remote UDP server - -L port number of shadowsocksr local UDP server - -i a file content is bypassed ip list - -a lan ip of access control, need a prefix to - define access control mode - -b wan ip of will be bypassed - -w wan ip of will be forwarded - -p lan ip of will be global proxy - -G lan ip of will be game mode proxy - -D proxy ports - -e extra options for iptables - -o apply the rules to the OUTPUT chain - -O apply the global rules to the OUTPUT chain - -u enable udprelay mode, TPROXY is required - -U enable udprelay mode, using different IP - and ports for TCP and UDP - -f flush the rules - -g gfw list mode - -r return china mode - -h show this help message and exit + -s ip address of shadowsocksr remote server + -l port number of shadowsocksr local server + -S ip address of shadowsocksr remote UDP server + -L port number of shadowsocksr local UDP server + -i a file content is bypassed ip list + -a lan ip of access control, need a prefix to + define access control mode + -b wan ip of will be bypassed + -w wan ip of will be forwarded + -p lan ip of will be global proxy + -G lan ip of will be game mode proxy + -D proxy ports + -e extra options for iptables + -o apply the rules to the OUTPUT chain + -O apply the global rules to the OUTPUT chain + -u enable udprelay mode, TPROXY is required + -U enable udprelay mode, using different IP + and ports for TCP and UDP + -f flush the rules + -g gfw list mode + -r return china mode + -h show this help message and exit EOF exit $1 } @@ -76,7 +76,7 @@ flush_r() { ipset_r() { ipset -N gmlan hash:net 2>/dev/null for ip in $LAN_GM_IP; do ipset -! add gmlan $ip ; done - + if [ "$RUNMODE" = "router" ] ;then ipset -! -R <<-EOF || return 1 create ss_spec_wan_ac hash:net @@ -87,15 +87,15 @@ EOF $IPT -I SS_SPEC_WAN_AC -d $server -j RETURN $IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN $IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW - + elif [ "$RUNMODE" = "gfw" ] ;then ipset -N gfwlist hash:net 2>/dev/null $IPT -N SS_SPEC_WAN_AC - $IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW - $IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW + $IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW + $IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW $IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN $IPT -I SS_SPEC_WAN_AC -d $server -j RETURN - + elif [ "$RUNMODE" = "oversea" ] ;then ipset -N oversea hash:net 2>/dev/null $IPT -N SS_SPEC_WAN_AC @@ -103,18 +103,18 @@ EOF for ip in $LAN_GM_IP; do ipset -! add gmlan $ip ; done $IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j SS_SPEC_WAN_FW $IPT -I SS_SPEC_WAN_AC -d $server -j RETURN - + elif [ "$RUNMODE" = "all" ] ;then $IPT -N SS_SPEC_WAN_AC $IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW $IPT -I SS_SPEC_WAN_AC -d $server -j RETURN - + fi - + ipset -N fplan hash:net 2>/dev/null for ip in $LAN_FP_IP; do ipset -! add fplan $ip ; done $IPT -I SS_SPEC_WAN_AC -m set --match-set fplan src -j SS_SPEC_WAN_FW - + ipset -N whitelist hash:net 2>/dev/null ipset -N blacklist hash:net 2>/dev/null $IPT -I SS_SPEC_WAN_AC -m set --match-set blacklist dst -j SS_SPEC_WAN_FW @@ -128,14 +128,14 @@ EOF fw_rule() { $IPT -N SS_SPEC_WAN_FW - $IPT -A SS_SPEC_WAN_FW -d 0.0.0.0/8 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 10.0.0.0/8 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 127.0.0.0/8 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 169.254.0.0/16 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 172.16.0.0/12 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 192.168.0.0/16 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 224.0.0.0/4 -j RETURN - $IPT -A SS_SPEC_WAN_FW -d 240.0.0.0/4 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 0.0.0.0/8 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 10.0.0.0/8 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 127.0.0.0/8 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 169.254.0.0/16 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 172.16.0.0/12 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 192.168.0.0/16 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 224.0.0.0/4 -j RETURN + $IPT -A SS_SPEC_WAN_FW -d 240.0.0.0/4 -j RETURN $IPT -A SS_SPEC_WAN_FW -p tcp $PROXY_PORTS \ -j REDIRECT --to-ports $local_port 2>/dev/null || { loger 3 "Can't redirect, please check the iptables." @@ -189,43 +189,42 @@ tp_rule() { local ipt="iptables -t mangle" $ipt -N SS_SPEC_TPROXY $ipt -A SS_SPEC_TPROXY -p udp --dport 53 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 0.0.0.0/8 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 10.0.0.0/8 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 127.0.0.0/8 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 169.254.0.0/16 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 172.16.0.0/12 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 192.168.0.0/16 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 224.0.0.0/4 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d 240.0.0.0/4 -j RETURN - $ipt -A SS_SPEC_TPROXY -p udp -d $SERVER -j RETURN - - $ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set fplan src \ + $ipt -A SS_SPEC_TPROXY -p udp -d 0.0.0.0/8 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 10.0.0.0/8 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 127.0.0.0/8 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 169.254.0.0/16 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 172.16.0.0/12 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 192.168.0.0/16 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 224.0.0.0/4 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d 240.0.0.0/4 -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp -d $SERVER -j RETURN + $ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set fplan src \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 - + if [ "$RUNMODE" = "router" ] ;then $ipt -A SS_SPEC_TPROXY -p udp -m set --match-set gmlan src -m set ! --match-set china dst \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 $ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set ! --match-set ss_spec_wan_ac dst \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 - + elif [ "$RUNMODE" = "gfw" ] ;then $ipt -A SS_SPEC_TPROXY -p udp -m set --match-set china dst -j RETURN $ipt -A SS_SPEC_TPROXY -p udp -m set --match-set gmlan src -m set ! --match-set china dst \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 $ipt -A SS_SPEC_TPROXY -p udp -m set $PROXY_PORTS --match-set gfwlist dst \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 - + elif [ "$RUNMODE" = "oversea" ] ;then $ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set china dst \ -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 - + elif [ "$RUNMODE" = "all" ] ;then $ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01 - fi - + fi + $ipt -I PREROUTING 1 ${IFNAME:+-i $IFNAME} -p udp $EXT_ARGS $MATCH_SET \ -m comment --comment "$TAG" -j SS_SPEC_TPROXY - + return $? } @@ -278,7 +277,7 @@ gen_spec_iplist() { 224.0.0.0/4 240.0.0.0/4 255.255.255.255 - $(get_wan_ip) + $(get_wan_ip) EOF } @@ -331,19 +330,19 @@ while getopts ":s:l:S:L:i:e:a:b:w:p:G:D:oOuUfgrczh" arg; do ;; p) LAN_FP_IP=$OPTARG - ;; + ;; G) LAN_GM_IP=$OPTARG - ;; + ;; D) PROXY_PORTS=$OPTARG - ;; + ;; o) OUTPUT=1 ;; O) OUTPUT=2 - ;; + ;; u) TPROXY=1 ;; @@ -355,13 +354,13 @@ while getopts ":s:l:S:L:i:e:a:b:w:p:G:D:oOuUfgrczh" arg; do ;; r) RUNMODE=router - ;; + ;; c) RUNMODE=oversea ;; z) RUNMODE=all - ;; + ;; f) flush_r exit 0 diff --git a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch index 9be20f019f..d5fc313d2e 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch +++ b/package/lean/luci-app-ssr-plus/root/usr/bin/ssr-switch @@ -35,31 +35,39 @@ CURRENT_SERVER=$DEFAULT_SERVER #判断代理是否正常 check_proxy() { -/usr/bin/ssr-check www.google.com 80 $switch_time 1 -if [ "$?" == "0" ]; then - return 0 -else - /usr/bin/ssr-check www.baidu.com 80 $switch_time 1 - if [ "$?" == "0" ]; then - #goole不通baidu通则不正常 - return 1 - else - return 2 - fi -fi -return 0 + local result=0 + local try_count=$(uci_get_by_type global switch_try_count 3) + for i in $(seq 1 $try_count) + do + /usr/bin/ssr-check www.google.com 80 $switch_time 1 + if [ "$?" == "0" ]; then + # echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Success, count=$i" >> /tmp/ssrplus.log + result=0 + break + else + # echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Fail, count=$i" >> /tmp/ssrplus.log + /usr/bin/ssr-check www.baidu.com 80 $switch_time 1 + if [ "$?" == "0" ]; then + result=1 + else + result=2 + fi + fi + sleep 1; + done + return $result; } test_proxy() { local servername=$(uci_get_by_name $1 server) local serverport=$(uci_get_by_name $1 server_port) -ret=$(ping -c 3 $servername | grep 'loss' | awk -F ',' '{ print $3 }' | awk -F "%" '{ print $1 }') +ret=$(ping -c 3 $servername | grep 'loss' | awk -F ',' '{ print $3 }' | awk -F "%" '{ print $1 }') [ -z "$ret" ] && return 1 [ "$ret" -gt "50" ] && return 1 ipset add ss_spec_wan_ac $servername 2>/dev/null ret=$? -/usr/bin/ssr-check $servername $serverport $switch_time +/usr/bin/ssr-check $servername $serverport $switch_time local ret2=$? if [ "$ret" = "0" ] ;then ipset del ss_spec_wan_ac $servername 2>/dev/null @@ -81,8 +89,8 @@ local servername=$(uci_get_by_name $1 server) local serverport=$(uci_get_by_name $1 server_port) ipset add ss_spec_wan_ac $servername 2>/dev/null ret=$? - /usr/bin/ssr-check $servername $serverport $switch_time - local ret2=$? +/usr/bin/ssr-check $servername $serverport $switch_time +local ret2=$? if [ "$ret" = "0" ] ;then ipset del ss_spec_wan_ac $servername 2>/dev/null fi @@ -117,58 +125,58 @@ start() { [ $(uci_get_by_name $DEFAULT_SERVER kcp_enable) = "1" ] && return 1 while [ "1" = "1" ] #死循环 -do - sleep $cycle_time - - LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") - - - #判断当前代理是否为缺省服务器 - if [ "$CURRENT_SERVER" != "$DEFAULT_SERVER" ] ;then - #echo "not default proxy" - echo "$(date "+%Y-%m-%d %H:%M:%S") Current server is not default Main server, try to switch back." >> /tmp/ssrplus.log +do + sleep $cycle_time - #检查缺省服务器是否正常 - if test_proxy $DEFAULT_SERVER ;then - #echo "switch to default proxy" - echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is avilable." >> /tmp/ssrplus.log - #缺省服务器正常,切换回来 - CURRENT_SERVER=$DEFAULT_SERVER - switch_proxy $CURRENT_SERVER - echo "$(date "+%Y-%m-%d %H:%M:%S") switch to default ["$(uci_get_by_name $CURRENT_SERVER server)"] proxy!" >> /tmp/ssrplus.log - continue - else - echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is NOT avilable.Continue using current server." >> /tmp/ssrplus.log - fi - fi + LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") - #判断当前代理是否正常 - check_proxy - current_ret=$? - - if [ "$current_ret" = "1" ] ;then - #当前代理错误,判断有无可用的服务器 - #echo "current error" - echo "$(date "+%Y-%m-%d %H:%M:%S") Current server error, try to switch another server." >> /tmp/ssrplus.log - - select_proxy - if [ "$ENABLE_SERVER" != nil ] ;then - #有其他服务器可用,进行切换 - #echo $(uci_get_by_name $new_proxy server) - echo "$(date "+%Y-%m-%d %H:%M:%S") Another server is avilable, now switching server." >> /tmp/ssrplus.log - CURRENT_SERVER=$ENABLE_SERVER - switch_proxy $CURRENT_SERVER - normal_flag=1 - echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR server switch OK" >> /tmp/ssrplus.log - else - switch_proxy $CURRENT_SERVER - normal_flag=1 - echo "$(date "+%Y-%m-%d %H:%M:%S") Try restart current server." >> /tmp/ssrplus.log - fi - else - normal_flag=0 - echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR No Problem." >> /tmp/ssrplus.log - fi + + #判断当前代理是否为缺省服务器 + if [ "$CURRENT_SERVER" != "$DEFAULT_SERVER" ] ;then + #echo "not default proxy" + echo "$(date "+%Y-%m-%d %H:%M:%S") Current server is not default Main server, try to switch back." >> /tmp/ssrplus.log + + #检查缺省服务器是否正常 + if test_proxy $DEFAULT_SERVER ;then + #echo "switch to default proxy" + echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is avilable." >> /tmp/ssrplus.log + #缺省服务器正常,切换回来 + CURRENT_SERVER=$DEFAULT_SERVER + switch_proxy $CURRENT_SERVER + echo "$(date "+%Y-%m-%d %H:%M:%S") switch to default ["$(uci_get_by_name $CURRENT_SERVER server)"] proxy!" >> /tmp/ssrplus.log + continue + else + echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is NOT avilable.Continue using current server." >> /tmp/ssrplus.log + fi + fi + + #判断当前代理是否正常 + check_proxy + current_ret=$? + + if [ "$current_ret" = "1" ] ;then + #当前代理错误,判断有无可用的服务器 + #echo "current error" + echo "$(date "+%Y-%m-%d %H:%M:%S") Current server error, try to switch another server." >> /tmp/ssrplus.log + + select_proxy + if [ "$ENABLE_SERVER" != nil ] ;then + #有其他服务器可用,进行切换 + #echo $(uci_get_by_name $new_proxy server) + echo "$(date "+%Y-%m-%d %H:%M:%S") Another server is avilable, now switching server." >> /tmp/ssrplus.log + CURRENT_SERVER=$ENABLE_SERVER + switch_proxy $CURRENT_SERVER + normal_flag=1 + echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR server switch OK" >> /tmp/ssrplus.log + else + switch_proxy $CURRENT_SERVER + normal_flag=1 + echo "$(date "+%Y-%m-%d %H:%M:%S") Try restart current server." >> /tmp/ssrplus.log + fi + else + normal_flag=0 + echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR No Problem." >> /tmp/ssrplus.log + fi done diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gentrojanconfig.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gentrojanconfig.lua index 9d85bc41d0..df7e19fc24 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gentrojanconfig.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gentrojanconfig.lua @@ -1,38 +1,38 @@ local ucursor = require "luci.model.uci".cursor() local json = require "luci.jsonc" local server_section = arg[1] -local proto = arg[2] +local proto = arg[2] local local_port = arg[3] local server = ucursor:get_all("shadowsocksr", server_section) local trojan = { - log_level = 3, - run_type = proto, - local_addr = "0.0.0.0", - local_port = tonumber(local_port), - remote_addr = server.server, - remote_port = tonumber(server.server_port), - udp_timeout = 60, - -- 传入连接 - password = {server.password}, - -- 传出连接 - ssl = { - verify = false, - verify_hostname = (server.tls == "1") and false or true, - cert = "", - ciper = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA", - sni = server.tls_host, - alpn = {"h2", "http/1.1"}, - curve = "", - reuse_session = true, - session_ticket = false, - }, - tcp = { - no_delay = true, - keep_alive = true, - fast_open = (server.fast_open == "1") and true or false, - fast_open_qlen = 20 - } + log_level = 3, + run_type = proto, + local_addr = "0.0.0.0", + local_port = tonumber(local_port), + remote_addr = server.server, + remote_port = tonumber(server.server_port), + udp_timeout = 60, + -- 传入连接 + password = {server.password}, + -- 传出连接 + ssl = { + verify = false, + verify_hostname = (server.tls == "1") and false or true, + cert = "", + ciper = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA", + sni = server.tls_host, + alpn = {"h2", "http/1.1"}, + curve = "", + reuse_session = true, + session_ticket = false, + }, + tcp = { + no_delay = true, + keep_alive = true, + fast_open = (server.fast_open == "1") and true or false, + fast_open_qlen = 20 + } } print(json.stringify(trojan, 1)) diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua index 85957e7143..0ea059a5e3 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/genv2config.lua @@ -1,95 +1,95 @@ local ucursor = require "luci.model.uci".cursor() local json = require "luci.jsonc" local server_section = arg[1] -local proto = arg[2] +local proto = arg[2] local local_port = arg[3] local server = ucursor:get_all("shadowsocksr", server_section) local v2ray = { - log = { - -- error = "/var/ssrplus.log", - loglevel = "warning" - }, - -- 传入连接 - inbound = { - port = local_port, - protocol = "dokodemo-door", - settings = { - network = proto, - followRedirect = true - }, - sniffing = { - enabled = true, - destOverride = { "http", "tls" } - } - }, - -- 传出连接 - outbound = { - protocol = "vmess", - settings = { - vnext = { - { - address = server.server, - port = tonumber(server.server_port), - users = { - { - id = server.vmess_id, - alterId = tonumber(server.alter_id), - security = server.security - } - } - } - } - }, - -- 底层传输配置 - streamSettings = { - network = server.transport, - security = (server.tls == '1') and "tls" or "none", - tlsSettings = {allowInsecure = (server.insecure == "1") and true or false,serverName=server.ws_host,}, - kcpSettings = (server.transport == "kcp") and { - mtu = tonumber(server.mtu), - tti = tonumber(server.tti), - uplinkCapacity = tonumber(server.uplink_capacity), - downlinkCapacity = tonumber(server.downlink_capacity), - congestion = (server.congestion == "1") and true or false, - readBufferSize = tonumber(server.read_buffer_size), - writeBufferSize = tonumber(server.write_buffer_size), - header = { - type = server.kcp_guise - } - } or nil, - wsSettings = (server.transport == "ws") and (server.ws_path ~= nil or server.ws_host ~= nil) and { - path = server.ws_path, - headers = (server.ws_host ~= nil) and { - Host = server.ws_host - } or nil, - } or nil, - httpSettings = (server.transport == "h2") and { - path = server.h2_path, - host = server.h2_host, - } or nil, - quicSettings = (server.transport == "quic") and { - security = server.quic_security, - key = server.quic_key, - header = { - type = server.quic_guise - } - } or nil - }, - mux = { - enabled = (server.mux == "1") and true or false, - concurrency = tonumber(server.concurrency) - } - }, +log = { + -- error = "/var/ssrplus.log", + loglevel = "warning" +}, + -- 传入连接 + inbound = { + port = local_port, + protocol = "dokodemo-door", + settings = { + network = proto, + followRedirect = true + }, + sniffing = { + enabled = true, + destOverride = { "http", "tls" } + } + }, + -- 传出连接 + outbound = { + protocol = "vmess", + settings = { + vnext = { + { + address = server.server, + port = tonumber(server.server_port), + users = { + { + id = server.vmess_id, + alterId = tonumber(server.alter_id), + security = server.security + } + } + } + } + }, + -- 底层传输配置 + streamSettings = { + network = server.transport, + security = (server.tls == '1') and "tls" or "none", + tlsSettings = {allowInsecure = (server.insecure == "1") and true or false,serverName=server.tls_host,}, + kcpSettings = (server.transport == "kcp") and { + mtu = tonumber(server.mtu), + tti = tonumber(server.tti), + uplinkCapacity = tonumber(server.uplink_capacity), + downlinkCapacity = tonumber(server.downlink_capacity), + congestion = (server.congestion == "1") and true or false, + readBufferSize = tonumber(server.read_buffer_size), + writeBufferSize = tonumber(server.write_buffer_size), + header = { + type = server.kcp_guise + } + } or nil, + wsSettings = (server.transport == "ws") and (server.ws_path ~= nil or server.ws_host ~= nil) and { + path = server.ws_path, + headers = (server.ws_host ~= nil) and { + Host = server.ws_host + } or nil, + } or nil, + httpSettings = (server.transport == "h2") and { + path = server.h2_path, + host = server.h2_host, + } or nil, + quicSettings = (server.transport == "quic") and { + security = server.quic_security, + key = server.quic_key, + header = { + type = server.quic_guise + } + } or nil + }, + mux = { + enabled = (server.mux == "1") and true or false, + concurrency = tonumber(server.concurrency) + } + }, - -- 额外传出连接 - outboundDetour = { - { - protocol = "freedom", - tag = "direct", - settings = { keep = "" } - } - } + -- 额外传出连接 + outboundDetour = { + { + protocol = "freedom", + tag = "direct", + settings = { keep = "" } + } + } } print(json.stringify(v2ray, 1)) diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua new file mode 100644 index 0000000000..8b9b759543 --- /dev/null +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -0,0 +1,365 @@ +#!/usr/bin/lua +------------------------------------------------ +-- This file is part of the luci-app-ssr-plus subscribe.lua +-- @author William Chan +------------------------------------------------ +require 'nixio' +require 'luci.util' +require 'luci.jsonc' +require 'luci.sys' + +-- these global functions are accessed all the time by the event handler +-- so caching them is worth the effort +local luci = luci +local tinsert = table.insert +local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string.char, string.byte, string.format, string.gsub +local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify +local b64decode = nixio.bin.b64decode +local cache = {} +local nodeResult = setmetatable({}, { __index = cache }) -- update result +local name = 'shadowsocksr' +local uciType = 'servers' +local ucic = luci.model.uci.cursor() +local proxy = ucic:get_first(name, 'server_subscribe', 'proxy', '0') +local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {}) + +local log = function(...) + print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " ")) +end +-- 分割字符串 +local function split(full, sep) + full = full:gsub("%z", "") -- 这里不是很清楚 有时候结尾带个\0 + local off, result = 1, {} + while true do + local nEnd = full:find(sep, off) + if not nEnd then + local res = ssub(full, off, slen(full)) + if #res > 0 then -- 过滤掉 \0 + tinsert(result, res) + end + break + else + tinsert(result, ssub(full, off, nEnd - 1)) + off = nEnd + slen(sep) + end + end + return result +end +-- urlencode +local function get_urlencode(c) + return sformat("%%%02X", sbyte(c)) +end + +local function urlEncode(szText) + local str = szText:gsub("([^0-9a-zA-Z ])", get_urlencode) + str = str:gsub(" ", "+") + return str +end + +local function get_urldecode(h) + return schar(tonumber(h, 16)) +end +local function UrlDecode(szText) + return szText:gsub("+", " "):gsub("%%(%x%x)", get_urldecode) +end + +-- trim +local function trim(text) + if not text or text == "" then + return "" + end + return (sgsub(text, "^%s*(.-)%s*$", "%1")) +end +-- md5 +local function md5(content) + local stdout = luci.sys.exec('echo \"' .. urlEncode(content) .. '\" | md5sum | cut -d \" \" -f1') + -- assert(nixio.errno() == 0) + return trim(stdout) +end +-- base64 +local function base64Decode(text) + local raw = text + if not text then return '' end + text = text:gsub("%z", "") + text = text:gsub("_", "/") + text = text:gsub("-", "+") + local mod4 = #text % 4 + text = text .. string.sub('====', mod4 + 1) + local result = b64decode(text) + if result then + return result:gsub("%z", "") + else + return raw + end +end +-- 处理数据 +local function processData(szType, content) + local result = { + auth_enable = '0', + switch_enable = '1', + type = szType, + local_port = 1234, + timeout = 60, -- 不太确定 好像是死的 + fast_open = 0, + kcp_enable = 0, + kcp_port = 0, + kcp_param = '--nocomp' + } + result.hashkey = type(content) == 'string' and md5(content) or md5(jsonStringify(content)) + if szType == 'ssr' then + local dat = split(content, "/\\?") + local hostInfo = split(dat[1], ':') + result.server = hostInfo[1] + result.server_port = hostInfo[2] + result.protocol = hostInfo[3] + result.encrypt_method = hostInfo[4] + result.obfs = hostInfo[5] + result.password = base64Decode(hostInfo[6]) + local params = {} + for _, v in pairs(split(dat[2], '&')) do + local t = split(v, '=') + params[t[1]] = t[2] + end + result.obfs_param = base64Decode(params.bfsparam) + result.protocol_param = base64Decode(params.protoparam) + local group = base64Decode(params.group) + if group then + result.alias = "[" .. group .. "] " + end + result.alias = result.alias .. base64Decode(params.remarks) + elseif szType == 'vmess' then + local info = jsonParse(content) + result.type = 'v2ray' + result.server = info.add + result.server_port = info.port + result.transport = info.net + result.alter_id = info.aid + result.vmess_id = info.id + result.alias = info.ps + result.mux = 1 + result.concurrency = 8 + if info.net == 'ws' then + result.ws_host = info.host + result.ws_path = info.path + end + if info.net == 'h2' then + result.h2_host = info.host + result.h2_path = info.path + end + if info.net == 'tcp' then + result.tcp_guise = info.type + result.http_host = info.host + result.http_path = info.path + end + if info.net == 'kcp' then + result.kcp_guise = info.type + result.mtu = 1350 + result.tti = 50 + result.uplink_capacity = 5 + result.downlink_capacity = 20 + result.read_buffer_size = 2 + result.write_buffer_size = 2 + end + if info.net == 'quic' then + result.quic_guise = info.type + result.quic_key = info.key + result.quic_security = info.securty + end + if not info.security then + result.security = "auto" + end + if info.tls == "tls" or info.tls == "1" then + result.tls = "1" + result.tls_host = info.host + else + result.tls = "0" + end + elseif szType == "ss" then + local idx_sp = 0 + local alias = "" + if content:find("#") then + idx_sp = content:find("#") + alias = content:sub(idx_sp + 1, -1) + end + local info = content:sub(1, idx_sp - 1) + local hostInfo = split(base64Decode(info), "@") + local host = split(hostInfo[2], ":") + local userinfo = base64Decode(hostInfo[1]) + local method = userinfo:sub(1, userinfo:find(":") - 1) + local password = userinfo:sub(userinfo:find(":") + 1, #userinfo) + result.alias = UrlDecode(alias) + result.type = "ss" + result.server = host[1] + if host[2]:find("/\\?") then + local query = split(host[2], "/\\?") + result.server_port = query[1] + -- local params = {} + -- for _, v in pairs(split(query[2], '&')) do + -- local t = split(v, '=') + -- params[t[1]] = t[2] + -- end + -- 这里似乎没什么用 我看数据结构没有写插件的支持 先抛弃 + else + result.server_port = host[2] + end + result.encrypt_method_ss = method + result.password = password + elseif szType == "ssd" then + result.type = "ss" + result.server = content.server + result.server_port = content.port + result.password = content.password + result.encrypt_method_ss = content.encryption + result.alias = "[" .. content.airport .. "] " .. content.remarks + end + if not result.alias then + result.alias = result.server .. ':' .. result.server_port + end + return result +end +-- wget +local function wget(url) + local stdout = luci.sys.exec('wget-ssl --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" --no-check-certificate -t 3 -T 10 -O- "' .. url .. '"') + return trim(stdout) +end + +local execute = function() + -- exec + do + if proxy == '0' then -- 不使用代理更新的话先暂停 + log('服务正在暂停') + luci.sys.init.stop(name) + end + for k, url in ipairs(subscribe_url) do + local raw = wget(url) + if #raw > 0 then + local nodes, szType + local groupHash = md5(url) + cache[groupHash] = {} + tinsert(nodeResult, {}) + local index = #nodeResult + -- SSD 似乎是这种格式 ssd:// 开头的 + if raw:find('ssd://') then + szType = 'ssd' + local nEnd = select(2, raw:find('ssd://')) + nodes = base64Decode(raw:sub(nEnd + 1, #raw)) + nodes = jsonParse(nodes) + local extra = { + airport = nodes.airport, + port = nodes.port, + encryption = nodes.encryption, + password = nodes.password + } + local servers = {} + -- SS里面包着 干脆直接这样 + for _, server in ipairs(nodes.servers) do + tinsert(servers, setmetatable(server, { __index = extra })) + end + nodes = servers + else + -- ssd 外的格式 + nodes = split(base64Decode(raw):gsub(" ", "\n"), "\n") + end + for _, v in ipairs(nodes) do + if v then + local result + if szType == 'ssd' then + result = processData(szType, v) + elseif not szType then + local node = trim(v) + local dat = split(node, "://") + if dat and dat[1] and dat[2] then + if dat[1] == 'ss' then + result = processData(dat[1], dat[2]) + else + result = processData(dat[1], base64Decode(dat[2])) + end + end + else + log('跳过未知类型: ' .. szType) + end + -- log(result) + if result then + if result.alias:find("过期时间") or + result.alias:find("剩余流量") or + result.alias:find("QQ群") or + result.alias:find("官网") or + not result.server + then + log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias) + else + log('成功解析: ' .. result.type ..' 节点, ' .. result.alias) + result.grouphashkey = groupHash + tinsert(nodeResult[index], result) + cache[groupHash][result.hashkey] = nodeResult[index][#nodeResult[index]] + end + end + end + end + log('成功解析节点数量: ' ..#nodes) + end + end + end + -- diff + do + assert(next(nodeResult), "node result is empty") + local add, del = 0, 0 + ucic:foreach(name, uciType, function(old) + if old.grouphashkey or old.hashkey then -- 没有 hash 的不参与删除 + if not nodeResult[old.grouphashkey] or not nodeResult[old.grouphashkey][old.hashkey] then + ucic:delete(name, old['.name']) + del = del + 1 + else + local dat = nodeResult[old.grouphashkey][old.hashkey] + ucic:tset(name, old['.name'], dat) + -- 标记一下 + setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } }) + end + else + log('忽略手动添加的节点: ' .. old.alias) + end + end) + for k, v in ipairs(nodeResult) do + for kk, vv in ipairs(v) do + if not vv._ignore then + local section = ucic:add(name, uciType) + ucic:tset(name, section, vv) + add = add + 1 + end + + end + end + ucic:commit(name) + -- 如果服务器已经不见了把帮换一个 + local globalServer = ucic:get_first(name, 'global', 'global_server', '') + local firstServer = ucic:get_first(name, uciType) + if not ucic:get(name, globalServer) then + if firstServer then + ucic:set(name, ucic:get_first(name, 'global'), 'global_server', firstServer) + ucic:commit(name) + log('当前主服务器已更新,正在自动更换。') + end + end + if firstServer then + luci.sys.call("/etc/init.d/" .. name .. " restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 + else + luci.sys.call("/etc/init.d/" .. name .. " stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 + end + log('新增节点数量: ' ..add, '删除节点数量: ' .. del) + log('更新成功服务正在启动') + end +end + +if subscribe_url and #subscribe_url > 0 then + xpcall(execute, function(e) + log(e) + log(debug.traceback()) + log('发生错误, 正在恢复服务') + local firstServer = ucic:get_first(name, uciType) + if firstServer then + luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 + else + luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早 + end + end) +end diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.sh b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.sh deleted file mode 100755 index 4323a46893..0000000000 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/bin/bash -# Copyright (C) 2017 XiaoShan https://www.mivm.cn - -. /usr/share/libubox/jshn.sh - -urlsafe_b64decode() { - local d="====" data=$(echo $1 | sed 's/_/\//g; s/-/+/g') - local mod4=$((${#data}%4)) - [ $mod4 -gt 0 ] && data=${data}${d:mod4} - echo $data | base64 -d -} - -urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } - -echo_date(){ - echo $(TZ=UTC-8 date -R +%Y-%m-%d\ %X):$1 -} - -Server_Update() { - local uci_set="uci -q set $name.$1." - ${uci_set}grouphashkey="$ssr_grouphashkey" - ${uci_set}hashkey="$ssr_hashkey" - ${uci_set}alias="[$ssr_group] $ssr_remarks" - ${uci_set}auth_enable="0" - ${uci_set}switch_enable="1" - ${uci_set}type="$ssr_type" - ${uci_set}server="$ssr_host" - ${uci_set}server_port="$ssr_port" - ${uci_set}local_port="1234" - uci -q get $name.@servers[$1].timeout >/dev/null || ${uci_set}timeout="60" - ${uci_set}password="$ssr_passwd" - ${uci_set}encrypt_method="$ssr_method" - ${uci_set}protocol="$ssr_protocol" - ${uci_set}protocol_param="$ssr_protoparam" - ${uci_set}obfs="$ssr_obfs" - ${uci_set}obfs_param="$ssr_obfsparam" - ${uci_set}fast_open="0" - ${uci_set}kcp_enable="0" - ${uci_set}kcp_port="0" - ${uci_set}kcp_param="--nocomp" - - if [ "$ssr_type" = "v2ray" ]; then - #v2ray - ${uci_set}alter_id="$ssr_alter_id" - ${uci_set}vmess_id="$ssr_vmess_id" - ${uci_set}transport="$ssr_transport" - ${uci_set}tcp_guise="$ssr_tcp_guise" - ${uci_set}ws_host="$ssr_ws_host" - ${uci_set}ws_path="$ssr_ws_path" - ${uci_set}h2_host="$ssr_h2_host" - ${uci_set}h2_path="$ssr_h2_path" - ${uci_set}tls="$ssr_tls" - ${uci_set}security=$ssr_security - ${uci_set}alias="$ssr_remarks" - fi - - if [ "$ssr_type" = "ss" ]; then - ${uci_set}encrypt_method_ss="$ss_method" - ${uci_set}alias="$ssr_remarks" - fi - -} - -name=shadowsocksr -subscribe_url=($(uci get $name.@server_subscribe[0].subscribe_url)) #订阅服务器地址 -[ ${#subscribe_url[@]} -eq 0 ] && exit 1 -[ $(uci -q get $name.@server_subscribe[0].proxy || echo 0) -eq 0 ] && /etc/init.d/$name stop >/dev/null 2>&1 -log_name=${name}_subscribe -for ((o=0;o<${#subscribe_url[@]};o++)) -do - echo_date "从 ${subscribe_url[o]} 获取订阅" - echo_date "开始更新在线订阅列表..." - echo_date "尝试下载订阅链接到本地临时文件,请稍等..." - subscribe_data=$(wget-ssl --no-check-certificate -t 3 -T 30 -O- ${subscribe_url[o]}) - curl_code=$? - # 计算group的hashkey - ssr_grouphashkey=$(echo "${subscribe_url[o]}" | md5sum | cut -d ' ' -f1) - if [ ! $curl_code -eq 0 ];then - echo_date "下载订阅失败,自动重试中..." - subscribe_data=$(wget-ssl --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" --no-check-certificate -t 3 -T 30 -O- ${subscribe_url[o]}) - curl_code=$? - fi - if [ $curl_code -eq 0 ];then - echo_date "下载订阅成功,开始解析节点信息..." - ssr_url=($(echo $subscribe_data | base64 -d | sed 's/\r//g')) # 解码数据并删除 \r 换行符 - subscribe_max=$(echo ${ssr_url[0]} | grep -i MAX= | awk -F = '{print $2}') - subscribe_max_x=() - if [ -n "$subscribe_max" ]; then - while [ ${#subscribe_max_x[@]} -ne $subscribe_max ] - do - if [ ${#ssr_url[@]} -ge 10 ]; then - if [ $((${RANDOM:0:2}%2)) -eq 0 ]; then - temp_x=${RANDOM:0:1} - else - temp_x=${RANDOM:0:2} - fi - else - temp_x=${RANDOM:0:1} - fi - [ $temp_x -lt ${#ssr_url[@]} -a -z "$(echo "${subscribe_max_x[*]}" | grep -w $temp_x)" ] && subscribe_max_x[${#subscribe_max_x[@]}]="$temp_x" - done - else - subscribe_max=${#ssr_url[@]} - fi - echo_date "共计$subscribe_max个节点" - - ssr_group=$(urlsafe_b64decode $(urlsafe_b64decode ${ssr_url[$((${#ssr_url[@]} - 1))]//ssr:\/\//} | sed 's/&/\n/g' | grep group= | awk -F = '{print $2}')) - if [ -z "$ssr_group" ]; then - ssr_group="default" - fi - if [ -n "$ssr_group" ]; then - subscribe_i=0 - subscribe_n=0 - subscribe_o=0 - subscribe_x="" - temp_host_o=() - curr_ssr=$(uci show $name | grep @servers | grep -c server=) - for ((x=0;x<$curr_ssr;x++)) # 循环已有服务器信息,匹配当前订阅群组 - do - temp_alias=$(uci -q get $name.@servers[$x].grouphashkey | grep "$ssr_grouphashkey") - [ -n "$temp_alias" ] && temp_host_o[${#temp_host_o[@]}]=$(uci get $name.@servers[$x].hashkey) - done - - for ((x=0;x<$subscribe_max;x++)) # 循环链接 - do - [ ${#subscribe_max_x[@]} -eq 0 ] && temp_x=$x || temp_x=${subscribe_max_x[x]} - result=$(echo ${ssr_url[temp_x]} | grep "ss") - subscribe_url_type=$(echo "$ssr_url" | awk -F ':' '{print $1}') - - if [ "$subscribe_url_type" = "ss" ]; then - temp_info=${ssr_url[temp_x]//ss:\/\//} # 解码 SS 链接 - # 计算hashkey - ssr_hashkey=$(echo "$temp_info" | md5sum | cut -d ' ' -f1) - - info=$(urlsafe_b64decode $(echo "$temp_info" | awk -F '@' '{print $1}')) - temp_info_array=(${info//:/ }) - ssr_type="ss" - ss_method=${temp_info_array[0]} - ssr_passwd=${temp_info_array[1]} - info=$(echo "$temp_info" | awk -F '@' '{print $2}' | awk -F '#' '{print $1}') - temp_info_array=(${info//:/ }) - ssr_host=${temp_info_array[0]} - ssr_port=${temp_info_array[1]} - ssr_remarks=$(urldecode $(echo "$temp_info" | awk -F '#' '{print $2}')) - fi - - if [ "$subscribe_url_type" = "ssr" ]; then - temp_info=$(urlsafe_b64decode ${ssr_url[temp_x]//ssr:\/\//}) # 解码 SSR 链接 - # 计算hashkey - ssr_hashkey=$(echo "$temp_info" | md5sum | cut -d ' ' -f1) - - info=${temp_info///?*/} - temp_info_array=(${info//:/ }) - ssr_type="ssr" - ssr_host=${temp_info_array[0]} - ssr_port=${temp_info_array[1]} - ssr_protocol=${temp_info_array[2]} - ssr_method=${temp_info_array[3]} - ssr_obfs=${temp_info_array[4]} - ssr_passwd=$(urlsafe_b64decode ${temp_info_array[5]}) - info=${temp_info:$((${#info} + 2))} - info=(${info//&/ }) - ssr_protoparam="" - ssr_obfsparam="" - ssr_remarks="$temp_x" - for ((i=0;i<${#info[@]};i++)) # 循环扩展信息 - do - temp_info=($(echo ${info[i]} | sed 's/=/ /g')) - case "${temp_info[0]}" in - protoparam) - ssr_protoparam=$(urlsafe_b64decode ${temp_info[1]});; - obfsparam) - ssr_obfsparam=$(urlsafe_b64decode ${temp_info[1]});; - remarks) - ssr_remarks=$(urlsafe_b64decode ${temp_info[1]});; - esac - done - fi - - if [ "$subscribe_url_type" = "vmess" ]; then - temp_info=$(urlsafe_b64decode ${ssr_url[temp_x]//vmess:\/\//}) # 解码 Vmess 链接 - # 计算hashkey - ssr_hashkey=$(echo "$temp_info" | md5sum | cut -d ' ' -f1) - - ssr_type="v2ray" - json_load "$temp_info" - json_get_var ssr_host add - json_get_var ssr_port port - json_get_var ssr_alter_id aid - json_get_var ssr_vmess_id id - json_get_var ssr_security security - if [ "$ssr_security" == "" ]; then - ssr_security="auto" - fi - json_get_var ssr_transport net - json_get_var ssr_remarks ps - ssr_tcp_guise="none" - json_get_var ssr_ws_host host - json_get_var ssr_ws_path path - json_get_var ssr_h2_host host - json_get_var ssr_h2_path path - json_get_var ssr_tls tls - if [ "$ssr_tls" == "tls" -o "$ssr_tls" == "1" ]; then - ssr_tls="1" - else - ssr_tls="0" - fi - fi - - if [ -z "ssr_remarks" ]; then # 没有备注的话则生成一个 - ssr_remarks="$ssr_host:$ssr_port"; - fi - - uci_name_tmp=$(uci show $name | grep -w "$ssr_hashkey" | awk -F . '{print $2}') - if [ -z "$uci_name_tmp" ]; then # 判断当前服务器信息是否存在 - uci_name_tmp=$(uci add $name servers) - subscribe_n=$(($subscribe_n + 1)) - fi - Server_Update $uci_name_tmp - subscribe_x=$subscribe_x$ssr_hashkey" " - ssrtype=$(echo $ssr_type | tr '[a-z]' '[A-Z]') - echo_date "$ssrtype节点:【$ssr_remarks】" - - # SSR - # echo "服务器地址: $ssr_host" - # echo "服务器端口 $ssr_port" - # echo "密码: $ssr_passwd" - # echo "SS加密: $ss_method" - # echo "加密: $ssr_method" - # echo "协议: $ssr_protocol" - # echo "协议参数: $ssr_protoparam" - # echo "混淆: $ssr_obfs" - # echo "混淆参数: $ssr_obfsparam" - # echo "备注: $ssr_remarks" - - done - for ((x=0;x<${#temp_host_o[@]};x++)) # 新旧服务器信息匹配,如果旧服务器信息不存在于新服务器信息则删除 - do - if [ -z "$(echo "$subscribe_x" | grep -w ${temp_host_o[x]})" ]; then - uci_name_tmp=$(uci show $name | grep ${temp_host_o[x]} | awk -F . '{print $2}') - uci delete $name.$uci_name_tmp - subscribe_o=$(($subscribe_o + 1)) - fi - done - echo_date "本次更新订阅来源 【$ssr_group】 服务器数量: ${#ssr_url[@]} 新增服务器: $subscribe_n 删除服务器: $subscribe_o" - echo_date "在线订阅列表更新完成!请等待网页自动刷新!" - subscribe_log="$ssr_group 服务器订阅更新成功 服务器数量: ${#ssr_url[@]} 新增服务器: $subscribe_n 删除服务器: $subscribe_o" - logger -st $log_name[$$] -p6 "$subscribe_log" - uci commit $name - else - echo_date "${subscribe_url[$o]} 订阅数据解析失败 无法获取 Group" - logger -st $log_name[$$] -p3 "${subscribe_url[$o]} 订阅数据解析失败 无法获取 Group" - fi - else - echo_date "${subscribe_url[$o]} 订阅数据获取失败 错误代码: $curl_code" - logger -st $log_name[$$] -p3 "${subscribe_url[$o]} 订阅数据获取失败 错误代码: $curl_code" - fi -done -/etc/init.d/$name restart >/dev/null 2>&1 diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua new file mode 100644 index 0000000000..9f62522abd --- /dev/null +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua @@ -0,0 +1,107 @@ +#!/usr/bin/lua +------------------------------------------------ +-- This file is part of the luci-app-ssr-plus update.lua +-- By Mattraks +------------------------------------------------ +require 'nixio' +require 'luci.util' +require 'luci.jsonc' +require 'luci.sys' +local icount =0 +local ucic = luci.model.uci.cursor() + +local log = function(...) + print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " ")) +end + +log('正在更新【GFW列表】数据库') +if nixio.fs.access("/usr/bin/wget-ssl") then + refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64" + else + refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64" + end + sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") + if sret== 0 then + luci.sys.call("/usr/bin/ssr-gfw") + icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l") + if tonumber(icount)>1000 then + oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l") + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf") +-- retstring=tostring(math.ceil(tonumber(icount)/2)) + log('更新成功! 新的总纪录数:'.. icount) + else + log('你已经是最新数据,无需更新!') + end + else + log('更新失败!') + end + luci.sys.exec("rm -f /tmp/gfwnew.txt") +else + log('更新失败!') +end + +log('正在更新【国内IP段】数据库') +refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt" +sret=luci.sys.call(refresh_cmd) +icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l") + if sret== 0 then + icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l") + if tonumber(icount)>1000 then + oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l") + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt") +-- retstring=tostring(math.ceil(tonumber(icount)/2)) + log('更新成功! 新的总纪录数:'.. icount) + else + log('你已经是最新数据,无需更新!') + end + else + log('更新失败!') + end + luci.sys.exec("rm -f /tmp/china_ssr.txt") +else + log('更新失败!') +end + +-- --[[ +if ucic:get_first('shadowsocksr', 'global', 'adblock', '') == '1' then +log('正在更新【广告屏蔽】数据库') + local need_process = 0 + if nixio.fs.access("/usr/bin/wget-ssl") then + refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf" + need_process = 1 +else + refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf" +end +sret=luci.sys.call(refresh_cmd .. " 2>/dev/null") +if sret== 0 then + if need_process == 1 then + luci.sys.call("/usr/bin/ssr-ad") + end + icount = luci.sys.exec("cat /tmp/ad.conf | wc -l") + if tonumber(icount)>1000 then + if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then + oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l") + else + oldcount=0 + end + if tonumber(icount) ~= tonumber(oldcount) then + luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf") +-- retstring=tostring(math.ceil(tonumber(icount))) + if oldcount==0 then + luci.sys.call("/etc/init.d/dnsmasq restart") + end + log('更新成功! 新的总纪录数:'.. icount) + else + log('你已经是最新数据,无需更新!') + end + else + log('更新失败!') + end + luci.sys.exec("rm -f /tmp/ad.conf") +else + log('更新失败!') +end +end +-- --]] diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.sh b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.sh deleted file mode 100755 index d7fb68567f..0000000000 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -chnroute_data=$(wget -O- -t 3 -T 3 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest) -[ $? -eq 0 ] && { - echo "$chnroute_data" | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt -} - -if [ -s "/tmp/china_ssr.txt" ];then - if ( ! cmp -s /tmp/china_ssr.txt /etc/china_ssr.txt );then - mv /tmp/china_ssr.txt /etc/china_ssr.txt - fi -fi - -/usr/share/shadowsocksr/chinaipset.sh - -wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64 -/usr/bin/ssr-gfw - -if [ -s "/tmp/gfwnew.txt" ];then - if ( ! cmp -s /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf );then - mv /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf - echo "copy" - fi -fi - -/etc/init.d/shadowsocksr restart diff --git a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua index 31a99999c3..54655ef483 100644 --- a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua +++ b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua @@ -15,13 +15,23 @@ if server.protocol == "vmess" then } } } +elseif server.protocol == "http" then + proset = { + allowTransparent = false, + accounts = { + { + user = (server.Http_user == nil) and "lean" or server.Http_user, + pass = (server.Http_pass == nil) and "password" or server.Http_pass + } + } + } else proset = { auth = "password", accounts = { { - user = server.Socks_user, - pass = server.Socks_pass + user = (server.Socks_user == nil) and "lean" or server.Socks_user, + pass = (server.Socks_pass == nil) and "password" or server.Socks_pass } } } @@ -33,12 +43,12 @@ local v2ray = { --error = "/var/log/v2ray.log", loglevel = "warning" }, - -- + -- 传入连接 inbound = { port = tonumber(server.port), protocol = server.protocol, settings = proset, - -- ײ㴫 + -- 底层传输配置 streamSettings = { network = server.transport, security = (server.tls == '1') and "tls" or "none", @@ -67,11 +77,11 @@ local v2ray = { } or nil } }, - -- + -- 传出连接 outbound = { protocol = "freedom" }, - -- ⴫ + -- 额外传出连接 outboundDetour = { { protocol = "blackhole", diff --git a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua index ddfaa4bb9f..3c7d8a595a 100644 --- a/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua +++ b/package/lean/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua @@ -32,6 +32,7 @@ e.default=10086 e=t:option(ListValue,"protocol",translate("Protocol")) e:value("vmess",translate("Vmess")) e:value("socks",translate("Socks")) +e:value("http",translate("Http")) e=t:option(Value,"VMess_id",translate("ID")) e.default=luci.sys.exec("cat /proc/sys/kernel/random/uuid") @@ -54,6 +55,17 @@ e.rmempty=true e.password=true e:depends("protocol","socks") +e=t:option(Value,"Http_user",translate("User name")) +e.default="lean" +e.rmempty=true +e:depends("protocol","http") + +e=t:option(Value,"Http_pass",translate("Password")) +e.default="password" +e.rmempty=true +e.password=true +e:depends("protocol","http") + e=t:option(Value,"VMess_level",translate("User Level")) e.default=1 diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/Makefile b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/Makefile deleted file mode 100644 index ec8cd0bf40..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2018-2019 Lienol -# -# This is free software, licensed under the Apache License, Version 2.0 . -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=LuCI support for V2ray Server -LUCI_DEPENDS:=+v2ray -LUCI_PKGARCH:=all -PKG_VERSION:=1.0 -PKG_RELEASE:=6 - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature - - diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/controller/v2ray_server.lua b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/controller/v2ray_server.lua deleted file mode 100644 index 5ca8c3d279..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/controller/v2ray_server.lua +++ /dev/null @@ -1,47 +0,0 @@ -module("luci.controller.v2ray_server",package.seeall) -local http = require "luci.http" -local v2ray = require "luci.model.cbi.v2ray_server.api.v2ray" - -function index() - if not nixio.fs.access("/etc/config/v2ray_server")then - return - end - entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false - entry({"admin","vpn","v2ray_server"},cbi("v2ray_server/index"),_("V2ray Server"),3).dependent=true - entry({"admin","vpn","v2ray_server","config"},cbi("v2ray_server/config")).leaf=true - - entry({"admin","vpn","v2ray_server","users_status"},call("v2ray_users_status")).leaf=true - entry({"admin", "vpn", "v2ray_server", "check"}, call("v2ray_check")).leaf = true - entry({"admin", "vpn", "v2ray_server", "update"}, call("v2ray_update")).leaf = true -end - -local function http_write_json(content) - http.prepare_content("application/json") - http.write_json(content or { code = 1 }) -end - -function v2ray_users_status() - local e={} - e.index=luci.http.formvalue("index") - e.status=luci.sys.call("ps -w| grep -v grep | grep '/var/etc/v2ray_server/" .. luci.http.formvalue("id") .. "' >/dev/null")==0 - http_write_json(e) -end - -function v2ray_check() - local json = v2ray.to_check("") - http_write_json(json) -end - -function v2ray_update() - local json = nil - local task = http.formvalue("task") - if task == "extract" then - json = v2ray.to_extract(http.formvalue("file"), http.formvalue("subfix")) - elseif task == "move" then - json = v2ray.to_move(http.formvalue("file")) - else - json = v2ray.to_download(http.formvalue("url")) - end - - http_write_json(json) -end \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua deleted file mode 100644 index 31a99999c3..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/genv2rayconfig.lua +++ /dev/null @@ -1,82 +0,0 @@ -local ucursor = require "luci.model.uci".cursor() -local json = require "luci.jsonc" -local server_section = arg[1] -local server = ucursor:get_all("v2ray_server", server_section) - -local proset - -if server.protocol == "vmess" then - proset = { - clients = { - { - id = server.VMess_id, - alterId = tonumber(server.VMess_alterId), - level = tonumber(server.VMess_level) - } - } - } -else - proset = { - auth = "password", - accounts = { - { - user = server.Socks_user, - pass = server.Socks_pass - } - } - } -end - - -local v2ray = { - log = { - --error = "/var/log/v2ray.log", - loglevel = "warning" - }, - -- - inbound = { - port = tonumber(server.port), - protocol = server.protocol, - settings = proset, - -- ײ㴫 - streamSettings = { - network = server.transport, - security = (server.tls == '1') and "tls" or "none", - kcpSettings = (server.transport == "mkcp") and { - mtu = tonumber(server.mkcp_mtu), - tti = tonumber(server.mkcp_tti), - uplinkCapacity = tonumber(server.mkcp_uplinkCapacity), - downlinkCapacity = tonumber(server.mkcp_downlinkCapacity), - congestion = (server.mkcp_congestion == "1") and true or false, - readBufferSize = tonumber(server.mkcp_readBufferSize), - writeBufferSize = tonumber(server.mkcp_writeBufferSize), - header = { - type = server.mkcp_guise - } - } or nil, - httpSettings = (server.transport == "h2") and { - path = server.h2_path, - host = server.h2_host, - } or nil, - quicSettings = (server.transport == "quic") and { - security = server.quic_security, - key = server.quic_key, - header = { - type = server.quic_guise - } - } or nil - } - }, - -- - outbound = { - protocol = "freedom" - }, - -- ⴫ - outboundDetour = { - { - protocol = "blackhole", - tag = "blocked" - } - } -} -print(json.stringify(v2ray,1)) \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/v2ray.lua b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/v2ray.lua deleted file mode 100644 index d7500b4584..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/api/v2ray.lua +++ /dev/null @@ -1,321 +0,0 @@ --- Copyright 2018 Lienol --- Licensed to the public under the Apache License 2.0. - -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() -local util = require "luci.util" -local i18n = require "luci.i18n" - -module("luci.model.cbi.v2ray_server.api.v2ray", package.seeall) - -local v2ray_api = "https://api.github.com/repos/v2ray/v2ray-core/releases/latest" - -local wget = "/usr/bin/wget" -local wget_args = { "--no-check-certificate", "--quiet", "--timeout=10", "--tries=2" } -local curl = "/usr/bin/curl" -local command_timeout = 40 - -local function _unpack(t, i) - i = i or 1 - if t[i] ~= nil then - return t[i], _unpack(t, i + 1) - end -end - -local function exec(cmd, args, writer, timeout) - local os = require "os" - local nixio = require "nixio" - - local fdi, fdo = nixio.pipe() - local pid = nixio.fork() - - if pid > 0 then - fdo:close() - - if writer or timeout then - local starttime = os.time() - while true do - if timeout and os.difftime(os.time(), starttime) >= timeout then - nixio.kill(pid, nixio.const.SIGTERM) - return 1 - end - - if writer then - local buffer = fdi:read(2048) - if buffer and #buffer > 0 then - writer(buffer) - end - end - - local wpid, stat, code = nixio.waitpid(pid, "nohang") - - if wpid and stat == "exited" then - return code - end - - if not writer and timeout then - nixio.nanosleep(1) - end - end - else - local wpid, stat, code = nixio.waitpid(pid) - return wpid and stat == "exited" and code - end - elseif pid == 0 then - nixio.dup(fdo, nixio.stdout) - fdi:close() - fdo:close() - nixio.exece(cmd, args, nil) - nixio.stdout:close() - os.exit(1) - end -end - -local function compare_versions(ver1, comp, ver2) - local table = table - - local av1 = util.split(ver1, "[%.%-]", nil, true) - local av2 = util.split(ver2, "[%.%-]", nil, true) - - local max = table.getn(av1) - local n2 = table.getn(av2) - if (max < n2) then - max = n2 - end - - for i = 1, max, 1 do - local s1 = av1[i] or "" - local s2 = av2[i] or "" - - if comp == "~=" and (s1 ~= s2) then return true end - if (comp == "<" or comp == "<=") and (s1 < s2) then return true end - if (comp == ">" or comp == ">=") and (s1 > s2) then return true end - if (s1 ~= s2) then return false end - end - - return not (comp == "<" or comp == ">") -end - -local function auto_get_arch() - local arch = nixio.uname().machine or "" - - if arch == "mips" then - if fs.access("/usr/lib/os-release") then - arch = sys.exec("grep 'LEDE_BOARD' /usr/lib/os-release | grep -oE 'ramips|ar71xx'") - elseif fs.access("/etc/openwrt_release") then - arch = sys.exec("grep 'DISTRIB_TARGET' /etc/openwrt_release | grep -oE 'ramips|ar71xx'") - end - end - - return util.trim(arch) -end - -local function get_file_info(arch) - local file_tree = "" - local sub_version = "" - - if arch == "x86_64" then - file_tree = "64" - elseif arch == "ramips" then - file_tree = "mipsle" - elseif arch == "ar71xx" then - file_tree = "mips" - elseif arch:match("^i[%d]86$") then - file_tree = "32" - elseif arch:match("^armv[5-8]") then - file_tree = "arm" - sub_version = arch:match("[5-8]") - end - - return file_tree, sub_version -end - -local function get_api_json(url) - local jsonc = require "luci.jsonc" - - local output = { } - --exec(wget, { "-O-", url, _unpack(wget_args) }, - -- function(chunk) output[#output + 1] = chunk end) - --local json_content = util.trim(table.concat(output)) - - local json_content = luci.sys.exec(curl.." -sL "..url) - - if json_content == "" then - return { } - end - - return jsonc.parse(json_content) or { } -end - -function get_config_option(option, default) - return uci:get("v2ray", "general", option) or default -end - -function get_current_log_file(type) - local log_folder = get_config_option("log_folder", "/var/log/v2ray") - return "%s/%s.%s.log" % { log_folder, type, "general" } -end - -function is_running(client) - if client and client ~= "" then - local file_name = client:match(".*/([^/]+)$") or "" - if file_name ~= "" then - return sys.call("pidof %s >/dev/null" % file_name) == 0 - end - end - - return false -end - -function get_v2ray_version() - return luci.sys.exec("/usr/bin/v2ray/v2ray -version | awk '{print $2}' | sed -n 1P") -end - -function to_check(arch) - if not arch or arch == "" then - arch = auto_get_arch() - end - - local file_tree, sub_version = get_file_info(arch) - - if file_tree == "" then - return { - code = 1, - error = i18n.translate("Can't determine ARCH, or ARCH not supported. Please select manually.") - } - end - - local json = get_api_json(v2ray_api) - - if json.tag_name == nil then - return { - code = 1, - error = i18n.translate("Get remote version info failed.") - } - end - - local remote_version = json.tag_name:match("[^v]+") - local needs_update = compare_versions(get_v2ray_version(), "<", remote_version) - local html_url, download_url - - if needs_update then - html_url = json.html_url - for _, v in ipairs(json.assets) do - if v.name and v.name:match("linux%-" .. file_tree) then - download_url = v.browser_download_url - break - end - end - end - - if needs_update and not download_url then - return { - code = 1, - version = remote_version, - html_url = html_url, - type = file_tree .. sub_version, - error = i18n.translate("New version found, but failed to get new version download url.") - } - end - - return { - code = 0, - update = needs_update, - version = remote_version, - url = { - html = html_url, - download = download_url - }, - type = file_tree .. sub_version - } -end - -function to_download(url) - if not url or url == "" then - return { - code = 1, - error = i18n.translate("Download url is required.") - } - end - - sys.call("/bin/rm -f /tmp/v2ray_download.*") - - local tmp_file = util.trim(util.exec("mktemp -u -t v2ray_download.XXXXXX")) - - local result = exec(wget, { - "-O", tmp_file, url, _unpack(wget_args) }, nil, command_timeout) == 0 - - if not result then - exec("/bin/rm", { "-f", tmp_file }) - return { - code = 1, - error = i18n.translatef("File download failed or timed out: %s", url) - } - end - - return { - code = 0, - file = tmp_file - } -end - -function to_extract(file, subfix) - local isinstall_unzip=sys.call("opkg list-installed | grep unzip > /dev/null")==0 - if not isinstall_unzip then - sys.call("opkg update && opkg install unzip > /dev/null") - end - - if not file or file == "" or not fs.access(file) then - return { - code = 1, - error = i18n.translate("File path required.") - } - end - - sys.call("/bin/rm -rf /tmp/v2ray_extract.*") - local tmp_dir = util.trim(util.exec("mktemp -d -t v2ray_extract.XXXXXX")) - - local output = { } - exec("/usr/bin/unzip", { "-o", file , "-d", tmp_dir }, - function(chunk) output[#output + 1] = chunk end) - - local files = util.split(table.concat(output)) - - exec("/bin/rm", { "-f", file }) - - return { - code = 0, - file = tmp_dir - } -end - -function to_move(file) - if not file or file == "" then - sys.call("/bin/rm -rf /tmp/v2ray_extract.*") - return { - code = 1, - error = i18n.translate("Client file is required.") - } - end - - local client_file = "/usr/bin/v2ray" - - sys.call("mkdir -p "..client_file) - - local result = exec("/bin/mv", { "-f", file.."/v2ray", file.."/v2ctl", client_file }, nil, command_timeout) == 0 - - if not result or not fs.access(client_file) then - sys.call("/bin/rm -rf /tmp/v2ray_extract.*") - return { - code = 1, - error = i18n.translatef("Can't move new file to path: %s", client_file) - } - end - - exec("/bin/chmod", { "-R", "755", client_file }) - - sys.call("/bin/rm -rf /tmp/v2ray_extract.*") - - return { code = 0 } -end diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua deleted file mode 100644 index ddfaa4bb9f..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/config.lua +++ /dev/null @@ -1,105 +0,0 @@ -local i="v2ray_server" -local n=require"luci.dispatcher" -local a,t,e -local o={ -"none", -"srtp", -"utp", -"wechat-video", -"dtls", -"wireguard", -} -a=Map(i,"V2ray "..translate("Server Config")) -a.redirect=n.build_url("admin","vpn","v2ray_server") - -t=a:section(NamedSection,arg[1],"user","") -t.addremove=false -t.dynamic=false - -e=t:option(Flag,"enable",translate("Enable")) -e.default="1" -e.rmempty=false - -e=t:option(Value,"remarks",translate("Remarks")) -e.default=translate("Remarks") - -e.rmempty=false -e=t:option(Value,"port",translate("Port")) -e.datatype="port" -e.rmempty=false -e.default=10086 - -e=t:option(ListValue,"protocol",translate("Protocol")) -e:value("vmess",translate("Vmess")) -e:value("socks",translate("Socks")) - -e=t:option(Value,"VMess_id",translate("ID")) -e.default=luci.sys.exec("cat /proc/sys/kernel/random/uuid") -e.rmempty=true -e:depends("protocol","vmess") - -e=t:option(Value,"VMess_alterId",translate("Alter ID")) -e.default=16 -e.rmempty=true -e:depends("protocol","vmess") - -e=t:option(Value,"Socks_user",translate("User name")) -e.default="lean" -e.rmempty=true -e:depends("protocol","socks") - -e=t:option(Value,"Socks_pass",translate("Password")) -e.default="password" -e.rmempty=true -e.password=true -e:depends("protocol","socks") - -e=t:option(Value,"VMess_level",translate("User Level")) -e.default=1 - -e=t:option(ListValue,"transport",translate("Transport")) -e.default=tcp -e:value("tcp","TCP") -e:value("mkcp","mKCP") -e:value("quic","QUIC") -e:depends("protocol","vmess") - -e=t:option(ListValue,"tcp_guise",translate("Camouflage Type")) -e:depends("transport","tcp") -e:value("none","none") -e:value("http","http") -e.default=none - -e=t:option(DynamicList,"tcp_guise_http_host",translate("HTTP Host")) -e:depends("tcp_guise","http") -e=t:option(DynamicList,"tcp_guise_http_path",translate("HTTP Path")) -e:depends("tcp_guise","http") -e=t:option(ListValue,"mkcp_guise",translate("Camouflage Type")) -for a,t in ipairs(o)do e:value(t)end -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_mtu",translate("KCP MTU")) -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_tti",translate("KCP TTI")) -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_uplinkCapacity",translate("KCP uplinkCapacity")) -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_downlinkCapacity",translate("KCP downlinkCapacity")) -e:depends("transport","mkcp") -e=t:option(Flag,"mkcp_congestion",translate("KCP Congestion")) -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_readBufferSize",translate("KCP readBufferSize")) -e:depends("transport","mkcp") -e=t:option(Value,"mkcp_writeBufferSize",translate("KCP writeBufferSize")) -e:depends("transport","mkcp") -e=t:option(ListValue,"quic_security",translate("Encrypt Method")) -e:value("none") -e:value("aes-128-gcm") -e:value("chacha20-poly1305") -e:depends("transport","quic") -e=t:option(Value,"quic_key",translate("Encrypt Method")..translate("Key")) -e:depends("transport","quic") -e=t:option(ListValue,"quic_guise",translate("Camouflage Type")) -for a,t in ipairs(o)do e:value(t)end -e:depends("transport","quic") - -return a diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua deleted file mode 100644 index b6fc41e06e..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/model/cbi/v2ray_server/index.lua +++ /dev/null @@ -1,45 +0,0 @@ -local i=require"luci.dispatcher" -local e=require"nixio.fs" -local e=require"luci.sys" -local e=luci.model.uci.cursor() -local o="v2ray_server" -local a,e,t - -a=Map(o,translate("V2ray Server")) -e=a:section(TypedSection,"global",translate("Global Setting")) -e.anonymous=true -e.addremove=false -t=e:option(Flag,"enable",translate("Enable")) -t.rmempty=false - -e=a:section(TypedSection,"user",translate("Server Setting")) -e.anonymous=true -e.addremove=true -e.template="cbi/tblsection" -e.extedit=i.build_url("admin","vpn",o,"config","%s") - -function e.create(t,e) -local e=TypedSection.create(t,e) -luci.http.redirect(i.build_url("admin","vpn",o,"config",e)) -end - -function e.remove(e,a) -e.map.proceed=true -e.map:del(a) -luci.http.redirect(i.build_url("admin","vpn",o)) -end - -t=e:option(Flag,"enable",translate("Enable")) -t.width="5%" -t.rmempty=false -t=e:option(DummyValue,"status",translate("Status")) -t.template="v2ray_server/users_status" -t.value=translate("Collecting data...") -t=e:option(DummyValue,"remarks",translate("Remarks")) -t.width="15%" -t=e:option(DummyValue,"port",translate("Port")) -t=e:option(DummyValue,"protocol",translate("Protocol")) - -a:append(Template("v2ray_server/users_list_status")) - -return a diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_list_status.htm b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_list_status.htm deleted file mode 100644 index d02ca6157d..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_list_status.htm +++ /dev/null @@ -1,28 +0,0 @@ -<%# - Copyright 2018 Lienol - Licensed to the public under the Apache License 2.0. --%> - -<% -local dsp = require "luci.dispatcher" --%> - - \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_status.htm b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_status.htm deleted file mode 100644 index 40c2e3c58c..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/users_status.htm +++ /dev/null @@ -1,3 +0,0 @@ -<%+cbi/valueheader%> --- -<%+cbi/valuefooter%> \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/v2ray.htm b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/v2ray.htm deleted file mode 100644 index 7208bf7f5f..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/luasrc/view/v2ray_server/v2ray.htm +++ /dev/null @@ -1,188 +0,0 @@ -<%# - Copyright 2018 - Licensed to the public under the Apache License 2.0. --%> - -<% -local v2ray_version=luci.sys.exec("/usr/bin/v2ray/v2ray -version | awk '{print $2}' | sed -n 1P") -local dsp = require "luci.dispatcher" --%> - - - -
- -
-
- - 【 <%=v2ray_version%>】 - - -
-
-
\ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/po/zh-cn/v2ray_server.po b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/po/zh-cn/v2ray_server.po deleted file mode 100644 index c5db9b349f..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/po/zh-cn/v2ray_server.po +++ /dev/null @@ -1,53 +0,0 @@ -msgid "V2ray Server" -msgstr "V2ray 服务器" - -msgid "Global Settings" -msgstr "全局设置" - -msgid "Server Config" -msgstr "服务器配置" - -msgid "Users Manager" -msgstr "用户管理" - -msgid "Remarks" -msgstr "备注" - -msgid "Port" -msgstr "端口" - -msgid "Password" -msgstr "密码" - -msgid "Protocol" -msgstr "协议" - -msgid "Null" -msgstr "无" - -msgid "Alter ID" -msgstr "额外ID(AlterID)" - -msgid "User Level" -msgstr "用户等级(Level)" - -msgid "Transport" -msgstr "传输方式" - -msgid "Camouflage Type" -msgstr "伪装类型" - -msgid "Enabled" -msgstr "启用" - -msgid "Status" -msgstr "状态" - -msgid "Current Condition" -msgstr "当前状态" - -msgid "NOT RUNNING" -msgstr "未运行" - -msgid "RUNNING" -msgstr "运行中" \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/config/v2ray_server b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/config/v2ray_server deleted file mode 100644 index cab9eeb88e..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/config/v2ray_server +++ /dev/null @@ -1,15 +0,0 @@ - -config global - option enable '0' - -config user - option enable '1' - option remarks '备注222' - option protocol 'vmess' - option VMess_id 'fd00927a-b0c2-4629-aef7-d9ff15a9d722' - option VMess_alterId '16' - option VMess_level '1' - option transport 'tcp' - option tcp_guise 'none' - option port '12366' - diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/init.d/v2ray_server b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/init.d/v2ray_server deleted file mode 100755 index ba4f90653f..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/init.d/v2ray_server +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2018-2019 Lienol - -START=99 - -CONFIG=v2ray_server -CONFIG_PATH=/var/etc/$CONFIG - -gen_v2ray_config_file() { - config_get enable $1 enable - [ "$enable" = "0" ] && return 0 - config_get remarks $1 remarks - config_get port $1 port - lua /usr/lib/lua/luci/model/cbi/v2ray_server/api/genv2rayconfig.lua $1 > $CONFIG_PATH/$1.json - [ -f /var/v2server ] || cp -a /usr/bin/v2ray/v2ray /var/v2server - /var/v2server -config $CONFIG_PATH/$1.json >/dev/null 2>&1 & -} - -start_v2ray_server() { - config_foreach gen_v2ray_config_file "user" - fw3 reload -} - -stop_v2ray_server() { - fw3 reload - ps -w | grep "$CONFIG_PATH/" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 & -} - -start() { - config_load $CONFIG - enable=$(uci get $CONFIG.@global[0].enable) - if [ "$enable" = "0" ];then - stop_v2ray_server - else - mkdir -p $CONFIG_PATH - start_v2ray_server - fi -} - -stop() { - stop_v2ray_server - rm -rf $CONFIG_PATH -} - -restart() { - stop - sleep 1 - start -} \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/uci-defaults/luci-app-v2ray-server b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/uci-defaults/luci-app-v2ray-server deleted file mode 100755 index 364f7db225..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/etc/uci-defaults/luci-app-v2ray-server +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete firewall.v2ray_server - set firewall.v2ray_server=include - set firewall.v2ray_server.type=script - set firewall.v2ray_server.path=/usr/share/v2ray_server/firewall.include - set firewall.v2ray_server.reload=1 -EOF - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@v2ray_server[-1] - add ucitrack v2ray_server - set ucitrack.@v2ray_server[-1].init=v2ray_server - commit ucitrack -EOF - -chmod a+x /usr/share/v2ray_server/* >/dev/null 2>&1 - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/usr/share/v2ray_server/firewall.include b/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/usr/share/v2ray_server/firewall.include deleted file mode 100755 index 1f06a00b6f..0000000000 --- a/package/lean/luci-app-v2ray-server/luci-app-v2ray-server/root/usr/share/v2ray_server/firewall.include +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -. $IPKG_INSTROOT/lib/functions.sh -. $IPKG_INSTROOT/lib/functions/service.sh - -gen_user_iptables() { - config_get enable $1 enable - [ "$enable" = "0" ] && return 0 - config_get remarks $1 remarks - config_get port $1 port - iptables -A V2RAY-SERVER -p tcp --dport $port -m comment --comment "$remarks" -j ACCEPT - iptables -A V2RAY-SERVER -p udp --dport $port -m comment --comment "$remarks" -j ACCEPT -} - -iptables -F V2RAY-SERVER 2>/dev/null -iptables -D INPUT -j V2RAY-SERVER 2>/dev/null -iptables -X V2RAY-SERVER 2>/dev/null - -enable=$(uci get v2ray_server.@global[0].enable) -if [ $enable -eq 1 ]; then - iptables -N V2RAY-SERVER - iptables -I INPUT -j V2RAY-SERVER - config_load v2ray_server - config_foreach gen_user_iptables "user" -fi \ No newline at end of file diff --git a/package/lean/luci-app-v2ray-server/po/zh-cn/v2ray_server.po b/package/lean/luci-app-v2ray-server/po/zh-cn/v2ray_server.po index c5db9b349f..fdddf5cad5 100644 --- a/package/lean/luci-app-v2ray-server/po/zh-cn/v2ray_server.po +++ b/package/lean/luci-app-v2ray-server/po/zh-cn/v2ray_server.po @@ -16,6 +16,9 @@ msgstr "备注" msgid "Port" msgstr "端口" +msgid "User name" +msgstr "用户名" + msgid "Password" msgstr "密码" diff --git a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua index 91ad4089df..14f4bdce05 100644 --- a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua +++ b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua @@ -23,9 +23,4 @@ e=t:option(DummyValue,"opennewwindow" , translate("")) e.description = translate("Create or manage your zerotier network, and auth clients who could access") -local apply = luci.http.formvalue("cbi.apply") -if apply then - io.popen("/etc/init.d/zerotier restart") -end - return a diff --git a/package/lean/npc/Makefile b/package/lean/npc/Makefile index 882fe69bf1..f14c1cf9cc 100644 --- a/package/lean/npc/Makefile +++ b/package/lean/npc/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=npc -PKG_VERSION:=0.23.2 +PKG_VERSION:=0.26.0 PKG_RELEASE:=1 ifeq ($(ARCH),mipsel) @@ -23,7 +23,13 @@ ifeq ($(ARCH),x86_64) NPC_ARCH:=amd64 endif ifeq ($(ARCH),arm) - NPC_ARCH:=arm + NPC_ARCH:=arm_v7 + ifeq ($(BOARD),bcm53xx) + NPC_ARCH:=arm_v5 + endif + ifeq ($(BOARD),kirkwood) + NPC_ARCH:=arm_v5 + endif endif ifeq ($(ARCH),aarch64) NPC_ARCH:=arm64 @@ -33,7 +39,7 @@ PKG_LICENSE:=Apache-2.0 PKG_SOURCE_URL:=https://github.com/cnlh/nps/releases/download/v$(PKG_VERSION) PKG_SOURCE:=linux_$(NPC_ARCH)_client.tar.gz -PKG_BUILD_DIR:=$(BUILD_DIR)/nps +PKG_BUILD_DIR:=$(BUILD_DIR)/nps-$(PKG_VERSION) PKG_HASH:=skip include $(INCLUDE_DIR)/package.mk @@ -53,7 +59,7 @@ npc is a fast reverse proxy to help you expose a local server behind a NAT or fi endef define Build/Prepare - $(PKG_UNPACK) + tar -zxf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) endef define Build/Configure diff --git a/package/lean/npc/npc/Makefile b/package/lean/npc/npc/Makefile deleted file mode 100644 index 882fe69bf1..0000000000 --- a/package/lean/npc/npc/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# -# Copyright (C) 2015-2016 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v3. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=npc -PKG_VERSION:=0.23.2 -PKG_RELEASE:=1 - -ifeq ($(ARCH),mipsel) - NPC_ARCH:=mipsle -endif -ifeq ($(ARCH),mips) - NPC_ARCH:=mips -endif -ifeq ($(ARCH),i386) - NPC_ARCH:=386 -endif -ifeq ($(ARCH),x86_64) - NPC_ARCH:=amd64 -endif -ifeq ($(ARCH),arm) - NPC_ARCH:=arm -endif -ifeq ($(ARCH),aarch64) - NPC_ARCH:=arm64 -endif - -PKG_LICENSE:=Apache-2.0 - -PKG_SOURCE_URL:=https://github.com/cnlh/nps/releases/download/v$(PKG_VERSION) -PKG_SOURCE:=linux_$(NPC_ARCH)_client.tar.gz -PKG_BUILD_DIR:=$(BUILD_DIR)/nps -PKG_HASH:=skip - -include $(INCLUDE_DIR)/package.mk - -define Package/$(PKG_NAME) - SECTION:=net - CATEGORY:=Network - TITLE:=NPC Client - DEPENDS:= - URL:=https://github.com/cnlh/nps/releases -endef - - - -define Package/$(PKG_NAME)/description -npc is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet -endef - -define Build/Prepare - $(PKG_UNPACK) -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Package/$(PKG_NAME)/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/npc $(1)/usr/bin/ -endef - -$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/openwrt-frpc/Makefile b/package/lean/openwrt-frpc/Makefile index 338bb56031..f4b2619f40 100644 --- a/package/lean/openwrt-frpc/Makefile +++ b/package/lean/openwrt-frpc/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openwrt-frpc -PKG_VERSION:=0.29.1 +PKG_VERSION:=0.31.1 PKG_RELEASE:=1 ifeq ($(ARCH),mipsel) diff --git a/package/lean/openwrt-kcptun-client/Makefile b/package/lean/openwrt-kcptun/Makefile similarity index 69% rename from package/lean/openwrt-kcptun-client/Makefile rename to package/lean/openwrt-kcptun/Makefile index 849b5a9545..6bdde9bf31 100644 --- a/package/lean/openwrt-kcptun-client/Makefile +++ b/package/lean/openwrt-kcptun/Makefile @@ -31,8 +31,8 @@ ifeq ($(ARCH),aarch64) PKG_ARCH_KCPTUN:=arm64 endif -PKG_NAME:=openwrt-kcptun-client -PKG_VERSION:=20190924 +PKG_NAME:=openwrt-kcptun +PKG_VERSION:=20200103 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE:=kcptun-linux-$(PKG_ARCH_KCPTUN)-$(PKG_VERSION).tar.gz @@ -41,7 +41,7 @@ PKG_HASH:=skip include $(INCLUDE_DIR)/package.mk -define Package/$(PKG_NAME) +define Package/$(PKG_NAME)-client SECTION:=net CATEGORY:=Network TITLE:=Kcptun is a cross-platform proxy software @@ -49,8 +49,12 @@ define Package/$(PKG_NAME) URL:=https://github.com/xtaci/kcptun endef -define Package/$(PKG_NAME)/description - Kcptun is a Fast and Reliable ARQ Protocol tunnel +define Package/$(PKG_NAME)-server + SECTION:=net + CATEGORY:=Network + TITLE:=Kcptun is a cross-platform proxy software + DEPENDS:= + URL:=https://github.com/xtaci/kcptun endef define Build/Prepare @@ -63,9 +67,15 @@ endef define Build/Compile endef -define Package/$(PKG_NAME)/install +define Package/$(PKG_NAME)-client/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/client_linux_$(PKG_ARCH_KCPTUN) $(1)/usr/bin/kcptun-client endef -$(eval $(call BuildPackage,$(PKG_NAME))) +define Package/$(PKG_NAME)-server/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/server_linux_$(PKG_ARCH_KCPTUN) $(1)/usr/bin/kcptun-server +endef + +$(eval $(call BuildPackage,$(PKG_NAME)-client)) +$(eval $(call BuildPackage,$(PKG_NAME)-server)) diff --git a/package/lean/rblibtorrent/Makefile b/package/lean/rblibtorrent/Makefile index c15101e08d..d2709c7bb5 100644 --- a/package/lean/rblibtorrent/Makefile +++ b/package/lean/rblibtorrent/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rblibtorrent PKG_VERSION:=1.1.13 -PKG_RELEASE=1 +PKG_RELEASE=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/arvidn/libtorrent.git @@ -41,12 +41,15 @@ EXTRA_CXXFLAGS += $(if $(CONFIG_GCC_VERSION_4_8),-std=gnu++11,-std=gnu++14) TARGET_LDFLAGS += -lstdc++ CONFIGURE_ARGS += \ - --prefix /usr \ - --enable-shared \ - --enable-static \ --disable-debug \ + --disable-rpath \ --enable-encryption \ - --with-boost=$(STAGING_DIR)/usr + --enable-deprecated-functions \ + --with-gnu-ld \ + --with-openssl=$(STAGING_DIR)/usr \ + --with-boost=$(STAGING_DIR)/usr \ + --with-libiconv \ + --with-libiconv-prefix=$(ICONV_PREFIX) define Build/Configure cd $(PKG_BUILD_DIR) ; \ diff --git a/package/lean/v2ray/Config.in b/package/lean/v2ray/Config.in new file mode 100644 index 0000000000..914555ab7a --- /dev/null +++ b/package/lean/v2ray/Config.in @@ -0,0 +1,149 @@ +menu "V2Ray Configuration" + depends on PACKAGE_v2ray + +choice + prompt "JSON Config Support" + default V2RAY_JSON_INTERNAL + + config V2RAY_JSON_V2CTL + bool "Load JSON from V2Ctl" + + config V2RAY_JSON_INTERNAL + bool "Load JSON Internally" + + config V2RAY_JSON_NONE + bool "None" + +endchoice + +config V2RAY_EXCLUDE_V2CTL + bool "Exclude V2Ctl" + depends on V2RAY_JSON_INTERNAL || V2RAY_JSON_NONE + default y + +config V2RAY_EXCLUDE_ASSETS + bool "Exclude geoip.dat & geosite.dat" + default y + +config V2RAY_COMPRESS_UPX + bool "Compress executable files with UPX" + default n + +choice + prompt "Disable Features" + default V2RAY_DISABLE_NONE + + config V2RAY_DISABLE_NONE + bool "None" + + config V2RAY_DISABLE_CUSTOM + bool "Custom" + +endchoice + +config V2RAY_DISABLE_DNS + bool "Disable Internal DNS Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_LOG + bool "Disable Log Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_POLICY + bool "Disable Local Policy Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_REVERSE + bool "Disable Reverse Proxy Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_ROUTING + bool "Disable Internal Routing Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_STATISTICS + bool "Disable Statistics Support" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_BLACKHOLE_PROTO + bool "Disable Blackhole Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_DNS_PROXY + bool "Disable DNS Proxy" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_DOKODEMO_PROTO + bool "Disable Dokodemo-door Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_FREEDOM_PROTO + bool "Disable Freedom Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_MTPROTO_PROXY + bool "Disable MTProto Proxy" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_HTTP_PROTO + bool "Disable HTTP Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_SHADOWSOCKS_PROTO + bool "Disable Shadowsocks Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_SOCKS_PROTO + bool "Disable Socks Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_VMESS_PROTO + bool "Disable VMess Protocol" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_TCP_TRANS + bool "Disable TCP Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_MKCP_TRANS + bool "Disable mKCP Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_WEBSOCKET_TRANS + bool "Disable WebSocket Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_HTTP2_TRANS + bool "Disable HTTP/2 Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_DOMAIN_SOCKET_TRANS + bool "Disable Domain Socket Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +config V2RAY_DISABLE_QUIC_TRANS + bool "Disable QUIC Transport" + depends on V2RAY_DISABLE_CUSTOM + default n + +endmenu diff --git a/package/lean/v2ray/Makefile b/package/lean/v2ray/Makefile index 138ff75c9e..53fae32e4b 100644 --- a/package/lean/v2ray/Makefile +++ b/package/lean/v2ray/Makefile @@ -1,69 +1,303 @@ # -# Copyright (C) 2015-2016 OpenWrt.org +# Copyright (C) 2019-2020 Xingwang Liao +# Copyright (C) 2019-2020 KFERMercer # -# This is free software, licensed under the GNU General Public License v3. +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. # include $(TOPDIR)/rules.mk PKG_NAME:=v2ray -PKG_VERSION:=4.20 -PKG_RELEASE:=1 +PKG_VERSION:=4.22.1 +PKG_RELEASE:=6 +PKG_BUILD_DIR:=$(BUILD_DIR)/v2ray-core-$(PKG_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-core-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/v2ray/v2ray-core/tar.gz/v$(PKG_VERSION)? +PKG_HASH:=31c1934eeac3552c7ab68eac9dc3e964e05f3c743b3733b0b6a0159c495019d6 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE +PKG_MAINTAINER:=Xingwang Liao + +PKG_CONFIG_DEPENDS := \ + CONFIG_V2RAY_JSON_V2CTL \ + CONFIG_V2RAY_JSON_INTERNAL \ + CONFIG_V2RAY_JSON_NONE \ + CONFIG_V2RAY_EXCLUDE_V2CTL \ + CONFIG_V2RAY_EXCLUDE_ASSETS \ + CONFIG_V2RAY_COMPRESS_UPX \ + CONFIG_V2RAY_DISABLE_NONE \ + CONFIG_V2RAY_DISABLE_CUSTOM \ + CONFIG_V2RAY_DISABLE_DNS \ + CONFIG_V2RAY_DISABLE_LOG \ + CONFIG_V2RAY_DISABLE_POLICY \ + CONFIG_V2RAY_DISABLE_REVERSE \ + CONFIG_V2RAY_DISABLE_ROUTING \ + CONFIG_V2RAY_DISABLE_STATISTICS \ + CONFIG_V2RAY_DISABLE_BLACKHOLE_PROTO \ + CONFIG_V2RAY_DISABLE_DNS_PROXY \ + CONFIG_V2RAY_DISABLE_DOKODEMO_PROTO \ + CONFIG_V2RAY_DISABLE_FREEDOM_PROTO \ + CONFIG_V2RAY_DISABLE_MTPROTO_PROXY \ + CONFIG_V2RAY_DISABLE_HTTP_PROTO \ + CONFIG_V2RAY_DISABLE_SHADOWSOCKS_PROTO \ + CONFIG_V2RAY_DISABLE_SOCKS_PROTO \ + CONFIG_V2RAY_DISABLE_VMESS_PROTO \ + CONFIG_V2RAY_DISABLE_TCP_TRANS \ + CONFIG_V2RAY_DISABLE_MKCP_TRANS \ + CONFIG_V2RAY_DISABLE_WEBSOCKET_TRANS \ + CONFIG_V2RAY_DISABLE_HTTP2_TRANS \ + CONFIG_V2RAY_DISABLE_DOMAIN_SOCKET_TRANS \ + CONFIG_V2RAY_DISABLE_QUIC_TRANS + +PKG_BUILD_DEPENDS:=golang/host +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +GO_PKG:=v2ray.com/core +GO_PKG_LDFLAGS:=-s -w +GO_PKG_LDFLAGS_X:= \ + v2ray.com/core.version=$(PKG_VERSION) \ + v2ray.com/core.build=R$(PKG_RELEASE) \ + v2ray.com/core.codename=OpenWrt include $(INCLUDE_DIR)/package.mk +include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk -define Package/$(PKG_NAME) - SECTION:=net - CATEGORY:=Network - TITLE:=V2Ray is a cross-platform proxy software - DEPENDS:=+ca-certificates - URL:=https://github.com/v2ray/v2ray-core +define Package/v2ray + TITLE:=A platform for building proxies + URL:=https://www.v2ray.com + SECTION:=net + CATEGORY:=Network + SUBMENU:=Project V + DEPENDS:=$(GO_ARCH_DEPENDS) +ca-certificates endef - -define Package/$(PKG_NAME)/description -V2Ray is a cross-platform proxy software +define Package/v2ray/config + source "$(SOURCE)/Config.in" endef -V2RAY_BIN:=v2ray +define Package/v2ray/description +Project V is a set of network tools that help you to build your own computer network. +It secures your network connections and thus protects your privacy. -ifeq ($(ARCH),x86_64) - PKG_ARCH_V2RAY:=amd64 + This package contains v2ray, v2ctl and v2ray-assets. +endef + +V2RAY_SED_ARGS:= + +ifeq ($(CONFIG_V2RAY_JSON_INTERNAL),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/main\/json"/\/\/ &/; \ + /\/\/ _ "v2ray.com\/core\/main\/jsonem"/s/\/\/ //; +else ifeq ($(CONFIG_V2RAY_JSON_NONE),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/main\/json"/\/\/ &/; endif -ifeq ($(ARCH),mipsel) - PKG_ARCH_V2RAY:=mipsle + +ifeq ($(CONFIG_V2RAY_DISABLE_CUSTOM),y) + +ifeq ($(CONFIG_V2RAY_DISABLE_DNS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/dns"/\/\/ &/; endif -ifeq ($(ARCH),mips) - PKG_ARCH_V2RAY:=mips + +ifeq ($(CONFIG_V2RAY_DISABLE_LOG),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/log"/\/\/ &/; \ + s/_ "v2ray.com\/core\/app\/log\/command"/\/\/ &/; endif -ifeq ($(ARCH),i386) - PKG_ARCH_V2RAY:=x86 + +ifeq ($(CONFIG_V2RAY_DISABLE_POLICY),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/policy"/\/\/ &/; endif -ifeq ($(ARCH),arm) - PKG_ARCH_V2RAY:=arm - ifneq ($(BOARD),bcm53xx) - V2RAY_BIN:=v2ray_armv7 - endif - ifeq ($(BOARD),kirkwood) - V2RAY_BIN:=v2ray - endif + +ifeq ($(CONFIG_V2RAY_DISABLE_REVERSE),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/reverse"/\/\/ &/; endif -ifeq ($(ARCH),aarch64) - PKG_ARCH_V2RAY:=arm64 + +ifeq ($(CONFIG_V2RAY_DISABLE_ROUTING),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/router"/\/\/ &/; endif +ifeq ($(CONFIG_V2RAY_DISABLE_STATISTICS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/app\/stats"/\/\/ &/; \ + s/_ "v2ray.com\/core\/app\/stats\/command"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_BLACKHOLE_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/blackhole"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_DNS_PROXY),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/dns"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_DOKODEMO_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/dokodemo"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_FREEDOM_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/freedom"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_MTPROTO_PROXY),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/mtproto"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_HTTP_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/http"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_SHADOWSOCKS_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/shadowsocks"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_SOCKS_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/socks"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_VMESS_PROTO),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/proxy\/vmess\/inbound"/\/\/ &/; \ + s/_ "v2ray.com\/core\/proxy\/vmess\/outbound"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_TCP_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/tcp"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_MKCP_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/kcp"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_WEBSOCKET_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/websocket"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_HTTP2_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/http"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/http"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_DOMAIN_SOCKET_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/domainsocket"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_QUIC_TRANS),y) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/quic"/\/\/ &/; +endif + +ifeq ($(CONFIG_V2RAY_DISABLE_MKCP_TRANS)$(CONFIG_V2RAY_DISABLE_QUIC_TRANS),yy) +V2RAY_SED_ARGS += \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/noop"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/srtp"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/tls"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/utp"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/wechat"/\/\/ &/; \ + s/_ "v2ray.com\/core\/transport\/internet\/headers\/wireguard"/\/\/ &/; +endif + +endif + +GEOIP_VER:=latest +GEOIP_FILE:=geoip-$(GEOIP_VER).dat + +define Download/geoip.dat + URL:=https://github.com/v2ray/geoip/releases/$(GEOIP_VER)/download + URL_FILE:=geoip.dat + FILE:=$(GEOIP_FILE) + HASH:=skip +endef + +GEOSITE_VER:=latest +GEOSITE_FILE:=geosite-$(GEOSITE_VER).dat + +define Download/geosite.dat + URL:=https://github.com/v2ray/domain-list-community/releases/$(GEOSITE_VER)/download + URL_FILE:=dlc.dat + FILE:=$(GEOSITE_FILE) + HASH:=skip +endef + define Build/Prepare -endef + $(call Build/Prepare/Default) -define Build/Configure +ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y) + # move file to make sure download new file every build + mv -f $(DL_DIR)/$(GEOIP_FILE) $(PKG_BUILD_DIR)/release/config/geoip.dat + mv -f $(DL_DIR)/$(GEOSITE_FILE) $(PKG_BUILD_DIR)/release/config/geosite.dat +endif + +ifneq ($(V2RAY_SED_ARGS),) + ( \ + sed -i \ + '$(V2RAY_SED_ARGS)' \ + $(PKG_BUILD_DIR)/main/distro/all/all.go ; \ + ) +endif endef define Build/Compile + $(eval GO_PKG_BUILD_PKG:=v2ray.com/core/main) + $(call GoPackage/Build/Compile) + mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ray + +ifeq ($(CONFIG_V2RAY_COMPRESS_UPX),y) + upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ray +endif + +ifneq ($(CONFIG_V2RAY_EXCLUDE_V2CTL),y) + $(eval GO_PKG_BUILD_PKG:=v2ray.com/core/infra/control/main) + $(call GoPackage/Build/Compile) + mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ctl + +ifeq ($(CONFIG_V2RAY_COMPRESS_UPX),y) + upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ctl +endif +endif endef -define Package/$(PKG_NAME)/install +define Package/v2ray/install $(INSTALL_DIR) $(1)/usr/bin/v2ray - $(INSTALL_BIN) ./files/$(PKG_ARCH_V2RAY)/$(V2RAY_BIN) $(1)/usr/bin/v2ray/v2ray + + $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/v2ray $(1)/usr/bin/v2ray + +ifneq ($(CONFIG_V2RAY_EXCLUDE_V2CTL),y) + $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/v2ctl $(1)/usr/bin/v2ray +endif + +ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y) + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \ + $(1)/usr/bin/v2ray +endif endef -$(eval $(call BuildPackage,$(PKG_NAME))) +ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y) +$(eval $(call Download,geoip.dat)) +$(eval $(call Download,geosite.dat)) +endif + +$(eval $(call GoBinPackage,v2ray)) +$(eval $(call BuildPackage,v2ray)) diff --git a/package/lean/v2ray/files/amd64/v2ray b/package/lean/v2ray/files/amd64/v2ray deleted file mode 100755 index 5ae09fced5..0000000000 Binary files a/package/lean/v2ray/files/amd64/v2ray and /dev/null differ diff --git a/package/lean/v2ray/files/arm/v2ray b/package/lean/v2ray/files/arm/v2ray deleted file mode 100755 index 36b213b2ee..0000000000 Binary files a/package/lean/v2ray/files/arm/v2ray and /dev/null differ diff --git a/package/lean/v2ray/files/arm/v2ray_armv7 b/package/lean/v2ray/files/arm/v2ray_armv7 deleted file mode 100755 index 23190110cd..0000000000 Binary files a/package/lean/v2ray/files/arm/v2ray_armv7 and /dev/null differ diff --git a/package/lean/v2ray/files/arm64/v2ray b/package/lean/v2ray/files/arm64/v2ray deleted file mode 100755 index 9b4728d3ed..0000000000 Binary files a/package/lean/v2ray/files/arm64/v2ray and /dev/null differ diff --git a/package/lean/v2ray/files/mips/v2ray b/package/lean/v2ray/files/mips/v2ray deleted file mode 100755 index 625f8d6ecd..0000000000 Binary files a/package/lean/v2ray/files/mips/v2ray and /dev/null differ diff --git a/package/lean/v2ray/files/mipsle/v2ray b/package/lean/v2ray/files/mipsle/v2ray deleted file mode 100755 index 917b161c43..0000000000 Binary files a/package/lean/v2ray/files/mipsle/v2ray and /dev/null differ diff --git a/package/lean/v2ray/files/x86/v2ray b/package/lean/v2ray/files/x86/v2ray deleted file mode 100755 index 75b7cab72f..0000000000 Binary files a/package/lean/v2ray/files/x86/v2ray and /dev/null differ diff --git a/package/lean/vlmcsd/Makefile b/package/lean/vlmcsd/Makefile index 201754e828..50c8f160f4 100644 --- a/package/lean/vlmcsd/Makefile +++ b/package/lean/vlmcsd/Makefile @@ -9,8 +9,8 @@ PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/etnperlong/vlmcsd.git -PKG_SOURCE_VERSION:=88007b3578cab6324241ae6e636d8e6503cd611c +PKG_SOURCE_URL:=https://github.com/Wind4/vlmcsd.git +PKG_SOURCE_VERSION:=cd488aeb85aedefe1cb4db02c632397d78a9de88 PKG_SOURCE_SUBDIR:=$(PKG_NAME) PKG_SOURCE:=$(PKG_SOURCE_SUBDIR)-$(PKG_VERSION).tar.gz diff --git a/package/lienol/trojan/Makefile b/package/lienol/trojan/Makefile index c17c136ed6..ee9672f716 100644 --- a/package/lienol/trojan/Makefile +++ b/package/lienol/trojan/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=trojan -PKG_VERSION:=1.13.0 -PKG_RELEASE:=2 +PKG_VERSION:=1.14.1 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/trojan-gfw/trojan.git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=98533aa1003979862763f4225266de78581e40bc +PKG_SOURCE_VERSION:=7cfe059c664e06bc7663620024578d85d9e6008c PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz CMAKE_INSTALL:=1 @@ -41,8 +41,10 @@ TARGET_LDFLAGS += -Wl,--gc-sections CMAKE_OPTIONS += \ -DENABLE_MYSQL=OFF \ - -DENABLE_SSL_KEYLOG=ON \ -DENABLE_NAT=ON \ + -DENABLE_REUSE_PORT=ON \ + -DENABLE_SSL_KEYLOG=ON \ + -DENABLE_TLS13_CIPHERSUITES=ON \ -DFORCE_TCP_FASTOPEN=OFF \ -DSYSTEMD_SERVICE=OFF \ -DOPENSSL_USE_STATIC_LIBS=FALSE \ diff --git a/package/lienol/trojan/patches/001-force-openssl-version.patch b/package/lienol/trojan/patches/001-force-openssl-version.patch index 0a7291261b..7ee8f631cc 100644 --- a/package/lienol/trojan/patches/001-force-openssl-version.patch +++ b/package/lienol/trojan/patches/001-force-openssl-version.patch @@ -4,7 +4,7 @@ add_definitions(-DBOOST_DATE_TIME_NO_LIB) endif() --find_package(OpenSSL 1.0.2 REQUIRED) +-find_package(OpenSSL 1.1.0 REQUIRED) +find_package(OpenSSL 1.1.1 REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(trojan ${OPENSSL_LIBRARIES})