Compare commits

..

6 Commits

Author SHA1 Message Date
sanasol
fb90277be9 Fix Arabic RTL support: correct locale code and CSS syntax
- Rename ar-AR to ar-SA (valid BCP 47 code for Saudi Arabia)
- Fix missing dot in CSS selector: .news-section .news-header
- Add trailing newline to ar-SA.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 23:00:08 +01:00
sanasol
27c220a757 Merge pull request 'Arabic and RTL support added' (#1) from Yugurten/hytale-f2p:develop into develop 2026-02-22 21:58:25 +00:00
Finix
30929ee0da Arabic and RTL support added 2026-02-22 19:25:01 +00:00
sanasol
44834e7d12 Bump version to 2.3.8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 23:47:52 +01:00
sanasol
cb7f7e51bf v2.3.8: auto-update agent from GitHub releases, add dl1 mirror fallback
- Agent auto-update: check GitHub releases API for new versions, download
  only when update available, track version in .version file
- Add dl1.htdwnldsan.top as backup-2 mirror in patches config sources
- Add dl1.htdwnldsan.top as primary non-Cloudflare mirror
- Graceful fallback: use existing agent if update check or download fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 23:31:28 +01:00
sanasol
9b20c454d3 v2.3.7: add non-Cloudflare mirror fallback for blocked regions
Users in Russia/Ukraine where Cloudflare IPs are blocked can now
download game files via htdwnldsan.top (direct VPS → MEGA redirect).
Both manifest fetch and archive downloads try mirrors automatically
on ETIMEDOUT/ECONNREFUSED errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 13:21:19 +01:00
8 changed files with 679 additions and 50 deletions

View File

@@ -8,9 +8,10 @@
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link <link
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap" href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap"
rel="stylesheet"> rel="stylesheet">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style-RTL.css">
</head> </head>
<body class="bg-black text-white overflow-hidden font-sans select-none" tabindex="-1"> <body class="bg-black text-white overflow-hidden font-sans select-none" tabindex="-1">

View File

@@ -12,9 +12,18 @@ const i18n = (() => {
{ code: 'ru-RU', name: 'Russian (Russia)' }, { code: 'ru-RU', name: 'Russian (Russia)' },
{ code: 'sv-SE', name: 'Swedish (Sweden)' }, { code: 'sv-SE', name: 'Swedish (Sweden)' },
{ code: 'tr-TR', name: 'Turkish (Turkey)' }, { code: 'tr-TR', name: 'Turkish (Turkey)' },
{ code: 'id-ID', name: 'Indonesian (Indonesia)' } { code: 'id-ID', name: 'Indonesian (Indonesia)' },
{ code: 'ar-SA', name: 'Arabic (Saudi Arabia)' }
]; ];
// RTL languages
const rtlLanguages = ['ar-SA'];
// Check if current language is RTL
function isRTL() {
return rtlLanguages.includes(currentLang);
}
// Load single language file // Load single language file
async function loadLanguage(lang) { async function loadLanguage(lang) {
if (translations[lang]) return true; if (translations[lang]) return true;
@@ -73,6 +82,24 @@ const i18n = (() => {
const key = el.getAttribute('data-i18n-title'); const key = el.getAttribute('data-i18n-title');
el.title = t(key); el.title = t(key);
}); });
// Update RTL layout
updateRTL();
}
// Update RTL layout
function updateRTL() {
const html = document.documentElement;
const body = document.body;
if (isRTL()) {
html.setAttribute('dir', 'rtl');
html.setAttribute('lang', currentLang);
body.classList.add('rtl');
} else {
html.removeAttribute('dir');
html.setAttribute('lang', currentLang);
body.classList.remove('rtl');
}
} }
// Initialize - load saved language only // Initialize - load saved language only
@@ -88,7 +115,8 @@ const i18n = (() => {
t, t,
setLanguage, setLanguage,
getAvailableLanguages: () => availableLanguages, getAvailableLanguages: () => availableLanguages,
getCurrentLanguage: () => currentLang getCurrentLanguage: () => currentLang,
isRTL
}; };
})(); })();

257
GUI/locales/ar-SA.json Normal file
View File

