From c180dd2a1baa340322ff50857efd0ba43c1aaab0 Mon Sep 17 00:00:00 2001
From: hellcat
覆盖".$sNodeZone."等多个区域。
+复制下方的v2ray/Clash订阅链接,在客户端添加即可正常使用。
+ ";
+
+ return response()->json($sContent);
+ }
+
+}
diff --git a/app/Models/ArticleTemplateFreenode.php b/app/Models/ArticleTemplateFreenode.php
new file mode 100755
index 00000000..fb7d6b8f
--- /dev/null
+++ b/app/Models/ArticleTemplateFreenode.php
@@ -0,0 +1,24 @@
+toArray();
+//
+// foreach ($aSelf as &$aSelfRow) {
+// unset($aSelfRow["content"]);
+// }
+//
+// return $aSelf;
+// }
+
+
+}
diff --git a/app/Services/CountrySpeedService.php b/app/Services/CountrySpeedService.php
new file mode 100755
index 00000000..ca8140e3
--- /dev/null
+++ b/app/Services/CountrySpeedService.php
@@ -0,0 +1,70 @@
+get();
+
+ $oDate = Carbon::now();
+ $sDateCN = $oDate->format('n月j日');
+ $sYear = date("Y");
+
+ $sCountrySpeed = CountrySpeedService::fn_b();
+
+ $sToken = FreenodeHelperService::tokenToday();
+
+ $aTags = [
+ "Shadowrocket",
+ "Quantumult",
+ "Clash",
+ "SSR",
+ "节点",
+ "订阅链接",
+ "免费节点",
+ "v2ray",
+ "SSR",
+ ];
+
+ $aResult = [];
+ $aResult["site_code_short"] = '';
+ $aResult["article"] = [
+ "title" => "",
+ "title_sub" => "",
+ "content" => "",
+ "tags" => $aTags,
+ "7like" => rand(5, 55),
+ ];
+
+ foreach ($oSites as $oSite) {
+ $aResult["site_code_short"] = $oSite->code_short;
+ $oArticleTemplate = ArticleTemplateFreenode::where("group_code", $oSite->group_code)->first();
+
+ $aSiteConfig = json_decode($oSite->config, true);
+ $sTelegramLink = $aSiteConfig["telegram"];
+ $aShipCode = $aSiteConfig["ship_code"];
+ $aSiteFnClient = $aSiteConfig["freenode_client"];
+
+ $aDylj = [];
+ foreach ($aSiteFnClient as $sSiteFnClient) {
+ $sFeedLink = "https://".FreenodeHelperService::urlFeedToday($oSite->code_short, $sSiteFnClient);
+ $str = "";
+ $str .= "".$sSiteFnClient."订阅链接:\n\n";
+ $str .= "
+ ".$sFeedLink."";
+ $aDylj[$sSiteFnClient] = $str;
+ }
+//
+//
+// https://cfn.loc/sub/20260204-v2ray.txt
+//
+//
+ $sDylj = implode("\n\n", $aDylj);
+
+ $sJctj = "";
+ foreach ($aShipCode as $sShipCode) {
+ $sJctj .= "
标签包裹 + $paragraphs = array_map(function($paragraph) { + return '
' . trim($paragraph) . '
'; + }, $paragraphs); + + // 使用 implode 拼接成一个字符串 + return implode('', $paragraphs); + } + + +} diff --git a/app/Services/Cron/FreenodeMerge.php b/app/Services/Cron/FreenodeMerge.php index f87fa196..97c1637c 100755 --- a/app/Services/Cron/FreenodeMerge.php +++ b/app/Services/Cron/FreenodeMerge.php @@ -253,7 +253,7 @@ final class FreenodeMerge } } - $oSiteMap = ModelSiteMap::where("group_code", "fn_a")->get(); + $oSiteMap = ModelSiteMap::whereIn("group_code", ["fn_a", "fn_b"])->get(); if ($oSiteMap->isEmpty()) { throw new \Exception("没找到siteMap的fn_a组?"); diff --git a/app/Services/Cron/FreenodeSync.php b/app/Services/Cron/FreenodeSync.php index 92ca3aca..51341458 100755 --- a/app/Services/Cron/FreenodeSync.php +++ b/app/Services/Cron/FreenodeSync.php @@ -7,6 +7,7 @@ namespace App\Services\Cron; use App\Models\SiteMap as ModelSiteMap; use App\Services\TomTool\Telegram\Slave as TeleSlave; use App\Services\TomTool\HttpV2; +use Illuminate\Support\Facades\Http; final class FreenodeSync { @@ -54,4 +55,118 @@ final class FreenodeSync echo " - ok \n"; } + + static function nodehub() + { + echo "\nFeenodeSync::nodehub() - 开始 \n"; + + $sDirBase = $_ENV["dir_base"]; + + $oFnSiteList = ModelSiteMap::where("group_code", "nodehub")->get(); + + $aResultAll = []; + foreach ($oFnSiteList as $oFnSite) { + + $aSiteConfig = json_decode($oFnSite->config, true); + $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? []; + $aSiteApi = json_decode($oFnSite->api_path, true); + $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? ""; + + $aFnContent = []; + foreach ($aSiteConfigFnClient as $aSiteConfigFnClientRow) { + $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt"; + + if (!file_exists($sFilePath)) { + $sMsg = "freenodeSync的run没有当天文件".$sFilePath; + TeleSlave::warn()->send($sMsg); + echo "\n - ".$sMsg; + continue; + } + + $aFnContent[$aSiteConfigFnClientRow] = file_get_contents($sFilePath); + + } + + $sApiUrl = "https://".$oFnSite->url."/".$sSiteApiFreenodeReceive; //// test + $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aFnContent)->enableJsonSend()->send(); + $aResult = json_decode($sResult, true); + + if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) { + $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name; + echo $sMsg.$sResult; + TeleSlave::warn()->setMsgS($sMsg)->send(); + continue; + } + + if (isset($aResult["sMsg"])) { + $sMsg = json_encode($aResult["sMsg"]); + TeleSlave::notify()->setMsgS($sMsg)->send(); + } else { + TeleSlave::log()->setMsgS("nodehub同步完成")->send(); + } + + } + + echo " - 完成 \n"; + } + +// static function run_b() +// { +// echo "\nFeenodeSync::run_b() - 开始 \n"; +// +// $sDirBase = $_ENV["dir_base"]; +// +// $oFnSiteList = ModelSiteMap::where("group_code", "fn_b")->get(); +// $oSiteNodehub = ModelSiteMap::where("code", "nodehub")->first(); +// $aSiteNodehubConfig = json_decode($oSiteNodehub->config ?? '', true); +// +// $aFreenodeClient = $aSiteNodehubConfig["freenode_client"] ?? []; +// $aNodehubApis = json_decode($oSiteNodehub->api_path, true); +// $sSiteApiFreenodeReceive = $aNodehubApis["freenode_receive"] ?? ""; +// +// $aResultAll = []; +// foreach ($oFnSiteList as $oFnSite) { +// +//// $aSiteConfig = json_decode($oFnSite->config, true); +//// $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? []; +//// $aSiteConfigFnClient = ["clash", "v2ray"]; +//// $aSiteApi = json_decode($oFnSite->api_path, true); +//// $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? ""; +// +// $aData = []; +// $aData["site_code_short"] = $oFnSite->code_short; +// foreach ($aFreenodeClient as $aSiteConfigFnClientRow) { +// $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt"; +// +// if (!file_exists($sFilePath)) { +// $sMsg = "freenodeSync的run没有当天文件".$sFilePath; +// TeleSlave::warn()->send($sMsg); +// echo "\n - ".$sMsg; +// continue; +// } +// +// $aData["raw"][$aSiteConfigFnClientRow] = file_get_contents($sFilePath); +// } +// +// $sApiUrl = "https://".$oSiteNodehub->url."/".$sSiteApiFreenodeReceive; +//// tomd($sApiUrl, 1); +// $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend()->send(); +// $aResult = json_decode($sResult, true); +// +// if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) { +// $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name."->".$sResult; +// echo $sMsg; +//// TeleSlave::warn()->setMsgS($sMsg)->send(); +// continue; +// } +// +// if (isset($aResult["sMsg"])) { +// $sMsg = json_encode($aResult["sMsg"]); +//// TeleSlave::warn()->setMsgS($sMsg)->send(); +// } +// +// } +// +// echo " - 完成 \n"; +// } } diff --git a/app/Services/FreenodeHelperService.php b/app/Services/FreenodeHelperService.php new file mode 100644 index 00000000..1a31cff4 --- /dev/null +++ b/app/Services/FreenodeHelperService.php @@ -0,0 +1,47 @@ + (int) env('freenode_speed_min', 0), + 'speed_max' => (int) env('freenode_speed_max', 0), + 'count_min' => (int) env('freenode_count_min', 0), + 'count_max' => (int) env('freenode_count_max', 0), + +]; diff --git a/config/path.php b/config/path.php new file mode 100755 index 00000000..358a7bcd --- /dev/null +++ b/config/path.php @@ -0,0 +1,7 @@ + env("url_nodehub_base"), + +]; diff --git a/routes/web.php b/routes/web.php index 21379db6..d6faa9bb 100755 --- a/routes/web.php +++ b/routes/web.php @@ -19,10 +19,13 @@ use App\Http\Controllers\Api\GithubController; use App\Services\OpenApi\Telegram as ServiceOpenApiTelegram; use App\Services\Article\Schema as ServiceArticleSchema; use App\Http\Controllers\Api\FreenodeController as ApiFreenodeController; +use App\Http\Controllers\Api\v1\FreenodeCountrySpeedController; //Route::get('/', [ArticleListController::class, 'fn'])->middleware('test'); // /api/telegram/post +Route::any('/api/v1/freenode/country_speed', [FreenodeCountrySpeedController::class, 'build']); + Route::any('/api/telegram/post', [ServiceOpenApiTelegram::class, 'post']); Route::any('/api/article/schema/build', [ServiceArticleSchema::class, 'api_buildArticle']); Route::any('/api/article/schema/build/receive', [ServiceArticleSchema::class, 'api_build_receive']);