alroyso 2 years ago
parent
commit
284e0d4c84

+ 13 - 4
SProxy/CManageNetWork.cpp

@@ -112,8 +112,17 @@ void CManageNetWork::ThreadFun_login(LPARAM lParam)
 	SStringW msg = L"";
 	std::string data;
 	HTTPRET httpstatus = m_base_curl->PostLogin(this->m_username, this->m_password, data);
+	if (httpstatus == HTTPRET::http_user_expired_at)
+	{
+		code = -2;
+		msg = m_base_curl->GetLastErrorW();
 
-	if (httpstatus == http_f) {
+	}
+	else if(httpstatus == HTTPRET::http_user_transfer_enable){
+		code = -3;
+		msg = m_base_curl->GetLastErrorW();
+	} 
+	else if (httpstatus == HTTPRET::http_f) {
 		code = 0;
 		msg = m_base_curl->GetLastErrorW();
 	}
@@ -161,7 +170,7 @@ void CManageNetWork::ThreadFun_Version_Config(LPARAM lParam)
 	int code = 200;
 	SStringW msg = L"ÓÐа汾,µãÎÒÉý¼¶";
 	std::string data;
-	if (!m_base_curl->Version(data)) {
+	if (m_base_curl->Version(data) == HTTPRET::http_f) {
 		code = 0;
 		msg = m_base_curl->GetLastErrorW();
 	}
@@ -193,7 +202,7 @@ void CManageNetWork::ThreadFun_Node_Config(LPARAM lParam)
 		data = "";
 
 		HTTPRET httpstatus = m_base_curl->GetServerNode(data);
-		if (httpstatus == http_f) {
+		if (httpstatus == HTTPRET::http_f) {
 			code = 0;
 			msg = m_base_curl->GetLastErrorW();
 		}
@@ -207,7 +216,7 @@ void CManageNetWork::ThreadFun_Node_Config(LPARAM lParam)
 				break;
 			}
 			httpstatus = m_base_curl->PostLogin(this->m_username, this->m_password, data);
-			if (httpstatus == http_f) {
+			if (httpstatus == HTTPRET::http_f) {
 				code = m_base_curl->GetHttpStatus();
 				msg = m_base_curl->GetLastErrorW();
 				count++;

+ 21 - 11
SProxy/CNetWork.cpp

@@ -5,7 +5,7 @@
 #include <fmt/format.h>
 #include "Logger.h"
 
-CNetWork::CNetWork() : m_http_ret(http_f)
+CNetWork::CNetWork() : m_http_ret(HTTPRET::http_f)
 {
 
 }
@@ -26,10 +26,10 @@ HTTPRET  CNetWork::Version(std::string& data) {
 	std::string text = GetUrl("/api/client/v3/version", p, CApp::getSingletonPtr()->GetUserinfo()->access_token);
 	if (text.empty()) {
 
-		return http_f;
+		return HTTPRET::http_f;
 	}
 	data = text.c_str();
-	return http_yes;
+	return HTTPRET::http_yes;
 }
 
 HTTPRET CNetWork::Refresh(std::string& data) {
@@ -37,28 +37,28 @@ HTTPRET CNetWork::Refresh(std::string& data) {
 	std::string text = GetUrl("/api/client/v3/refresh", p, CApp::getSingletonPtr()->GetUserinfo()->access_token);
 	if (text.empty()) {
 
-		return http_f;
+		return HTTPRET::http_f;
 	}
 	data = text.c_str();
-	return http_yes;
+	return HTTPRET::http_yes;
 }
 
 
 HTTPRET CNetWork::Auth(std::string& data) {
-	return http_yes;
+	return HTTPRET::http_yes;
 }
 HTTPRET CNetWork::GetServerNode(std::string& data) {
 	std::vector<cpr::Parameter> p;
 	std::string text = GetUrl("/api/client/v3/nodes",p,CApp::getSingletonPtr()->GetUserinfo()->access_token);
 	if (text.empty()) {
 
-		return http_f;
+		return HTTPRET::http_f;
 	}
 
 	data = text.c_str();
 
 
-	return http_yes;
+	return HTTPRET::http_yes;
 }
 
 HTTPRET CNetWork::PostLogin(LPCSTR username, LPCSTR password, std::string& data)
@@ -68,13 +68,22 @@ HTTPRET CNetWork::PostLogin(LPCSTR username, LPCSTR password, std::string& data)
 	p.push_back({ "password",password });
 	std::string text = PostUrl("/api/client/v3/login", p);
 	if (text.empty()) {
-
-		return http_f;
+		if (m_http_status == 445)
+		{
+			return HTTPRET::http_user_expired_at;
+		} else if (m_http_status == 446)
+		{
+			return HTTPRET::http_user_transfer_enable;
+		}
+		else {
+			return HTTPRET::http_f;
+		}
+		
 	}
 
 	data = text.c_str();
 
-    return http_yes;
+    return HTTPRET::http_yes;
 }
 
 void CNetWork::SetUrl(LPCSTR url)
@@ -205,6 +214,7 @@ std::string CNetWork::PostUrl(std::string path, std::vector<cpr::Pair> parame, s
 			break;
 		}
 		else {
+
 			m_http_status = r.status_code;
 			if (r.error.message.empty())
 			{

+ 3 - 1
SProxy/CServerList.cpp

@@ -60,6 +60,8 @@ bool CServerList::Init(std::string data)
 				m_serverlist_mode.udp = data[i]["udp"].get<int>();
 				m_serverlist_mode.port = data[i]["port"].get<int>();
 
+				m_serverlist_mode.country_code = data[i]["country_code"].get<std::string>();
+
 				vectlistmode.push_back(m_serverlist_mode);
 			}
 
@@ -107,7 +109,7 @@ void CServerList::MinimumSelectNode()
 	{
 		for each (CServerListMode itme in t)
 		{
-			if (itme.online_users > 0)
+			if (itme.online_users > 0 && strcmp(itme.country_code.c_str(),"hk") == 0)
 			{
 				node_name = itme.name;
 				break;

+ 2 - 0
SProxy/CServerListMode.h

@@ -38,4 +38,6 @@ public:
 	std::string v2_sni;
 
 	std::string sni;
+
+	std::string country_code;
 };

+ 1 - 1
SProxy/ClashApi.cpp

@@ -46,7 +46,7 @@ bool ClashApi::RequestConfigUpdate(std::filesystem::path configPath)
 	{
 		cpr::Session   m_cpr_session;
 		nlohmann::json j = {
-			{"path",configPath.string()}
+			{"path",Utf16ToUtf8(configPath.wstring())}
 		};
 		// cpr::Put(cpr::Url{ url }, cpr::Body{ j.dump() });
 		auto url = m_api_base_url + "/configs";

+ 4 - 1
SProxy/IBaseCurl.h

@@ -1,12 +1,15 @@
 #pragma once
 
-enum HTTPRET
+enum struct  HTTPRET
 {
 	http_no = 0,
 	http_f,
 	http_yes,
 	http_start,
 	http_end,
+	http_user_expired_at,
+	http_user_transfer_enable
+
 };
 
 

BIN
SProxy/LoginDlg.cpp


BIN
SProxy/MainDlg.cpp


+ 1 - 1
SProxy/comm.h

@@ -21,4 +21,4 @@ constexpr auto CONNECT_NODE_MSG = L"
 constexpr auto SUEECS_NODE_MSG = L"»ñÈ¡½Úµã³É¹¦.."; 
 
 
-constexpr auto VERSION = L"1.1.2";
+constexpr auto VERSION = L"1.1.3";