update 2024-11-24 09:42:42

This commit is contained in:
kenzok8 2024-11-24 09:42:42 +08:00
parent 40f3577664
commit 24663b8d32
12 changed files with 108 additions and 363 deletions

View File

@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_MAINTAINER:=Thaolga <https://github.com/Thaolga/luci-app-nekobox> PKG_MAINTAINER:=Thaolga <https://github.com/Thaolga/luci-app-nekobox>
PKG_NAME:=luci-app-nekobox PKG_NAME:=luci-app-nekobox
PKG_VERSION:=1.5.4 PKG_VERSION:=1.5.5
PKG_RELEASE:=cn PKG_RELEASE:=cn
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
@ -60,8 +60,6 @@ endef
define Package/$(PKG_NAME)/postinst define Package/$(PKG_NAME)/postinst
#!/bin/sh #!/bin/sh
if [ -f "/tmp/neko/neko.bak" ]; then if [ -f "/tmp/neko/neko.bak" ]; then
cp -rf "/tmp/neko/core/mihomo" "/etc/neko/core/mihomo"
chmod 0755 /etc/neko/core/mihomo
cp -rf "/tmp/neko/geoip.metadb" "/etc/neko/geoip.metadb" cp -rf "/tmp/neko/geoip.metadb" "/etc/neko/geoip.metadb"
cp -rf "/tmp/neko/geosite.db" "/etc/neko/geosite.db" cp -rf "/tmp/neko/geosite.db" "/etc/neko/geosite.db"

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.4"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="186" height="20" role="img" aria-label="Current Version: v1.5.5">
<title>Current Version: v1.5.4</title> <title>Current Version: v1.5.5</title>
<linearGradient id="s" x2="0" y2="100%"> <linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/> <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/> <stop offset="1" stop-opacity=".1"/>
@ -15,7 +15,7 @@
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"> <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="700" style="letter-spacing: -5;">Current Version</text> <text aria-hidden="true" x="495" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="700" style="letter-spacing: -5;">Current Version</text>
<text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="700" style="letter-spacing: -5;">Current Version</text> <text x="495" y="140" transform="scale(.1)" fill="#fff" textLength="700" style="letter-spacing: -5;">Current Version</text>
<text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.4</text> <text aria-hidden="true" x="1405" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="600" style="letter-spacing: -3;">v1.5.5</text>
<text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.4</text> <text x="1405" y="140" transform="scale(.1)" fill="#fff" textLength="600" style="letter-spacing: -3;">v1.5.5</text>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -3,7 +3,7 @@
// NEKO CONFIGURATION // NEKO CONFIGURATION
$neko_dir="/etc/neko"; $neko_dir="/etc/neko";
$neko_www="/www/nekobox"; $neko_www="/www/nekobox";
$neko_bin="$neko_dir/core/mihomo"; $neko_bin="/usr/bin/mihomo";
$neko_theme= exec("cat $neko_www/lib/theme.txt"); $neko_theme= exec("cat $neko_www/lib/theme.txt");
$neko_status=exec("uci -q get neko.cfg.enabled"); $neko_status=exec("uci -q get neko.cfg.enabled");

View File

