Sync with CTCGFW's main code

This commit is contained in:
CN_SZTL 2020-02-01 02:30:25 +08:00
parent a139f9c9e9
commit 030cb13ae1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
97 changed files with 5099 additions and 2658 deletions

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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])

View File

@ -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.

View File

@ -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<CMemFile> 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

View File

@ -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
"<UpnpSendActionAsync>");
}
/* 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(

View File

@ -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))

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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)))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -8,5 +8,5 @@
│ # │
│ " │
│─────────────────────────────────────────────────│
│ OpenWrt SNAPSHOT, Mod 19.11 By CTCGFW │
│ OpenWrt SNAPSHOT, Mod 20.02 By CTCGFW │
└─────────────────────────────────────────────────┘

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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."))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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
}

View File

@ -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

View File

@ -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("<strong>控制台下载:<a onclick=\"window.open('http://www.softether-download.com/files/softether/v4.22-9634-beta-2016.11.27-tree/Windows/SoftEther_VPN_Server_and_VPN_Bridge/softether-vpnserver_vpnbridge-v4.22-9634-beta-2016.11.27-windows-x86_x64-intel.exe')\"><br/>Windows-x86_x64-intel.exe</a><a onclick=\"window.open('http://www.softether-download.com/files/softether/v4.21-9613-beta-2016.04.24-tree/Mac_OS_X/Admin_Tools/VPN_Server_Manager_Package/softether-vpnserver_manager-v4.21-9613-beta-2016.04.24-macos-x86-32bit.pkg')\"><br/>macos-x86-32bit.pkg</a></strong>"))
o=s:option(DummyValue,"moreinfo",translate("<strong>控制台下载:<a onclick=\"window.open('https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.30-9696-beta/softether-vpnserver_vpnbridge-v4.30-9696-beta-2019.07.08-windows-x86_x64-intel.exe')\"><br/>Windows-x86_x64-intel.exe</a><a onclick=\"window.open('https://www.softether-download.com/files/softether/v4.21-9613-beta-2016.04.24-tree/Mac_OS_X/Admin_Tools/VPN_Server_Manager_Package/softether-vpnserver_manager-v4.21-9613-beta-2016.04.24-macos-x86-32bit.pkg')\"><br/>macos-x86-32bit.pkg</a></strong>"))
return m

View File

@ -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

View File

@ -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 .. "<font color='green'>[" .. server_name .. "] OK.</font><br />"
else
retstring =retstring .. "<font color='red'>[" .. server_name .. "] Error.</font><br />"
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

View File

@ -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

View File

@ -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")

View File

@ -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")

View File

@ -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
return m

View File

@ -20,4 +20,4 @@ function f.handle(self, state, data)
return true
end
return f
return f

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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%"

View File

@ -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")

View File

@ -1,7 +1,5 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function check_connect(btn,urlname)
{
btn.disabled = true;
@ -18,20 +16,14 @@
s.innerHTML ="<font color='green'>"+"<%:Connect OK%>"+"</font>";
else
s.innerHTML ="<font color='red'>"+"<%:Connect Error%>"+"</font>";
}
btn.disabled = false;
btn.value = '<%:Check Connect%>';
}
);
return false;
}
//]]></script>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Connect%>" onclick="return check_connect(this,'<%=self.option%>')" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>

View File

@ -1,11 +1,10 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function check_port(btn)
{
btn.disabled = true;
btn.value = '<%:Check...%>';
btn.value = '<%:Check...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocksr","checkport")%>',
null,
function(x,rv)
@ -13,24 +12,15 @@
var s = document.getElementById('<%=self.option%>-status');
if (s)
{
s.innerHTML =rv.ret;
}
btn.disabled = false;
btn.value = '<%:Check Server%>';
}
);
return false;
}
//]]></script>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Server%>" onclick="return check_port(this)" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>

View File

@ -1,11 +1,9 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function refresh_data(btn,dataname)
{
btn.disabled = true;
btn.value = '<%:Refresh...%> ';
btn.value = '<%:Refresh...%> ';
murl=dataname;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocksr","refresh")%>',
{ set:murl },
@ -24,21 +22,14 @@
{
s.innerHTML ="<font color='green'>"+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+"</font>";
}
}
btn.disabled = false;
btn.value = '<%:Refresh Data %>';
}
);
return false;
}
//]]></script>
<input type="button" class="cbi-button cbi-input-reload" value="<%:Refresh Data%> " onclick="return refresh_data(this,'<%=self.option%>')" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>

View File

@ -2,23 +2,61 @@
Copyright 2018-2019 Lienol <lawlienol@gmail.com>
Licensed to the public under the Apache License 2.0.
-%>
<%
local dsp = require "luci.dispatcher"
-%>
<script type="text/javascript">
//<![CDATA[
var pings = document.getElementsByClassName('pingtime');
for(var i = 0; i < pings.length; i++) {
XHR.get('<%=dsp.build_url("admin/services/shadowsocksr/ping")%>', {
index: i,
domain: pings[i].getAttribute("hint")
const doms = document.getElementsByClassName('pingtime');
const ports = document.getElementsByClassName("socket-connected")
// 这也是卡的原罪 CGI 一下子处理不这么多
const xhr = (index) => {
return new Promise((res) => {
const dom = doms[index];
const port = ports[index];
if (!dom) res()
XHR.get('<%=dsp.build_url("admin/services/shadowsocksr/ping")%>', {
index,
domain: dom.getAttribute("hint"),
port: port.getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
}
);
(x, result) => {
let col = '#ff0000';
if (result.ping) {
if (result.ping < 300) col = '#ff3300';
if (result.ping < 200) col = '#ff7700';
if (result.ping < 100) col = '#249400';
}
dom.innerHTML = `<font color="${col}">${(result.ping ? result.ping : "--") + " ms"}</font>`
if (result.socket) {
port.innerHTML = '<font color="#249400">ok</font>'
} else {
port.innerHTML = '<font color="#ff0000">fail</font>'
}
res()
});
})
}
(async () => {
for (let group = 0; group < Math.ceil(doms.length / 5); group++) {
await Promise.all([
xhr(group * 5 + 0),
xhr(group * 5 + 1),
xhr(group * 5 + 2),
xhr(group * 5 + 3),
xhr(group * 5 + 4),
])
}
})()
// for(var i = 0; i < pings.length; i++) {
// XHR.get('<%=dsp.build_url("admin/services/shadowsocksr/ping")%>', {
// index: i,
// domain: pings[i].getAttribute("hint")
// },
// function(x, result) {
// pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
// }
// );
// }
//]]>
</script>

View File

@ -0,0 +1,3 @@
<%+cbi/valueheader%>
<span class="socket-connected" hint="<%=self:cfgvalue(section)%>">connecting</span>
<%+cbi/valuefooter%>

View File

@ -1,227 +1,237 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function padright(str, cnt, pad) {
return str + Array(cnt + 1).join(pad);
}
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
function b64encutf8safe(str) {
return b64EncodeUnicode(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '');
}
function b64DecodeUnicode(str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function b64decutf8safe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l)
str = padright(str, l, "=");
return b64DecodeUnicode(str);
}
function b64encsafe(str) {
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '')
}
function b64decsafe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l)
str = padright(str, l, "=");
return atob(str);
}
function dictvalue(d, key) {
var v = d[key];
if (typeof (v) == 'undefined' || v == '')
return '';
return b64decsafe(v);
}
function export_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s)
return false;
var v_server = document.getElementById('cbid.shadowsocksr.' + sid + '.server');
var v_port = document.getElementById('cbid.shadowsocksr.' + sid + '.server_port');
var v_protocol = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol');
var v_method = document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method');
var v_obfs = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs');
var v_password = document.getElementById('cbid.shadowsocksr.' + sid + '.password');
var v_obfs_param = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param');
var v_protocol_param = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param');
var v_alias = document.getElementById('cbid.shadowsocksr.' + sid + '.alias');
function padright(str, cnt, pad) {
return str + Array(cnt + 1).join(pad);
}
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
function b64encutf8safe(str) {
return b64EncodeUnicode(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '');
}
function b64DecodeUnicode(str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function b64decutf8safe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l)
str = padright(str, l, "=");
return b64DecodeUnicode(str);
}
function b64encsafe(str) {
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '')
}
function b64decsafe(str) {
var l;
str = str.replace(/-/g, "+").replace(/_/g, "/");
l = str.length;
l = (4 - l % 4) % 4;
if (l)
str = padright(str, l, "=");
return atob(str);
}
function dictvalue(d, key) {
var v = d[key];
if (typeof (v) == 'undefined' || v == '')
return '';
return b64decsafe(v);
}
function export_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s)
return false;
var v_server = document.getElementById('cbid.shadowsocksr.' + sid + '.server');
var v_port = document.getElementById('cbid.shadowsocksr.' + sid + '.server_port');
var v_protocol = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol');
var v_method = document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method');
var v_obfs = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs');
var v_password = document.getElementById('cbid.shadowsocksr.' + sid + '.password');
var v_obfs_param = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param');
var v_protocol_param = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param');
var v_alias = document.getElementById('cbid.shadowsocksr.' + sid + '.alias');
var ssr_str = v_server.value + ":" +
v_port.value + ":" +
v_protocol.value + ":" +
v_method.value + ":" +
v_obfs.value + ":" +
b64encsafe(v_password.value) +
"/?obfsparam=" + b64encsafe(v_obfs_param.value) +
"&protoparam=" + b64encsafe(v_protocol_param.value) +
"&remarks=" + b64encutf8safe(v_alias.value);
var textarea = document.createElement("textarea");
textarea.textContent = "ssr://" + b64encsafe(ssr_str);
textarea.style.position = "fixed";
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand("copy"); // Security exception may be thrown by some browsers.
s.innerHTML = "<font color='green'><%:Copy SSR to clipboard successfully.%></font>";
} catch (ex) {
s.innerHTML = "<font color='red'><%:Unable to copy SSR to clipboard.%></font>";
} finally {
document.body.removeChild(textarea);
}
return false;
}
var ssr_str = v_server.value + ":" +
v_port.value + ":" +
v_protocol.value + ":" +
v_method.value + ":" +
v_obfs.value + ":" +
b64encsafe(v_password.value) +
"/?obfsparam=" + b64encsafe(v_obfs_param.value) +
"&protoparam=" + b64encsafe(v_protocol_param.value) +
"&remarks=" + b64encutf8safe(v_alias.value);
var textarea = document.createElement("textarea");
textarea.textContent = "ssr://" + b64encsafe(ssr_str);
textarea.style.position = "fixed";
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand("copy"); // Security exception may be thrown by some browsers.
s.innerHTML = "<font color='green'><%:Copy SSR to clipboard successfully.%></font>";
} catch (ex) {
s.innerHTML = "<font color='red'><%:Unable to copy SSR to clipboard.%></font>";
} finally {
document.body.removeChild(textarea);
}
return false;
}
function import_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s)
return false;
var ssrurl = prompt("在这里黏贴配置链接 ssr:// | ss:// | vmess:// | trojan://", "");
if (ssrurl == null || ssrurl == "") {
s.innerHTML = "<font color='red'>用户取消</font>";
return false;
}
s.innerHTML = "";
//var ssu = ssrurl.match(/ssr:\/\/([A-Za-z0-9_-]+)/i);
var ssu = ssrurl.split('://');
console.log(ssu.length);
if ((ssu[0] != "ssr" && ssu[0] != "ss" && ssu[0] != "vmess" && ssu[0] != "trojan") || ssu[1] == "") {
s.innerHTML = "<font color='red'>无效格式</font>";
return false;
}
function import_ssr_url(btn, urlname, sid) {
var s = document.getElementById(urlname + '-status');
if (!s)
return false;
var ssrurl = prompt("在这里黏贴配置链接 ssr:// | ss:// | vmess:// | trojan://", "");
if (ssrurl == null || ssrurl == "") {
s.innerHTML = "<font color='red'>用户取消</font>";
return false;
}
s.innerHTML = "";
//var ssu = ssrurl.match(/ssr:\/\/([A-Za-z0-9_-]+)/i);
var ssu = ssrurl.split('://');
console.log(ssu.length);
if ((ssu[0] != "ssr" && ssu[0] != "ss" && ssu[0] != "vmess" && ssu[0] != "trojan") || ssu[1] == "") {
s.innerHTML = "<font color='red'>无效格式</font>";
return false;
}
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
if (ssu[0] == "ssr") {
var sstr = b64decsafe(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ssr";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
if (!ssm || ssm.length < 7)
return false;
var pdict = {};
if (param.length > 2)
{
var a = param.split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
pdict[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
}
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm[2];
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol').value = ssm[3];
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method').value = ssm[4];
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs').value = ssm[5];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = b64decsafe(ssm[6]);
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param').value = dictvalue(pdict, 'obfsparam');
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param').value = dictvalue(pdict, 'protoparam');
var rem = pdict['remarks'];
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0)
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = b64decutf8safe(rem);
s.innerHTML = "<font color='green'>导入ShadowsocksR配置信息成功</font>";
return false;
} else if (ssu[0] == "ss") {
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1]
}
var sstr = b64decsafe(url0);
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ss";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var team = sstr.split('@');
console.log(param);
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method_ss').value = part1[0];
if (param != undefined) {
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
}
s.innerHTML = "<font color='green'>导入Shadowsocks配置信息成功</font>";
return false;
} else if (ssu[0] == "trojan") {
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1]
}
var sstr = b64decsafe(url0);
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "trojan";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var team = sstr.split('@');
console.log(param);
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
if (param != undefined) {
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
}
s.innerHTML = "<font color='green'>导入Trojan配置信息成功</font>";
return false;
} else if (ssu[0] == "vmess") {
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "v2ray";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = JSON.parse(sstr);
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = ssm.ps;
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm.add;
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm.port;
document.getElementById('cbid.shadowsocksr.' + sid + '.alter_id').value = ssm.aid;
document.getElementById('cbid.shadowsocksr.' + sid + '.vmess_id').value = ssm.id;
document.getElementById('cbid.shadowsocksr.' + sid + '.security').value = ssm.type;
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').value = ssm.net;
document.getElementById('cbid.shadowsocksr.' + sid + '.http_host').value = ssm.host;
document.getElementById('cbid.shadowsocksr.' + sid + '.http_path').value = ssm.path;
s.innerHTML = "<font color='green'>导入V2ray配置信息成功</font>";
return false;
}
}
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
if (ssu[0] == "ssr") {
var sstr = b64decsafe(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ssr";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
if (!ssm || ssm.length < 7)
return false;
var pdict = {};
if (param.length > 2)
{
var a = param.split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
pdict[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
}
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm[2];
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol').value = ssm[3];
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method').value = ssm[4];
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs').value = ssm[5];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = b64decsafe(ssm[6]);
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param').value = dictvalue(pdict, 'obfsparam');
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param').value = dictvalue(pdict, 'protoparam');
var rem = pdict['remarks'];
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0)
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = b64decutf8safe(rem);
s.innerHTML = "<font color='green'>导入ShadowsocksR配置信息成功</font>";
return false;
} else if (ssu[0] == "ss") {
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1]
}
var sstr = b64decsafe(url0);
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ss";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var team = sstr.split('@');
console.log(param);
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method_ss').value = part1[0];
if (param != undefined) {
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
}
s.innerHTML = "<font color='green'>导入Shadowsocks配置信息成功</font>";
return false;
} else if (ssu[0] == "trojan") {
var ploc = ssu[1].indexOf("#");
if (ploc > 0) {
url0 = ssu[1].substr(0, ploc);
param = ssu[1].substr(ploc + 1);
} else {
url0 = ssu[1]
}
var sstr = b64decsafe(url0);
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "trojan";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var team = sstr.split('@');
console.log(param);
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
if (param != undefined) {
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
}
s.innerHTML = "<font color='green'>导入Trojan配置信息成功</font>";
return false;
} else if (ssu[0] == "vmess") {
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "v2ray";
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
}
var ssm = JSON.parse(sstr);
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = ssm.ps;
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm.add;
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm.port;
document.getElementById('cbid.shadowsocksr.' + sid + '.alter_id').value = ssm.aid;
document.getElementById('cbid.shadowsocksr.' + sid + '.vmess_id').value = ssm.id;
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').value = ssm.net;
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').dispatchEvent(event);
if (ssm.net == "tcp") {
document.getElementById('cbid.shadowsocksr.' + sid + '.http_host').value = ssm.host;
document.getElementById('cbid.shadowsocksr.' + sid + '.http_path').value = ssm.path;
}
if (ssm.net == "ws") {
document.getElementById('cbid.shadowsocksr.' + sid + '.ws_host').value = ssm.host;
document.getElementById('cbid.shadowsocksr.' + sid + '.ws_path').value = ssm.path;
}
if (ssm.net == "h2") {
document.getElementById('cbid.shadowsocksr.' + sid + '.h2_host').value = ssm.host;
document.getElementById('cbid.shadowsocksr.' + sid + '.h2_path').value = ssm.path;
}
if (ssm.net == "quic") {
document.getElementById('cbid.shadowsocksr.' + sid + '.quic_security').value = ssm.securty;
document.getElementById('cbid.shadowsocksr.' + sid + '.quic_key').value = ssm.key;
}
if (ssm.net == "kcp") {
document.getElementById('cbid.shadowsocksr.' + sid + '.kcp_guise').value = ssm.type;
}
if (ssm.tls == "tls") {
document.getElementById('cbid.shadowsocksr.' + sid + '.tls').checked = true;
document.getElementById('cbid.shadowsocksr.' + sid + '.tls').dispatchEvent(event);
document.getElementById('cbid.shadowsocksr.' + sid + '.tls_host').value = ssm.host;
}
document.getElementById('cbid.shadowsocksr.' + sid + '.mux').checked = true;
document.getElementById('cbid.shadowsocksr.' + sid + '.mux').dispatchEvent(event);
s.innerHTML = "<font color='green'>导入V2ray配置信息成功</font>";
return false;
}
}
//]]></script>
<input type="button" class="cbi-button cbi-button-apply" value="导入配置信息" onclick="return import_ssr_url(this, '<%=self.option%>', '<%=self.value%>')" />
<span id="<%=self.option%>-status"></span>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,18 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function subscribe(btn,dataname) {
btn.disabled = true;
btn.value = '<%:Refresh...%> ';
murl=dataname;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocksr","subscribe")%>', { set:murl }, function(x,rv) {
// 先简单刷新后期如果重构会考虑下如何组织lua shell JavaScript之间的代码逻辑和各自的调用逻辑
window.location.reload()
// btn.disabled = false;
// btn.value = '<%:Refresh Data %>';
});
return false;
}
//]]></script>
<input type="button" class="cbi-button cbi-input-apply" value="<%:Update All Subscribe Severs%> " onclick="return subscribe(this,'<%=self.option%>')" />
<!-- <span id="<%=self.option%>-status"><em><%=self.value%></em></span> -->
<%+cbi/valuefooter%>

View File

@ -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延迟"

View File

@ -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

View File

@ -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'

View File

@ -1,2 +0,0 @@
server=/.t66y.com/127.0.0.1#5335
ipset=/.t66y.com/gfwlist

View File

@ -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 <<EOF
global {
perm_cache=1024;
cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 127.0.0.1;
server_port = 5335;
status_ctl = on;
query_method = tcp_only;
min_ttl=1h;
max_ttl=1w;
timeout=10;
neg_domain_pol=on;
proc_limit=2;
procq_limit=8;
perm_cache=1024;
cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 127.0.0.1;
server_port = 5335;
status_ctl = on;
query_method = tcp_only;
min_ttl=1h;
max_ttl=1w;
timeout=10;
neg_domain_pol=on;
proc_limit=2;
procq_limit=8;
par_queries=1;
}
server {
label= "ssr-usrdns";
ip = $usr_dns;
port = $usr_port;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
label= "ssr-usrdns";
ip = $usr_dns;
port = $usr_port;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}
server {
label= "ssr-pdnsd";
ip = $tcp_dns_list;
port = 5353;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
label= "ssr-pdnsd";
ip = $tcp_dns_list;
port = 5353;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}
EOF
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf -d
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf &
}
@ -276,12 +276,12 @@ start_redir() {
1|on|true|yes|enabled) ARG_OTA="-A";;
*) ARG_OTA="";;
esac
#deal kcp
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable 0)
if [ $kcp_enable = "1" ] ;then
[ ! -f "/usr/bin/kcptun-client" ] && return 1
local kcp_str=`/usr/bin/kcptun-client -v |grep kcptun|wc -l`
[ "0" = $kcp_str ] && return 1
local kcp_port=$(uci_get_by_name $GLOBAL_SERVER kcp_port)
@ -291,98 +291,100 @@ start_redir() {
[ "$password" != "" ] && password="--key "${password}
service_start /usr/bin/kcptun-client \
-r $kcp_server:$kcp_port \
-l :$server_port $password $kcp_param
-l :$server_port $password $kcp_param
kcp_enable_flag=1
fi
gen_config_file $GLOBAL_SERVER 0
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" ] ;then
sscmd="/usr/bin/ss-redir"
elif [ "$stype" == "ssr" ] ;then
sscmd="/usr/bin/ssr-redir"
elif [ "$stype" == "v2ray" ] ;then
sscmd="/usr/bin/v2ray/v2ray"
elif [ "$stype" == "trojan" ] ;then
sscmd="/usr/sbin/trojan"
fi
gen_config_file $GLOBAL_SERVER 0
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" ] ;then
sscmd="/usr/bin/ss-redir"
elif [ "$stype" == "ssr" ] ;then
sscmd="/usr/bin/ssr-redir"
elif [ "$stype" == "v2ray" ] ;then
sscmd="/usr/bin/v2ray/v2ray"
[ ! -f "$sscmd" ] && sscmd="/usr/bin/v2ray"
elif [ "$stype" == "trojan" ] ;then
sscmd="/usr/sbin/trojan"
fi
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
if [ "$utype" == "ss" ] ;then
ucmd="/usr/bin/ss-redir"
elif [ "$utype" == "ssr" ] ;then
ucmd="/usr/bin/ssr-redir"
elif [ "$utype" == "v2ray" ] ;then
ucmd="/usr/bin/v2ray/v2ray"
elif [ "$utype" == "trojan" ] ;then
ucmd="/usr/sbin/trojan"
fi
if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
else
threads=$(uci_get_by_type global threads)
fi
if [ "$utype" == "ss" ] ;then
ucmd="/usr/bin/ss-redir"
elif [ "$utype" == "ssr" ] ;then
ucmd="/usr/bin/ssr-redir"
elif [ "$utype" == "v2ray" ] ;then
ucmd="/usr/bin/v2ray/v2ray"
[ ! -f "$ucmd" ] && ucmd="/usr/bin/v2ray"
elif [ "$utype" == "trojan" ] ;then
ucmd="/usr/sbin/trojan"
fi
if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
else
threads=$(uci_get_by_type global threads)
fi
redir_tcp=1
if [ "$stype" == "ss" -o "$stype" == "ssr" ] ;then
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
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
}

View File

@ -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:\/\/##;' |

View File

@ -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

View File

@ -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 <server_ip> ip address of shadowsocksr remote server
-l <local_port> port number of shadowsocksr local server
-S <server_ip> ip address of shadowsocksr remote UDP server
-L <local_port> port number of shadowsocksr local UDP server
-i <ip_list_file> a file content is bypassed ip list
-a <lan_ips> lan ip of access control, need a prefix to
define access control mode
-b <wan_ips> wan ip of will be bypassed
-w <wan_ips> wan ip of will be forwarded
-p <fp_lan_ips> lan ip of will be global proxy
-G <gm_lan_ips> lan ip of will be game mode proxy
-D <proxy_ports> proxy ports
-e <extra_options> 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 <server_ip> ip address of shadowsocksr remote server
-l <local_port> port number of shadowsocksr local server
-S <server_ip> ip address of shadowsocksr remote UDP server
-L <local_port> port number of shadowsocksr local UDP server
-i <ip_list_file> a file content is bypassed ip list
-a <lan_ips> lan ip of access control, need a prefix to
define access control mode
-b <wan_ips> wan ip of will be bypassed
-w <wan_ips> wan ip of will be forwarded
-p <fp_lan_ips> lan ip of will be global proxy
-G <gm_lan_ips> lan ip of will be game mode proxy
-D <proxy_ports> proxy ports
-e <extra_options> 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

View File

@ -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

View File

@ -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))

View File

@ -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))

View File

@ -0,0 +1,365 @@
#!/usr/bin/lua
------------------------------------------------
-- This file is part of the luci-app-ssr-plus subscribe.lua
-- @author William Chan <root@williamchan.me>
------------------------------------------------
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

View File

@ -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

View File

@ -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
-- --]]

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -1,321 +0,0 @@
-- Copyright 2018 Lienol <lienol@qq.com>
-- 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

View File

@ -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

View File

@ -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

View File

@ -1,28 +0,0 @@
<%#
Copyright 2018 Lienol
Licensed to the public under the Apache License 2.0.
-%>
<%
local dsp = require "luci.dispatcher"
-%>
<script type="text/javascript">
//<![CDATA[
var v2ray_users_status = document.getElementsByClassName('v2ray_users_status');
for(var i = 0; i < v2ray_users_status.length; i++) {
var id = v2ray_users_status[i].parentElement.parentElement.parentElement.id;
id = id.substr(id.lastIndexOf("-") + 1);
XHR.poll(1,'<%=dsp.build_url("admin/vpn/v2ray_server/users_status")%>', {
index: i,
id: id
},
function(x, result) {
v2ray_users_status[result.index].setAttribute("style","font-weight:bold;");
v2ray_users_status[result.index].setAttribute("color",result.status ? "green":"red");
v2ray_users_status[result.index].innerHTML = (result.status ? '✓' : 'X');
}
);
}
//]]>
</script>

View File

@ -1,3 +0,0 @@
<%+cbi/valueheader%>
<font class="v2ray_users_status" hint="<%=self:cfgvalue(section)%>">--</font>
<%+cbi/valuefooter%>

View File

@ -1,188 +0,0 @@
<%#
Copyright 2018 <lienol@qq.com>
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"
-%>
<script type="text/javascript">
//<![CDATA[
var v2rayInfo;
var tokenStr = '<%=token%>';
var noUpdateText = '<%:已是最新版本%>';
var updateSuccessText = '<%:更新成功.%>';
var clickToUpdateText = '<%:点击更新%>';
var inProgressText = '<%:正在更新...%>';
var unexpectedErrorText = '<%:意外错误.%>';
var updateInProgressNotice = '<%:正在更新,你确认要关闭吗?%>';
window.onload = function() {
var v2rayCheckBtn = document.getElementById('_v2ray-check_btn');
var v2rayDetailElm = document.getElementById('_v2ray-check_btn-detail');
};
function addPageNotice_v2ray() {
window.onbeforeunload = function(e) {
e.returnValue = updateInProgressNotice;
return updateInProgressNotice;
};
}
function removePageNotice_v2ray() {
window.onbeforeunload = undefined;
}
function onUpdateSuccess_v2ray(btn) {
alert(updateSuccessText);
if(btn) {
btn.value = updateSuccessText;
btn.placeholder = updateSuccessText;
btn.disabled = true;
}
window.setTimeout(function() {
window.location.reload();
}, 1000);
}
function onRequestError_v2ray(btn, errorMessage) {
btn.disabled = false;
btn.value = btn.placeholder;
if(errorMessage) {
alert(errorMessage);
}
}
function doAjaxGet(url, data, onResult) {
new XHR().get(url, data, function(_, json) {
var resultJson = json || {
'code': 1,
'error': unexpectedErrorText
};
if(typeof onResult === 'function') {
onResult(resultJson);
}
})
}
function onBtnClick_v2ray(btn) {
if(v2rayInfo === undefined) {
checkUpdate_v2ray(btn);
} else {
doUpdate_v2ray(btn);
}
}
function checkUpdate_v2ray(btn) {
btn.disabled = true;
btn.value = inProgressText;
addPageNotice_v2ray();
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
doAjaxGet('<%=dsp.build_url("admin/vpn/v2ray_server/check")%>', {
token: tokenStr,
arch: ''
}, function(json) {
removePageNotice_v2ray();
if(json.code) {
v2rayInfo = undefined;
onRequestError_v2ray(btn, json.error);
} else {
if(json.update) {
v2rayInfo = json;
btn.disabled = false;
btn.value = clickToUpdateText;
btn.placeholder = clickToUpdateText;
if(ckeckDetailElm) {
var urlNode = '';
if(json.version) {
urlNode = '<em style="color:red;">最新版本号:' + json.version + '</em>';
if(json.url && json.url.html) {
urlNode = '<a href="' + json.url.html + '" target="_blank">' + urlNode + '</a>';
}
}
ckeckDetailElm.innerHTML = urlNode;
}
} else {
btn.disabled = true;
btn.value = noUpdateText;
}
}
});
}
function doUpdate_v2ray(btn) {
btn.disabled = true;
btn.value = '<%:下载中...%>';
addPageNotice_v2ray();
var v2rayUpdateUrl = '<%=dsp.build_url("admin/vpn/v2ray_server/update")%>';
// Download file
doAjaxGet(v2rayUpdateUrl, {
token: tokenStr,
url: v2rayInfo ? v2rayInfo.url.download : ''
}, function(json) {
if(json.code) {
removePageNotice_v2ray();
onRequestError_v2ray(btn, json.error);
} else {
btn.value = '<%:解压中...%>';
// Extract file
doAjaxGet(v2rayUpdateUrl, {
token: tokenStr,
task: 'extract',
file: json.file,
subfix: v2rayInfo ? v2rayInfo.type : ''
}, function(json) {
if(json.code) {
removePageNotice_v2ray();
onRequestError_v2ray(btn, json.error);
} else {
btn.value = '<%:移动中...%>';
// Move file to target dir
doAjaxGet(v2rayUpdateUrl, {
token: tokenStr,
task: 'move',
file: json.file
}, function(json) {
removePageNotice_v2ray();
if(json.code) {
onRequestError_v2ray(btn, json.error);
} else {
onUpdateSuccess_v2ray(btn);
}
})
}
})
}
})
}
//]]>
</script>
<div class="cbi-value">
<label class="cbi-value-title">V2ray
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<img src="/luci-static/resources/cbi/help.gif">
<span><%=v2ray_version%>】</span>
<input class="cbi-button cbi-input-apply" type="submit" id="_v2ray-check_btn" onclick="onBtnClick_v2ray(this);" value="<%:Manually update%>">
<span id="_v2ray-check_btn-detail"></span>
</div>
</div>
</div>

View File

@ -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 "运行中"

View File

@ -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'

View File

@ -1,49 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2018-2019 Lienol <lawlienol@gmail.com>
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
}

View File

@ -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

View File

@ -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

View File

@ -16,6 +16,9 @@ msgstr "备注"
msgid "Port"
msgstr "端口"
msgid "User name"
msgstr "用户名"
msgid "Password"
msgstr "密码"

View File

@ -23,9 +23,4 @@ e=t:option(DummyValue,"opennewwindow" ,
translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Zerotier.com\" onclick=\"window.open('https://my.zerotier.com/network')\" />"))
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

View File

@ -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

View File

@ -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)))

View File

@ -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)

View File

@ -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))

View File

@ -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) ; \

View File

@ -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

View File

@ -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 <kuoruan@gmail.com>
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))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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

View File

@ -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 \

View File

@ -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})