feat: auto-fallback to default bind IP when invalid bind address detected

When a forward service is updated with a bind IP that doesn't exist on the
host network interfaces, the system now automatically falls back to the
default bind address (listening on all interfaces) instead of failing.

- Added syncForwardServicesWithWarnings to collect fallback warnings
- Implemented fallbackForwardPortToDefaultBind for graceful degradation
- Added UpdateForwardPortBindIP repository method to persist fallback
- Enhanced error detection for 'cannot assign requested address' errors
- Frontend displays warning toasts when fallback occurs
- Added comprehensive unit tests for new error detection functions
This commit is contained in:
sagitchu
2026-03-03 21:34:12 +08:00
parent 7efb49bdab
commit 1c596fae4b
6 changed files with 136 additions and 14 deletions
+12
View File
@@ -1419,6 +1419,18 @@ export default function ForwardPage() {
}
if (res.code === 0) {
const warningItems = Array.isArray((res as any).data?.warnings)
? (res as any).data.warnings
.map((item: unknown) => (typeof item === "string" ? item.trim() : ""))
.filter((item: string) => item)
: [];
warningItems.forEach((warning: string) => {
toast(warning, {
icon: "⚠️",
duration: 5000,
});
});
toast.success(isEdit ? "修改成功" : "创建成功");
setModalOpen(false);
loadData();