@ -18,13 +18,13 @@ function getCurrentVersion() {
function getLatestVersion() { function getLatestVersion() {
$url = "https://github.com/Thaolga/openwrt-nekobox/releases"; $url = "https://github.com/Thaolga/openwrt-nekobox/releases";
$html = shell_exec("curl -m 10 -s $url"); $output = shell_exec("wget -qO- $url");
if ($html === null || empty($html)) { if ($output === null || empty($output)) {
return "Error"; return "Error";
} }
preg_match('/\/releases\/tag\/([\d\.]+)/', $html, $matches); preg_match('/\/releases\/tag\/([\d\.]+)/', $output, $matches);
if (isset($matches[1])) { if (isset($matches[1])) {
return cleanVersion($matches[1]); return cleanVersion($matches[1]);
} }
@ -33,8 +33,8 @@ function getLatestVersion() {
} }
function cleanVersion($version) { function cleanVersion($version) {
$version = explode('-', $version)[0]; $version = explode('-', $version)[0];
return preg_replace('/[^0-9\.]/', '', $version); return preg_replace('/[^0-9\.]/', '', $version);
} }
$currentVersion = getCurrentVersion(); $currentVersion = getCurrentVersion();

View File

@ -60,7 +60,7 @@ if (json_last_error() !== JSON_ERROR_NONE) {
$latest_version = $data['tag_name'] ?? ''; $latest_version = $data['tag_name'] ?? '';
$current_version = ''; $current_version = '';
$install_path = '/etc/neko/core/mihomo'; $install_path = '/usr/bin/mihomo';
$temp_file = '/tmp/mihomo.gz'; $temp_file = '/tmp/mihomo.gz';
if (file_exists($install_path)) { if (file_exists($install_path)) {

View File

@ -190,7 +190,7 @@ if (isset($_POST['update'])) {
if (!empty($url)) { if (!empty($url)) {
$finalPath = $subscriptionPath . $customFileName; $finalPath = $subscriptionPath . $customFileName;
$command = "curl -fsSL -o {$finalPath} {$url}"; $command = "wget -q --show-progress -O {$finalPath} {$url}";
exec($command . ' 2>&1', $output, $return_var); exec($command . ' 2>&1', $output, $return_var);
if ($return_var === 0) { if ($return_var === 0) {

View File

@ -197,7 +197,7 @@ if (isset($_POST['saveSubscription'])) {
if (!empty($url)) { if (!empty($url)) {
$finalPath = $configPath . $customFileName; $finalPath = $configPath . $customFileName;
$command = sprintf( $command = sprintf(
"curl -fsSL -o %s %s", "wget -q --show-progress -O %s %s",
escapeshellarg($finalPath), escapeshellarg($finalPath),
escapeshellarg($url) escapeshellarg($url)
); );
@ -222,7 +222,6 @@ $updateCompleted = isset($_POST['saveSubscription']);
<?php <?php
$subscriptionPath = '/etc/neko/config/'; $subscriptionPath = '/etc/neko/config/';
$dataFile = $subscriptionPath . 'subscription_data.json'; $dataFile = $subscriptionPath . 'subscription_data.json';
$message = ""; $message = "";
$defaultSubscriptions = [ $defaultSubscriptions = [
[ [
@ -269,23 +268,27 @@ if (isset($_POST['update_index'])) {
$originalContent = file_exists($finalPath) ? file_get_contents($finalPath) : ''; $originalContent = file_exists($finalPath) ? file_get_contents($finalPath) : '';
$ch = curl_init($subscriptionUrl); $command = sprintf(
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); "wget -q --header='Accept-Charset: utf-8' -O %s %s",
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); escapeshellarg($finalPath),
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); escapeshellarg($subscriptionUrl)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); );
$fileContent = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($fileContent === false) { exec($command . ' 2>&1', $output, $return_var);
$message = "订阅 $index 无法下载文件。cURL 错误信息: " . $error;
if ($return_var !== 0) {
$message = "订阅 $index 无法下载文件。wget 错误信息: " . implode("\n", $output);
} else { } else {
$fileContent = str_replace("\xEF\xBB\xBF", '', $fileContent); $fileContent = file_get_contents($finalPath);
$fileContent = str_replace("\xEF\xBB\xBF", '', $fileContent);
if (!isUtf8($fileContent)) {
$fileContent = utf8_encode($fileContent);
}
$parsedData = json_decode($fileContent, true); $parsedData = json_decode($fileContent, true);
if ($parsedData === null && json_last_error() !== JSON_ERROR_NONE) { if ($parsedData === null && json_last_error() !== JSON_ERROR_NONE) {
file_put_contents($finalPath, $originalContent); file_put_contents($finalPath, $originalContent);
$message = "订阅 $index 解析 JSON 数据失败!错误信息: " . json_last_error_msg(); $message = "订阅 $index 解析 JSON 数据失败!错误信息: " . json_last_error_msg();
} else { } else {
if (isset($parsedData['inbounds'])) { if (isset($parsedData['inbounds'])) {
@ -300,29 +303,29 @@ if (isset($_POST['update_index'])) {
} }
$newInbounds[] = [ $newInbounds[] = [
"tag" => "tun", "tag" => "tun",
"type" => "tun", "type" => "tun",
"inet4_address" => "172.19.0.0/30", "inet4_address" => "172.19.0.0/30",
"inet6_address" => "fdfe:dcba:9876::0/126", "inet6_address" => "fdfe:dcba:9876::0/126",
"stack" => "system", "stack" => "system",
"auto_route" => true, "auto_route" => true,
"strict_route" => true, "strict_route" => true,
"sniff" => true, "sniff" => true,
"platform" => [ "platform" => [
"http_proxy" => [ "http_proxy" => [
"enabled" => true, "enabled" => true,
"server" => "0.0.0.0", "server" => "0.0.0.0",
"server_port" => 7890 "server_port" => 7890
]
] ]
]
]; ];
$newInbounds[] = [ $newInbounds[] = [
"tag" => "mixed", "tag" => "mixed",
"type" => "mixed", "type" => "mixed",
"listen" => "0.0.0.0", "listen" => "0.0.0.0",
"listen_port" => 7890, "listen_port" => 7890,
"sniff" => true "sniff" => true
]; ];
$parsedData['inbounds'] = $newInbounds; $parsedData['inbounds'] = $newInbounds;
@ -349,6 +352,11 @@ if (isset($_POST['update_index'])) {
file_put_contents($dataFile, json_encode($subscriptionData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); file_put_contents($dataFile, json_encode($subscriptionData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
} }
} }
function isUtf8($string) {
$encoded = utf8_encode($string);
return $encoded === $string;
}
?> ?>
<!doctype html> <!doctype html>

View File

@ -20,37 +20,27 @@ function downloadFile($url, $destination, $retries = 3, $timeout = 30) {
mkdir($dir, 0755, true); mkdir($dir, 0755, true);
} }
$ch = curl_init($url); $command = sprintf(
curl_setopt_array($ch, [ "wget -q --timeout=%d --tries=%d --header='Accept-Charset: utf-8' -O %s %s",
CURLOPT_RETURNTRANSFER => true, $timeout,
CURLOPT_FOLLOWLOCATION => true, $retries,
CURLOPT_TIMEOUT => $timeout, escapeshellarg($destination),
CURLOPT_SSL_VERIFYPEER => false, escapeshellarg($url)
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' );
]);
$content = curl_exec($ch); $output = [];
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $return_var = null;
exec($command, $output, $return_var);
if ($content === false) { if ($return_var !== 0) {
throw new Exception("下载失败: " . curl_error($ch)); throw new Exception("wget 错误信息: " . implode("\n", $output));
} }
if ($httpCode !== 200) {
throw new Exception("HTTP 响应码错误: $httpCode");
}
if (file_put_contents($destination, $content) === false) {
throw new Exception("无法保存文件到 $destination");
}
curl_close($ch);
logMessage(basename($destination), "下载并保存成功"); logMessage(basename($destination), "下载并保存成功");
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
logMessage(basename($destination), "$attempt 次尝试失败: " . $e->getMessage()); logMessage(basename($destination), "$attempt 次尝试失败: " . $e->getMessage());
curl_close($ch);
if ($attempt === $retries) { if ($attempt === $retries) {
logMessage(basename($destination), "所有下载尝试均失败"); logMessage(basename($destination), "所有下载尝试均失败");
@ -87,4 +77,4 @@ echo "\n配置文件更新完成\n\n";
foreach ($logMessages as $message) { foreach ($logMessages as $message) {
echo $message . "\n"; echo $message . "\n";
} }
?> ?>

View File

@ -174,22 +174,12 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
{ {
"tag": "🌀 手动切换1", "tag": "🌀 手动切换",
"type": "selector",
"use_all_providers": true,
"includes": [
],
"excludes": "(?i)网站|地址|剩余|过期|时间|有效|套餐|到期"
},
{
"tag": "🌀 手动切换2",
"type": "selector", "type": "selector",
"use_all_providers": true, "use_all_providers": true,
"includes": [ "includes": [
@ -217,8 +207,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -233,8 +222,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -249,8 +237,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -265,8 +252,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -281,8 +267,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -353,8 +338,7 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🌀 手动切换1", "🌀 手动切换",
"🌀 手动切换2",
"🐸 其他地区" "🐸 其他地区"
] ]
}, },
@ -420,6 +404,9 @@
"🇰🇷 韩国节点", "🇰🇷 韩国节点",
"🇸🇬 狮城节点", "🇸🇬 狮城节点",
"🇺🇸 美国节点", "🇺🇸 美国节点",
"🐸 其他地区",
"♻️ 自动选择",
"🌀 手动切换",
"📹 YouTube", "📹 YouTube",
"🎵 TikTok", "🎵 TikTok",
"🎥 Netflix", "🎥 Netflix",
@ -452,8 +439,7 @@
"🚀 节点选择", "🚀 节点选择",
"🎯 全球直连", "🎯 全球直连",
"🐸 其他地区", "🐸 其他地区",
"🌀 手动切换1", "🌀 手动切换"
"🌀 手动切换2"
] ]
}, },
{ {
@ -649,6 +635,13 @@
], ],
"outbound": "🍎 苹果服务" "outbound": "🍎 苹果服务"
}, },
{
"rule_set": [
"geoip-tiktok",
"geosite-tiktok"
],
"outbound": "🎵 TikTok"
},
{ {
"rule_set": [ "rule_set": [
"google-cn" "google-cn"
@ -673,13 +666,6 @@
], ],
"outbound": "📹 YouTube" "outbound": "📹 YouTube"
}, },
{
"rule_set": [
"geoip-tiktok",
"geosite-tiktok"
],
"outbound": "🎵 TikTok"
},
{ {
"rule_set": [ "rule_set": [
"geoip-netflix", "geoip-netflix",

View File

@ -3,7 +3,7 @@
neko_dir="/etc/neko" neko_dir="/etc/neko"
neko_tmp_dir="$neko_dir/tmp" neko_tmp_dir="$neko_dir/tmp"
neko_core="$neko_dir/core" neko_core="$neko_dir/core"
neko_bin="$neko_dir/core/mihomo" neko_bin="/usr/bin/mihomo"
neko_www="/www/nekobox" neko_www="/www/nekobox"
neko_config=`cat $neko_www/lib/selected_config.txt` neko_config=`cat $neko_www/lib/selected_config.txt`
@ -21,31 +21,20 @@ neko_status=`uci -q get neko.cfg.enabled`
php_pid_path="$neko_tmp_dir/php_pid.txt" php_pid_path="$neko_tmp_dir/php_pid.txt"
log="$neko_dir/tmp/log.txt" log="$neko_dir/tmp/log.txt"
singbox_bin="/usr/bin/sing-box"
singbox_log="/var/log/singbox_log.txt"
singbox_config_dir="/etc/neko/config"
singbox_pid_path="$neko_tmp_dir/singbox_pid.txt"
core_ver="neko"
url_core="https://github.com/Thaolga/neko/releases/download/core_neko"
url_geo="https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest"
neko_ver(){ neko_ver(){
neko_version="1.5.4" neko_version="1.5.5"
} }
logs() { logs() {
echo "[ `date +%T` ] $1" echo "[ `date +%T` ] $1"
echo "[ `date +%T` ] $1" >> $log if [ -z $2 ]; then
} echo "[ `date +%T` ] $1" >> $log
elif [ $2 -eq 2 ]; then
neko_logs() { echo "[ `date +%T` ] $1" > $log
echo "[ `date +%T` ] $1" >> $neko_log elif [ $2 -eq 3 ]; then
} echo "[ `date +%T` ] $1" >> $log
exit 1
singbox_logs() { fi
local timestamp=$(date +"%T")
echo -e "[ $timestamp ] $1" >> "$neko_dir/tmp/log.txt"
} }
check_depedency() { check_depedency() {
@ -136,129 +125,6 @@ check_depedency() {
fi fi
} }
files_check() {
arch=`uname -m`
geoip_path="${neko_dir}/geoip.metadb"
geosite_path="${neko_dir}/geosite.db"
case "$arch" in
aarch64)
arch="arm64"
;;
arm)
arch="armv7"
;;
x86_64)
arch="amd64"
;;
mips)
arch="mips_24"
;;
*)
arch="0"
;;
esac
if [ $arch == "0" ] ; then
logs "- ERROR!!! Arch not supported"
else
if [ -f ${neko_bin} ]; then
logs "- Mihomo OK" 1
core_version=`$neko_bin -v | head -1 | awk '{print $1 " " $5 " " $3}'`
logs "- Core Detected : $core_version"
else
logs "- Downloading Mihomo Binary - $arch"
wget -q --no-check-certificate -O ${neko_dir}/core/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
gzip -d ${neko_dir}/core/mihomo.gz
fi
if [ -f ${geoip_path} ]; then
logs "- GeoIP OK" 1
else
logs "- Downloading GeoIP"
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
fi
if [ -f ${geosite_path} ]; then
logs "- GeoSite OK" 1
else
logs "- Downloading GeoSite"
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
fi
fi
for file in "$neko_core"/*; do
if [ ! -x "$file" ]; then
chmod +x "$file"
fi
done
}
singbox_start(){
singbox_logs() {
local timestamp=$(date +"%T")
echo -e "[ $timestamp ] - $1" >> "$neko_dir/tmp/log.txt"
}
singbox_logs "Starting Sing-box"
singbox_logs "- Auto Restart Firewall : ON"
local config_file="$singbox_config_dir/config.json"
singbox_logs "Config file: $config_file"
singbox_logs "Creating start script"
create_start_script "$config_file"
local singbox_version=$($singbox_bin version)
singbox_logs "Sing-box version: $singbox_version"
(while true; do
$singbox_bin run -c $config_file 2>&1 | while read line; do
singbox_logs "$line"
done
done) &
sleep 1
singbox_pid=$(pgrep sing-box)
if [[ -n $singbox_pid ]]; then
singbox_logs "- Sing-box Started. PID : $singbox_pid"
echo $singbox_pid > $singbox_pid_path
uci set neko.cfg.singbox_enabled='1'
uci commit neko
else
singbox_logs "- Failed to start Sing-box"
fi
singbox_logs "Done"
}
singbox_stop(){
logs "Stopping Sing-box" 2
local pid=$(pgrep -f "$singbox_bin")
if [ -n "$pid" ] ; then
logs "- Killing Sing-box PID: $pid"
kill -15 $pid
pkill -f "while.*sing-box"
sleep 2
if kill -0 $pid 2>/dev/null; then
logs "- Sing-box didn't stop gracefully. Forcing stop."
kill -9 $pid
pkill -9 -f "while.*sing-box"
fi
rm -f $singbox_pid_path
uci set neko.cfg.singbox_enabled='0'
uci commit neko
logs "Sing-box has been stopped"
else
logs "Sing-box is not Running"
fi
}
singbox_restart(){
logs "Restarting Sing-box" 2
singbox_stop
sleep 1
singbox_start
logs "Restarting Sing-box - Done"
}
neko_start(){ neko_start(){
neko_ver neko_ver
logs "Starting Neko v.$neko_version" 2 logs "Starting Neko v.$neko_version" 2
@ -293,6 +159,7 @@ neko_start(){
logs "- Restarting Firewall" logs "- Restarting Firewall"
$firewall restart $firewall restart
$neko_bin -f $neko_config -d $neko_dir >> $neko_log & $neko_bin -f $neko_config -d $neko_dir >> $neko_log &
sleep 1 sleep 1
neko_pid=`pgrep mihomo` neko_pid=`pgrep mihomo`
if [[ -z $neko_pid ]]; then if [[ -z $neko_pid ]]; then
@ -352,7 +219,6 @@ neko_stop(){
kill $rpid kill $rpid
fi fi
logs "Neko has Disabled" logs "Neko has Disabled"
logs "Neko Disabled." > $neko_log
else else
logs "Neko is not Running" logs "Neko is not Running"
fi fi
@ -389,21 +255,12 @@ while getopts ":skrpcvh" signal ; do
s) s)
neko_start neko_start
;; ;;
S)
singbox_start
;;
k) k)
neko_stop neko_stop
;; ;;
K)
singbox_stop
;;
r) r)
neko_restart neko_restart
;; ;;
R)
singbox_restart
;;
p) p)
php_start php_start
;; ;;
@ -413,18 +270,18 @@ while getopts ":skrpcvh" signal ; do
v) v)
neko_ver neko_ver
neko_checknewver neko_checknewver
echo "v.$neko_version $strversion" echo "v.$neko_version"
;; ;;
h) h)
echo "Neko" echo "Neko"
echo " -s : Start Mihomo Proxy and Sing-box" echo " -s : Start Mihomo Proxy"
echo " -p : Start PHP Server" echo " -p : Start PHP Server"
echo " -k : Kill/Stop Mihomo Proxy and Sing-box" echo " -k : Kill/Stop Mihomo Proxy"
echo " -r : Restart Mihomo Proxy and Sing-box" echo " -r : Restart Mihomo Proxy"
echo " -c : cleanup (kill mihomo, sing-box, and php server)" echo " -c : cleanup (kill mihomo and php server)"
echo " -v : Version" echo " -v : Version"
echo " -h : help (this text)" echo " -h : help (this text)"
echo "Please Use ROOT User" echo "Please Use ROOT User"
;; ;;
esac esac
done done

View File

@ -5,23 +5,8 @@
arch=`uname -m` arch=`uname -m`
neko_dir="/etc/neko" neko_dir="/etc/neko"
tmp_dir="/tmp" tmp_dir="/tmp"
log="$neko_dir/tmp/log.txt"
core_ver="neko" echo "[ `date +%T` ] - Checking Files..."
url_core="https://github.com/Thaolga/neko/releases/download/core_neko"
url_geo="https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest"
geoip_path="${neko_dir}/geoip.metadb"
geosite_path="${neko_dir}/geosite.db"
neko_bin="${neko_dir}/core/mihomo"
rpid=`pgrep "neko/core"`
if [[ -n $rpid ]] ; then
kill $rpid
fi
echo "[ `date +%T` ] - Checking Files"
files_check() { files_check() {
uci set uhttpd.main.index_page='index.php' uci set uhttpd.main.index_page='index.php'
@ -29,89 +14,14 @@ files_check() {
uci commit uhttpd uci commit uhttpd
/etc/init.d/uhttpd restart /etc/init.d/uhttpd restart
case "$arch" in
aarch64)
arch="arm64"
;;
arm)
arch="armv7"
;;
x86_64)
arch="amd64"
;;
mips)
arch="mips_24"
;;
*)
arch="0"
;;
esac
if [ $arch == "0" ] ; then
echo "[ `date +%T` ] - ERROR!!! Arch not supported"
else
if [ -f ${neko_bin} ]; then
echo "[ `date +%T` ] - Mihomo OK"
else
echo "[ `date +%T` ] - Downloading Mihomo Binary - $arch"
echo "[ `date +%T` ] - Downloading Mihomo Binary - $arch" >> $log
wget -q --no-check-certificate -O ${neko_dir}/core/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
gzip -d ${neko_dir}/core/mihomo.gz
fi
if [ -f ${geoip_path} ]; then
echo "[ `date +%T` ] - GeoIP OK"
else
echo "[ `date +%T` ] - Downloading GeoIP"
echo "[ `date +%T` ] - Downloading GeoIP" >> $log
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
fi
if [ -f ${geosite_path} ]; then
echo "[ `date +%T` ] - GeoSite OK"
else
echo "[ `date +%T` ] - Downloading GeoSite"
echo "[ `date +%T` ] - Downloading GeoSite" >> $log
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
fi
fi
chmod +x $neko_dir/core/mihomo
} }
if [ -f "/tmp/neko/neko.bak" ]; then if [ -f "/tmp/neko/neko.bak" ]; then
echo "[ `date +%T` ] - Old Files Detected" echo "[ `date +%T` ] - Old Configs"
if [ -f "/tmp/neko/core/mihomo" ]; then echo "[ `date +%T` ] - Restoring..."
cp -rf "/tmp/neko/core/mihomo" "/etc/neko/core/mihomo"
else
echo "mihomo Not Detected, Downloading"
mkdir ${tmp_dir}/neko
wget -q --no-check-certificate -O ${tmp_dir}/neko/mihomo.gz ${url_core}/mihomo-linux-${arch}-${core_ver}.gz
gzip -d ${tmp_dir}/neko/mihomo.gz
cp -rf ${tmp_dir}/neko/mihomo ${neko_dir}/core/mihomo
rm -rf ${tmp_dir}/neko/mihomo
fi
chmod 0755 /etc/neko/core/mihomo
if [ -f "/tmp/neko/geoip.metadb" ]; then
cp -rf "/tmp/neko/geoip.metadb" "/etc/neko/geoip.metadb"
else
echo "GeoIP Not Detected, Downloading"
wget -q --no-check-certificate -O ${geoip_path} ${url_geo}/geoip.metadb
fi
if [ -f "/tmp/neko/geosite.db" ]; then
cp -rf "/tmp/neko/geosite.db" "/etc/neko/geosite.db"
else
echo "GeoSite Not Detected, Downloading"
wget -q --no-check-certificate -O ${neko_dir} ${url_geo}/geosite.db
fi
if [ -f "/tmp/neko/cache.db" ]; then if [ -f "/tmp/neko/cache.db" ]; then
cp -rf "/tmp/neko/cache.db" "/etc/neko/cache.db" cp -rf "/tmp/neko/cache.db" "/etc/neko/cache.db"
else
echo "Neko Cache Not Detected, Skipped"
fi fi
cp -rf /tmp/neko/config/* "/etc/neko/config/" cp -rf /tmp/neko/config/* "/etc/neko/config/"
cp -rf /tmp/neko/proxy_provider/* "/etc/neko/proxy_provider/" cp -rf /tmp/neko/proxy_provider/* "/etc/neko/proxy_provider/"
cp -rf /tmp/neko/rule_provider/* "/etc/neko/rule_provider/" cp -rf /tmp/neko/rule_provider/* "/etc/neko/rule_provider/"
@ -120,9 +30,5 @@ else
files_check files_check
fi fi
if [ $arch == "mips_24" ]; then
sed -i "s/#wget/wget/g" /etc/neko/core/neko
fi
uci set neko.cfg.enabled='0' uci set neko.cfg.enabled='0'
uci commit neko uci commit neko

View File

@ -153,7 +153,7 @@ install_core() {
fi fi
current_version='' current_version=''
install_path='/etc/neko/core/mihomo' install_path='/usr/bin/mihomo'
temp_file='/tmp/mihomo.gz' temp_file='/tmp/mihomo.gz'
temp_extract_path='/tmp/mihomo_temp' temp_extract_path='/tmp/mihomo_temp'