@@ -0,0 +1,257 @@
{
"nav": {
"play": "لعب",
"mods": "المودات",
"news": "الأخبار",
"chat": "دردشة اللاعبين",
"settings": "الإعدادات"
},
"header": {
"playersLabel": "اللاعبون:",
"manageProfiles": "إدارة الملفات الشخصية",
"defaultProfile": "الافتراضي"
},
"install": {
"title": "مشغل اللعب المجاني",
"playerName": "اسم اللاعب",
"playerNamePlaceholder": "أدخل اسمك",
"gameBranch": "إصدار اللعبة",
"releaseVersion": "إصدار نهائي (مستقر)",
"preReleaseVersion": "إصدار تجريبي (تجريبي)",
"customInstallation": "تثبيت مخصص",
"installationFolder": "مجلد التثبيت",
"pathPlaceholder": "الموقع الافتراضي",
"browse": "تصفح",
"installButton": "تثبيت HYTALE",
"installing": "جاري التثبيت..."
},
"play": {
"ready": "جاهز للعب",
"subtitle": "شغل Hytale وابدأ المغامرة",
"playButton": "لعب HYTALE",
"latestNews": "آخر الأخبار",
"viewAll": "عرض الكل",
"checking": "جاري التحقق...",
"play": "بدء"
},
"mods": {
"searchPlaceholder": "البحث عن مودات...",
"myMods": "موداتي",
"previous": "السابق",
"next": "التالي",
"page": "صفحة",
"of": "من",
"modalTitle": "موداتي",
"noModsFound": "لم يتم العثور على مودات",
"noModsFoundDesc": "حاول تعديل معايير البحث",
"noModsInstalled": "لا توجد مودات مثبتة",
"noModsInstalledDesc": "أضف مودات من CurseForge أو استورد ملفات محلية",
"view": "عرض",
"install": "تثبيت",
"installed": "مثبت",
"enable": "تفعيل",
"disable": "تعطيل",
"active": "نشط",
"disabled": "معطل",
"delete": "حذف المود",
"noDescription": "لا يوجد وصف متاح",
"confirmDelete": "هل أنت متأكد أنك تريد حذف \"{name}\"؟",
"confirmDeleteDesc": "لا يمكن التراجع عن هذا الإجراء.",
"confirmDeletion": "تأكيد الحذف",
"apiKeyRequired": "مطلوب مفتاح API",
"apiKeyRequiredDesc": "مطلوب مفتاح CurseForge API لتصفح المودات"
},
"news": {
"title": "كل الأخبار",
"readMore": "اقرأ المزيد"
},
"chat": {
"title": "دردشة اللاعبين",
"pickColor": "اللون",
"inputPlaceholder": "اكتب رسالتك...",
"send": "إرسال",
"online": "متصل",
"charCounter": "{current}/{max}",
"secureChat": "دردشة آمنة - الروابط محجوبة",
"joinChat": "انضمام للدردشة",
"chooseUsername": "اختر اسم مستخدم للانضمام إلى دردشة اللاعبين",
"username": "اسم المستخدم",
"usernamePlaceholder": "أدخل اسم المستخدم...",
"usernameHint": "3-20 حرفاً، حروف، أرقام، و - و _ فقط",
"joinButton": "انضمام",
"colorModal": {
"title": "تخصيص لون اسم المستخدم",
"chooseSolid": "اختر لوناً ثابتاً:",
"customColor": "لون مخصص:",
"preview": "معاينة:",
"previewUsername": "اسم المستخدم",
"apply": "تطبيق اللون"
}
},
"settings": {
"title": "الإعدادات",
"java": "بيئة تشغيل جافا",
"useCustomJava": "استخدام مسار جافا مخصص",
"javaDescription": "تجاوز بيئة جافا المرفقة واستخدام تثبيت خاص بك",
"javaPath": "مسار ملف جافا التنفيذي",
"javaPathPlaceholder": "اختر مسار جافا...",
"javaBrowse": "تصفح",
"javaHint": "اختر مجلد تثبيت جافا (يدعم ويندوز، ماك، ولينكس)",
"discord": "تكامل ديسكورد",
"enableRPC": "تفعيل نشاط ديسكورد (Rich Presence)",
"discordDescription": "إظهار نشاط المشغل الخاص بك على ديسكورد",
"game": "خيارات اللعبة",
"playerName": "اسم اللاعب",
"playerNamePlaceholder": "أدخل اسم اللاعب",
"playerNameHint": "سيتم استخدام هذا الاسم داخل اللعبة (1-16 حرفاً)",
"openGameLocation": "فتح موقع اللعبة",
"openGameLocationDesc": "فتح مجلد تثبيت اللعبة",
"account": "إدارة UUID اللاعب",
"currentUUID": "الـ UUID الحالي",
"uuidPlaceholder": "جاري تحميل UUID...",
"copyUUID": "نسخ UUID",
"regenerateUUID": "إعادة إنشاء UUID",
"uuidHint": "معرف اللاعب الفريد الخاص بك لهذا الاسم",
"manageUUIDs": "إدارة جميع الـ UUIDs",
"manageUUIDsDesc": "عرض وإدارة جميع معرفات اللاعبين",
"language": "اللغة",
"selectLanguage": "اختر اللغة",
"repairGame": "إصلاح اللعبة",
"reinstallGame": "إعادة تثبيت ملفات اللعبة (يحفظ البيانات)",
"gpuPreference": "تفضيل معالج الرسوميات (GPU)",
"gpuHint": "ميزة للمحمول فقط؛ اضبطها على Integrated إذا كنت تستخدم كمبيوتر مكتبي",
"gpuAuto": "تلقائي",
"gpuIntegrated": "مدمج",
"gpuDedicated": "منفصل",
"logs": "سجلات النظام",
"logsCopy": "نسخ",
"logsRefresh": "تحديث",
"logsFolder": "فتح المجلد",
"logsLoading": "جاري تحميل السجلات...",
"closeLauncher": "سلوك المشغل",
"closeOnStart": "إغلاق المشغل عند بدء اللعبة",
"closeOnStartDescription": "إغلاق المشغل تلقائياً بعد تشغيل Hytale",
"hwAccel": "تسريع الأجهزة (Hardware Acceleration)",
"hwAccelDescription": "تفعيل تسريع الأجهزة للمشغل",
"gameBranch": "فرع اللعبة",
"branchRelease": "إصدار نهائي",
"branchPreRelease": "إصدار تجريبي",
"branchHint": "التبديل بين الإصدار المستقر والإصدار التجريبي",
"branchWarning": "تغيير الفرع سيؤدي إلى تحميل وتثبيت نسخة مختلفة من اللعبة",
"branchSwitching": "جاري التبديل إلى {branch}...",
"branchSwitched": "تم التبديل إلى {branch} بنجاح!",
"installRequired": "التثبيت مطلوب",
"branchInstallConfirm": "سيتم تثبيت اللعبة لفرع {branch}. هل تريد الاستمرار؟"
},
"uuid": {
"modalTitle": "إدارة UUID",
"currentUserUUID": "UUID المستخدم الحالي",
"allPlayerUUIDs": "جميع معرفات UUID للاعبين",
"generateNew": "إنشاء UUID جديد",
"loadingUUIDs": "جاري تحميل الـ UUIDs...",
"setCustomUUID": "تعيين UUID مخصص",
"customPlaceholder": "أدخل UUID مخصص (الصيغة: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)",
"setUUID": "تعيين UUID",
"warning": "تحذير: تعيين UUID مخصص سيغير هوية اللاعب الحالية",
"copyTooltip": "نسخ UUID",
"regenerateTooltip": "إنشاء UUID جديد"
},
"profiles": {
"modalTitle": "إدارة الملفات الشخصية",
"newProfilePlaceholder": "اسم الملف الشخصي الجديد",
"createProfile": "إنشاء ملف شخصي"
},
"discord": {
"notificationText": "انضم إلى مجتمعنا على ديسكورد!",
"joinButton": "انضم إلى ديسكورد"
},
"common": {
"confirm": "تأكيد",
"cancel": "إلغاء",
"save": "حفظ",
"close": "إغلاق",
"delete": "حذف",
"edit": "تعديل",
"loading": "جاري التحميل...",
"apply": "تطبيق",
"install": "تثبيت"
},
"notifications": {
"gameDataNotFound": "خطأ: لم يتم العثور على بيانات اللعبة",
"gameUpdatedSuccess": "تم تحديث اللعبة بنجاح! 🎉",
"updateFailed": "فشل التحديث: {error}",
"updateError": "خطأ في التحديث: {error}",
"discordEnabled": "تم تفعيل نشاط ديسكورد",
"discordDisabled": "تم تعطيل نشاط ديسكورد",
"discordSaveFailed": "فشل حفظ إعدادات ديسكورد",
"playerNameRequired": "يرجى إدخال اسم لاعب صالح",
"playerNameSaved": "تم حفظ اسم اللاعب بنجاح",
"playerNameSaveFailed": "فشل حفظ اسم اللاعب",
"uuidCopied": "تم نسخ الـ UUID إلى الحافظة!",
"uuidCopyFailed": "فشل نسخ الـ UUID",
"uuidRegenNotAvailable": "إعادة إنشاء UUID غير متاحة",
"uuidRegenFailed": "فشل إعادة إنشاء الـ UUID",
"uuidGenerated": "تم إنشاء UUID جديد بنجاح!",
"uuidGeneratedShort": "تم إنشاء UUID جديد!",
"uuidGenerateFailed": "فشل إنشاء UUID جديد",
"uuidRequired": "يرجى إدخال UUID",
"uuidInvalidFormat": "صيغة UUID غير صالحة",
"uuidSetFailed": "فشل تعيين الـ UUID المخصص",
"uuidSetSuccess": "تم تعيين الـ UUID المخصص بنجاح!",
"uuidDeleteFailed": "فشل حذف الـ UUID",
"uuidDeleteSuccess": "تم حذف الـ UUID بنجاح!",
"modsDownloading": "جاري تحميل {name}...",
"modsTogglingMod": "جاري تبديل حالة المود...",
"modsDeletingMod": "جاري حذف المود...",
"modsLoadingMods": "جاري تحميل المودات من CurseForge...",
"modsInstalledSuccess": "تم تثبيت {name} بنجاح! 🎉",
"modsDeletedSuccess": "تم حذف {name} بنجاح",
"modsDownloadFailed": "فشل تحميل المود: {error}",
"modsToggleFailed": "فشل تبديل المود: {error}",
"modsDeleteFailed": "فشل حذف المود: {error}",
"modsModNotFound": "لم يتم العثور على معلومات المود",
"hwAccelSaved": "تم حفظ إعداد تسريع الأجهزة",
"hwAccelSaveFailed": "فشل حفظ إعداد تسريع الأجهزة",
"noUsername": "لم يتم تهيئة اسم مستخدم. يرجى حفظ اسم المستخدم أولاً.",
"switchUsernameSuccess": "تم التبديل إلى المستخدم \"{username}\" بنجاح!",
"switchUsernameFailed": "فشل تبديل اسم المستخدم",
"playerNameTooLong": "يجب أن يكون اسم اللاعب 16 حرفاً أو أقل"
},
"confirm": {
"defaultTitle": "تأكيد الإجراء",
"regenerateUuidTitle": "إنشاء UUID جديد",
"regenerateUuidMessage": "هل أنت متأكد أنك تريد إنشاء UUID جديد؟ سيؤدي ذلك إلى تغيير هوية اللاعب الخاصة بك.",
"regenerateUuidButton": "إنشاء",
"setCustomUuidTitle": "تعيين UUID مخصص",
"setCustomUuidMessage": "هل أنت متأكد أنك تريد تعيين هذا الـ UUID المخصص؟ سيؤدي ذلك إلى تغيير هوية اللاعب الخاصة بك.",
"setCustomUuidButton": "تعيين UUID",
"deleteUuidTitle": "حذف UUID",
"deleteUuidMessage": "هل أنت متأكد أنك تريد حذف الـ UUID الخاص بـ \"{username}\"؟ لا يمكن التراجع عن هذا الإجراء.",
"deleteUuidButton": "حذف",
"uninstallGameTitle": "إلغاء تثبيت اللعبة",
"uninstallGameMessage": "هل أنت متأكد أنك تريد إلغاء تثبيت Hytale؟ سيتم حذف جميع ملفات اللعبة.",
"uninstallGameButton": "إلغاء التثبيت",
"switchUsernameTitle": "تبديل الهوية",
"switchUsernameMessage": "التبديل إلى اسم المستخدم \"{username}\"؟ سيؤدي هذا إلى تغيير هوية اللاعب الحالية.",
"switchUsernameButton": "تبديل"
},
"progress": {
"initializing": "جاري التهيئة...",
"downloading": "جاري التحميل...",
"installing": "جاري التثبيت...",
"extracting": "جاري الاستخراج...",
"verifying": "جاري التحقق...",
"switchingProfile": "جاري تبديل الملف الشخصي...",
"profileSwitched": "تم تبديل الملف الشخصي!",
"startingGame": "جاري بدء اللعبة...",
"launching": "جاري التشغيل...",
"uninstallingGame": "جاري إلغاء تثبيت اللعبة...",
"gameUninstalled": "تم إلغاء تثبيت اللعبة بنجاح!",
"uninstallFailed": "فشل إلغاء التثبيت: {error}",
"startingUpdate": "جاري بدء تحديث اللعبة الإجباري...",
"installationComplete": "تم اكتمال التثبيت بنجاح!",
"installationFailed": "فشل التثبيت: {error}",
"installingGameFiles": "جاري تثبيت ملفات اللعبة...",
"installComplete": "اكتمل التثبيت!"
}
}

209
GUI/style-RTL.css Normal file
View File

@@ -0,0 +1,209 @@
body.rtl {
direction: rtl;
font-family: 'Noto Sans Arabic', 'Space Grotesk', sans-serif;
}
body.rtl .sidebar {
right: 0;
left: auto;
border-right: none;
border-left: 1px solid rgba(255, 255, 255, 0.1);
}
body.rtl .nav-item.active::before {
right: -8px;
left: auto;
border-radius: 4px 0 0 4px;
}
body.rtl .nav-tooltip {
right: 100%;
left: auto;
margin-right: 0.5rem;
margin-left: 0;
}
body.rtl .nav-item:hover .nav-tooltip {
transform: translateX(-8px);
}
body.rtl .main-content {
margin-right: 80px;
margin-left: 0;
}
/* Header Layout*/
body.rtl .players-counter {
order: 2;
margin-left: 1.5rem;
margin-right: 0;
}
body.rtl .profile-selector {
order: -1;
}
body.rtl .window-controls {
order: 3;
flex-direction: row;
}
body.rtl .profile-dropdown {
right: auto;
left: 0;
}
body.rtl .form-group {
text-align: right;
}
body.rtl .radio-label,
body.rtl .checkbox-group {
flex-direction: row-reverse;
}
body.rtl .form-input {
border-radius: 0 8px 8px 0;
}
body.rtl .mods-pagination {
flex-direction: row-reverse;
}
body.rtl .pagination-btn:first-child i {
transform: rotate(180deg);
}
body.rtl .pagination-btn:last-child i {
transform: rotate(180deg);
}
/* UUID Display */
body.rtl .uuid-display-container {
flex-direction: row-reverse;
}
body.rtl .uuid-btn {
border-radius: 0 8px 8px 0;
}
body.rtl .uuid-input {
border-radius: 8px 0 0 8px;
}
body.rtl .segmented-control {
flex-direction: row-reverse;
}
/* Mod Grid Layout */
body.rtl .mods-search {
text-align: right;
}
body.rtl .mods-search-container {
flex-direction: row-reverse;
}
body.rtl .mods-actions {
order: -1;
}
body.rtl .mod-card {
direction: rtl;
}
body.rtl .installed-mod-card {
direction: rtl;
}
body.rtl .installed-mod-card .mod-info {
text-align: right;
}
body.rtl .mods-header {
flex-direction: row-reverse;
}
body.rtl .news-section .news-header {
flex-direction: row-reverse;
}
/* Settings Layout */
body.rtl .settings-option {
text-align: right;
}
body.rtl .settings-input-group {
text-align: right;
}
body.rtl .settings-input {
border-radius: 0 8px 8px 0;
}
body.rtl .settings-section-title i {
margin-right: 0;
margin-left: 0.5rem;
}
body.rtl .settings-hint i {
margin-right: 0;
margin-left: 0.5rem;
}
body.rtl .custom-options,
body.rtl .custom-java-options {
text-align: right;
}
body.rtl .checkbox-content {
margin-right: 2rem;
margin-left: 0;
}
body.rtl .btn-content {
text-align: right;
}
/* Icons & Transformations */
body.rtl .news-title i {
padding-left: 0.5rem;
}
body.rtl .uuid-modal-title i {
padding-left: 0.5rem;
}
body.rtl .mods-modal-title i {
padding-left: 0.5rem;
}
body.rtl .view-all-btn i,
body.rtl .sidebar-nav div i,
body.rtl .logs-header i,
body.rtl .home-play-button i {
transform: scaleX(-1);
}
body.rtl .play-title i {
transform: scaleX(-1);
padding-right: 0.5rem;
}
body.rtl .logs-terminal {
direction: ltr;
text-align: left;
}
body.rtl .version-display-bottom {
right: auto;
left: 1rem;
}

View File

@@ -3,7 +3,7 @@ const path = require('path');
const { execFile } = require('child_process'); const { execFile } = require('child_process');
const { downloadFile, retryDownload } = require('../utils/fileManager'); const { downloadFile, retryDownload } = require('../utils/fileManager');
const { getOS, getArch } = require('../utils/platformUtils'); const { getOS, getArch } = require('../utils/platformUtils');
const { validateChecksum, extractVersionDetails, getInstalledClientVersion, getUpdatePlan, extractVersionNumber } = require('../services/versionManager'); const { validateChecksum, extractVersionDetails, getInstalledClientVersion, getUpdatePlan, extractVersionNumber, getAllMirrorUrls, getPatchesBaseUrl } = require('../services/versionManager');
const { installButler } = require('./butlerManager'); const { installButler } = require('./butlerManager');
const { GAME_DIR, CACHE_DIR, TOOLS_DIR } = require('../core/paths'); const { GAME_DIR, CACHE_DIR, TOOLS_DIR } = require('../core/paths');
const { saveVersionClient } = require('../core/config'); const { saveVersionClient } = require('../core/config');
@@ -31,15 +31,62 @@ async function acquireGameArchive(downloadUrl, targetPath, checksum, progressCal
console.log(`Downloading game archive from: ${downloadUrl}`); console.log(`Downloading game archive from: ${downloadUrl}`);
try { // Try primary URL first, then mirror URLs on timeout/connection failure
if (allowRetry) { const mirrors = await getAllMirrorUrls();
await retryDownload(downloadUrl, targetPath, progressCallback); const primaryBase = await getPatchesBaseUrl();
} else { const urlsToTry = [downloadUrl];
await downloadFile(downloadUrl, targetPath, progressCallback);
// Build mirror URLs by replacing the base URL
for (const mirror of mirrors) {
if (mirror !== primaryBase && downloadUrl.startsWith(primaryBase)) {
const mirrorUrl = downloadUrl.replace(primaryBase, mirror);
if (!urlsToTry.includes(mirrorUrl)) {
urlsToTry.push(mirrorUrl);
}
} }
} catch (error) { }
const enhancedError = new Error(`Archive download failed: ${error.message}`);
enhancedError.originalError = error; let lastError;
for (let i = 0; i < urlsToTry.length; i++) {
const url = urlsToTry[i];
try {
if (i > 0) {
console.log(`[Download] Trying mirror ${i}: ${url}`);
if (progressCallback) {
progressCallback(`Trying alternative mirror (${i}/${urlsToTry.length - 1})...`, 0, null, null, null);
}
// Clean up partial download from previous attempt
if (fs.existsSync(targetPath)) {
try { fs.unlinkSync(targetPath); } catch (e) {}
}
}
if (allowRetry) {
await retryDownload(url, targetPath, progressCallback);
} else {
await downloadFile(url, targetPath, progressCallback);
}
lastError = null;
break; // Success
} catch (error) {
lastError = error;
const isConnectionError = error.message && (
error.message.includes('ETIMEDOUT') ||
error.message.includes('ECONNREFUSED') ||
error.message.includes('ECONNABORTED') ||
error.message.includes('timeout')
);
if (isConnectionError && i < urlsToTry.length - 1) {
console.warn(`[Download] Connection failed (${error.message}), will try mirror...`);
continue;
}
// Non-connection error or last mirror — throw
break;
}
}
if (lastError) {
const enhancedError = new Error(`Archive download failed: ${lastError.message}`);
enhancedError.originalError = lastError;
enhancedError.downloadUrl = downloadUrl; enhancedError.downloadUrl = downloadUrl;
enhancedError.targetPath = targetPath; enhancedError.targetPath = targetPath;
throw enhancedError; throw enhancedError;

View File

@@ -7,12 +7,19 @@ const { getOS, getArch } = require('../utils/platformUtils');
// Patches base URL fetched dynamically via multi-source fallback chain // Patches base URL fetched dynamically via multi-source fallback chain
const AUTH_DOMAIN = process.env.HYTALE_AUTH_DOMAIN || 'auth.sanasol.ws'; const AUTH_DOMAIN = process.env.HYTALE_AUTH_DOMAIN || 'auth.sanasol.ws';
const PATCHES_CONFIG_SOURCES = [ const PATCHES_CONFIG_SOURCES = [
{ type: 'http', url: `https://${AUTH_DOMAIN}/api/patches-config`, name: 'auth-server' }, { type: 'http', url: `https://${AUTH_DOMAIN}/api/patches-config`, name: 'primary' },
{ type: 'http', url: 'https://htdwnldsan.top/patches-config', name: 'backup-http' }, { type: 'http', url: 'https://htdwnldsan.top/patches-config', name: 'backup-1' },
{ type: 'http', url: 'https://dl1.htdwnldsan.top/patches-config', name: 'backup-2' },
{ type: 'doh', name: '_patches.htdwnldsan.top', name_label: 'dns-txt' }, { type: 'doh', name: '_patches.htdwnldsan.top', name_label: 'dns-txt' },
]; ];
const HARDCODED_FALLBACK = 'https://dl.vboro.de/patches'; const HARDCODED_FALLBACK = 'https://dl.vboro.de/patches';
// Alternative mirrors (non-Cloudflare) for regions where CF is blocked
const NON_CF_MIRRORS = [
'https://dl1.htdwnldsan.top',
'https://htdwnldsan.top/patches',
];
// Fallback: latest known build number if manifest is unreachable // Fallback: latest known build number if manifest is unreachable
const FALLBACK_LATEST_BUILD = 11; const FALLBACK_LATEST_BUILD = 11;
@@ -167,7 +174,18 @@ async function getPatchesBaseUrl() {
} }
/** /**
* Fetch the mirror manifest * Get all available mirror base URLs (primary + non-Cloudflare fallbacks)
* Used by download logic to retry on different mirrors when primary is blocked
*/
async function getAllMirrorUrls() {
const primary = await getPatchesBaseUrl();
// Deduplicate: don't include mirrors that match primary
const mirrors = NON_CF_MIRRORS.filter(m => m !== primary);
return [primary, ...mirrors];
}
/**
* Fetch the mirror manifest — tries primary URL first, then non-Cloudflare mirrors
*/ */
async function fetchMirrorManifest() { async function fetchMirrorManifest() {
const now = Date.now(); const now = Date.now();
@@ -177,31 +195,48 @@ async function fetchMirrorManifest() {
return manifestCache; return manifestCache;
} }
const baseUrl = await getPatchesBaseUrl(); const mirrors = await getAllMirrorUrls();
const manifestUrl = `${baseUrl}/manifest.json`;
try { for (let i = 0; i < mirrors.length; i++) {
console.log('[Mirror] Fetching manifest from:', manifestUrl); const baseUrl = mirrors[i];
const response = await axios.get(manifestUrl, { const manifestUrl = `${baseUrl}/manifest.json`;
timeout: 15000, try {
headers: { 'User-Agent': 'Hytale-F2P-Launcher' } console.log(`[Mirror] Fetching manifest from: ${manifestUrl}`);
}); const response = await axios.get(manifestUrl, {
timeout: 15000,
maxRedirects: 5,
headers: { 'User-Agent': 'Hytale-F2P-Launcher' }
});
if (response.data && response.data.files) { if (response.data && response.data.files) {
manifestCache = response.data; manifestCache = response.data;
manifestCacheTime = now; manifestCacheTime = now;
console.log('[Mirror] Manifest fetched successfully'); // If a non-primary mirror worked, switch to it for downloads too
return response.data; if (i > 0) {
console.log(`[Mirror] Primary unreachable, switching to mirror: ${baseUrl}`);
patchesBaseUrl = baseUrl;
patchesConfigTime = now;
saveDiskCache(baseUrl);
}
console.log('[Mirror] Manifest fetched successfully');
return response.data;
}
throw new Error('Invalid manifest structure');
} catch (error) {
const isTimeout = error.code === 'ETIMEDOUT' || error.code === 'ECONNABORTED' || error.message.includes('timeout');
console.error(`[Mirror] Error fetching manifest from ${baseUrl}: ${error.message}${isTimeout ? ' (Cloudflare may be blocked)' : ''}`);
if (i < mirrors.length - 1) {
console.log(`[Mirror] Trying next mirror...`);
}
} }
throw new Error('Invalid manifest structure');
} catch (error) {
console.error('[Mirror] Error fetching manifest:', error.message);
if (manifestCache) {
console.log('[Mirror] Using expired cache');
return manifestCache;
}
throw error;
} }
// All mirrors failed — use cached manifest if available
if (manifestCache) {
console.log('[Mirror] All mirrors failed, using expired cache');
return manifestCache;
}
throw new Error('All mirrors failed and no cached manifest available');
} }
/** /**
@@ -499,5 +534,6 @@ module.exports = {
extractVersionNumber, extractVersionNumber,
getPlatformPatches, getPlatformPatches,
findOptimalPatchPath, findOptimalPatchPath,
getPatchesBaseUrl getPatchesBaseUrl,
getAllMirrorUrls
}; };

View File

@@ -9,7 +9,9 @@ const MAX_DOMAIN_LENGTH = 16;
// DualAuth ByteBuddy Agent (runtime class transformation, no JAR modification) // DualAuth ByteBuddy Agent (runtime class transformation, no JAR modification)
const DUALAUTH_AGENT_URL = 'https://github.com/sanasol/hytale-auth-server/releases/latest/download/dualauth-agent.jar'; const DUALAUTH_AGENT_URL = 'https://github.com/sanasol/hytale-auth-server/releases/latest/download/dualauth-agent.jar';
const DUALAUTH_AGENT_VERSION_API = 'https://api.github.com/repos/sanasol/hytale-auth-server/releases/latest';
const DUALAUTH_AGENT_FILENAME = 'dualauth-agent.jar'; const DUALAUTH_AGENT_FILENAME = 'dualauth-agent.jar';
const DUALAUTH_AGENT_VERSION_FILE = 'dualauth-agent.version';
function getTargetDomain() { function getTargetDomain() {
if (process.env.HYTALE_AUTH_DOMAIN) { if (process.env.HYTALE_AUTH_DOMAIN) {
@@ -511,30 +513,70 @@ class ClientPatcher {
*/ */
async ensureAgentAvailable(serverDir, progressCallback) { async ensureAgentAvailable(serverDir, progressCallback) {
const agentPath = this.getAgentPath(serverDir); const agentPath = this.getAgentPath(serverDir);
const versionPath = path.join(serverDir, DUALAUTH_AGENT_VERSION_FILE);
console.log('=== DualAuth Agent (ByteBuddy) ==='); console.log('=== DualAuth Agent (ByteBuddy) ===');
console.log(`Target: ${agentPath}`); console.log(`Target: ${agentPath}`);
// Check if agent already exists and is valid // Check local version and whether file exists
let localVersion = null;
let agentExists = false;
if (fs.existsSync(agentPath)) { if (fs.existsSync(agentPath)) {
try { try {
const stats = fs.statSync(agentPath); const stats = fs.statSync(agentPath);
if (stats.size > 1024) { if (stats.size > 1024) {
console.log(`DualAuth Agent present (${(stats.size / 1024).toFixed(0)} KB)`); agentExists = true;
if (progressCallback) progressCallback('DualAuth Agent ready', 100); if (fs.existsSync(versionPath)) {
return { success: true, agentPath, alreadyExists: true }; localVersion = fs.readFileSync(versionPath, 'utf8').trim();
}
} else {
console.log('Agent file appears corrupt, re-downloading...');
fs.unlinkSync(agentPath);
} }
// File exists but too small - corrupt, re-download
console.log('Agent file appears corrupt, re-downloading...');
fs.unlinkSync(agentPath);
} catch (e) { } catch (e) {
console.warn('Could not check agent file:', e.message); console.warn('Could not check agent file:', e.message);
} }
} }
// Check for updates from GitHub
let remoteVersion = null;
let needsDownload = !agentExists;
if (agentExists) {
try {
if (progressCallback) progressCallback('Checking for agent updates...', 5);
const axios = require('axios');
const resp = await axios.get(DUALAUTH_AGENT_VERSION_API, {
timeout: 5000,
headers: { 'Accept': 'application/vnd.github.v3+json' }
});
remoteVersion = resp.data.tag_name; // e.g. "v1.1.10"
if (localVersion && localVersion === remoteVersion) {
console.log(`DualAuth Agent up to date (${localVersion})`);
if (progressCallback) progressCallback('DualAuth Agent ready', 100);
return { success: true, agentPath, alreadyExists: true, version: localVersion };
}
console.log(`Agent update available: ${localVersion || 'unknown'}${remoteVersion}`);
needsDownload = true;
} catch (e) {
// GitHub API failed - use existing agent if available
console.warn(`Could not check for updates: ${e.message}`);
if (agentExists) {
console.log(`Using existing agent (${localVersion || 'unknown version'})`);
if (progressCallback) progressCallback('DualAuth Agent ready', 100);
return { success: true, agentPath, alreadyExists: true, version: localVersion };
}
}
}
if (!needsDownload) {
if (progressCallback) progressCallback('DualAuth Agent ready', 100);
return { success: true, agentPath, alreadyExists: true, version: localVersion };
}
// Download agent from GitHub releases // Download agent from GitHub releases
if (progressCallback) progressCallback('Downloading DualAuth Agent...', 20); const action = agentExists ? 'Updating' : 'Downloading';
console.log(`Downloading from: ${DUALAUTH_AGENT_URL}`); if (progressCallback) progressCallback(`${action} DualAuth Agent...`, 20);
console.log(`${action} from: ${DUALAUTH_AGENT_URL}`);
try { try {
// Ensure server directory exists // Ensure server directory exists
@@ -548,7 +590,7 @@ class ClientPatcher {
const stream = await smartDownloadStream(DUALAUTH_AGENT_URL, (chunk, downloadedBytes, total) => { const stream = await smartDownloadStream(DUALAUTH_AGENT_URL, (chunk, downloadedBytes, total) => {
if (progressCallback && total) { if (progressCallback && total) {
const percent = 20 + Math.floor((downloadedBytes / total) * 70); const percent = 20 + Math.floor((downloadedBytes / total) * 70);
progressCallback(`Downloading agent... ${(downloadedBytes / 1024).toFixed(0)} KB`, percent); progressCallback(`${action} agent... ${(downloadedBytes / 1024).toFixed(0)} KB`, percent);
} }
}); });
@@ -575,9 +617,13 @@ class ClientPatcher {
} }
fs.renameSync(tmpPath, agentPath); fs.renameSync(tmpPath, agentPath);
console.log(`DualAuth Agent downloaded (${(stats.size / 1024).toFixed(0)} KB)`); // Save version
const version = remoteVersion || 'unknown';
fs.writeFileSync(versionPath, version, 'utf8');
console.log(`DualAuth Agent ${agentExists ? 'updated' : 'downloaded'} (${(stats.size / 1024).toFixed(0)} KB, ${version})`);
if (progressCallback) progressCallback('DualAuth Agent ready', 100); if (progressCallback) progressCallback('DualAuth Agent ready', 100);
return { success: true, agentPath }; return { success: true, agentPath, updated: agentExists, version };
} catch (downloadError) { } catch (downloadError) {
console.error(`Failed to download DualAuth Agent: ${downloadError.message}`); console.error(`Failed to download DualAuth Agent: ${downloadError.message}`);
@@ -586,6 +632,11 @@ class ClientPatcher {
if (fs.existsSync(tmpPath)) { if (fs.existsSync(tmpPath)) {
try { fs.unlinkSync(tmpPath); } catch (e) { /* ignore */ } try { fs.unlinkSync(tmpPath); } catch (e) { /* ignore */ }
} }
// If we had an existing agent, still use it
if (agentExists) {
console.log('Using existing agent despite update failure');
return { success: true, agentPath, alreadyExists: true, version: localVersion };
}
return { success: false, error: downloadError.message }; return { success: false, error: downloadError.message };
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "hytale-f2p-launcher", "name": "hytale-f2p-launcher",
"version": "2.3.6", "version": "2.3.8",
"description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support", "description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support",
"homepage": "https://git.sanhost.net/sanasol/hytale-f2p", "homepage": "https://git.sanhost.net/sanasol/hytale-f2p",
"main": "main.js", "main": "main.js",