Skip to content

Commit 41f62d8

Browse files
authored
feat: separate real ip header of frontend/agent (#130)
* feat: separate real ip header of frontend/agent * test(ci): test * Revert "test(ci): test" This reverts commit 7d2f16e. * chore: auto-fix linting and formatting issues
1 parent 833d2d9 commit 41f62d8

File tree

11 files changed

+71
-19
lines changed

11 files changed

+71
-19
lines changed

src/lib/i18n.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { initReactI18next } from "react-i18next"
33

44
import deTranslation from "../locales/de/translation.json"
55
import enTranslation from "../locales/en/translation.json"
6+
import esTranslation from "../locales/es/translation.json"
67
import itTranslation from "../locales/it/translation.json"
78
import ruTranslation from "../locales/ru/translation.json"
9+
import taTranslation from "../locales/ta/translation.json"
810
import zhCNTranslation from "../locales/zh-CN/translation.json"
911
import zhTWTranslation from "../locales/zh-TW/translation.json"
10-
import esTranslation from "../locales/es/translation.json"
11-
import taTranslation from "../locales/ta/translation.json"
1212

1313
const resources = {
1414
"zh-CN": {

src/locales/de/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"BruteForceAttackingToken": "Brute Force Angriffs Token",
8888
"BruteForceAttackingAgentSecret": "Brute Force Angriff Agent Geheimnis",
8989
"CustomCodesDashboard": "Benutzerdefinierter Coder für das Dashboard",
90-
"RealIPHeader": "Echter IP-Anfrage-Header",
90+
"WebRealIPHeader": "Echter IP-Anfrage-Header des Frontend",
91+
"AgentRealIPHeader": "Echter IP-Anfrage-Header des Agent",
9192
"UseDirectConnectingIP": "Direkte IP-Verbindung verwenden",
9293
"IPChangeNotification": "IP Änderung Benachrichtigung",
9394
"EditTask": "Task bearbeiten",

src/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139
"CustomCodes": "Custom Codes (Style and Script)",
140140
"CustomCodesDashboard": "Custom Codes for Dashboard",
141141
"CustomPublicDNSNameserversforDDNS": "Custom Public DNS Nameservers for DDNS",
142-
"RealIPHeader": "Real IP request header",
142+
"WebRealIPHeader": "Frontend real IP request header",
143+
"AgentRealIPHeader": "Agent real IP request header",
143144
"UseDirectConnectingIP": "Use direct connection IP",
144145
"IPChangeNotification": "IP Change Notification",
145146
"FullIPNotification": "Show Full IP Address in Notification Messages",

src/locales/es/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@
162162
"CustomCodes": "Códigos personalizados (Style y Script)",
163163
"CustomCodesDashboard": "Códigos personalizados para el Dashboard",
164164
"CustomPublicDNSNameserversforDDNS": "Servidores de nombres DNS públicos personalizados para DDNS",
165-
"RealIPHeader": "Encabezado de solicitud de IP real",
165+
"WebRealIPHeader": "Encabezado de solicitud de IP real del frontend",
166+
"AgentRealIPHeader": "Encabezado de solicitud de IP real del Agent",
166167
"UseDirectConnectingIP": "Usar IP de conexión directa",
167168
"CreateNotifier": "Crear notificador",
168169
"LastBlockReason": "Última razón de bloqueo",

src/locales/it/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@
144144
"DashboardOriginalHost": "Indirizzo di ancoraggio dell'agente [nome dominio/IP:porta]",
145145
"ConfigTLS": "Usa TLS per connettere Agent",
146146
"CustomPublicDNSNameserversforDDNS": "Server dei nomi DNS pubblici personalizzati per DDNS",
147-
"RealIPHeader": "Intestazione della richiesta IP reale",
147+
"WebRealIPHeader": "Intestazione della richiesta IP reale del frontend",
148+
"AgentRealIPHeader": "Intestazione della richiesta IP reale dell’agente",
148149
"UseDirectConnectingIP": "Utilizzare l'IP di connessione diretta",
149150
"IPChangeNotification": "Notifica di modifica IP",
150151
"FullIPNotification": "Mostra l'indirizzo IP completo nei messaggi di notifica",

src/locales/ru/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@
122122
"BruteForceAttackingAgentSecret": "Секрет агента для защиты от брутфорса",
123123
"CustomCodesDashboard": "Пользовательский код для панели управления",
124124
"CustomPublicDNSNameserversforDDNS": "Пользовательские публичные DNS-серверы для DDNS",
125-
"RealIPHeader": "Заголовок запроса с реальным IP",
125+
"WebRealIPHeader": "Заголовок запроса с реальным IP от frontend",
126+
"AgentRealIPHeader": "Заголовок запроса с реальным IP от агента",
126127
"FullIPNotification": "Показывать полный IP-адрес в уведомлениях",
127128
"EditService": "Редактировать сервис",
128129
"CreateService": "Создать сервис",

src/locales/ta/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@
143143
"CustomCodes": "தனிப்பயன் குறியீடுகள் (நடை மற்றும் ச்கிரிப்ட்)",
144144
"CustomCodesDashboard": "டாச்போர்டுக்கான தனிப்பயன் குறியீடுகள்",
145145
"CustomPublicDNSNameserversforDDNS": "டி.டி.என்.எச்சிற்கான தனிப்பயன் பொது டி.என்.எச் பெயர்செர்வர்ச்",
146-
"RealIPHeader": "உண்மையான ஐபி கோரிக்கை தலைப்பு",
146+
"WebRealIPHeader": "முன்நிலை உண்மையான ஐபி கோரிக்கை தலைப்பு",
147+
"AgentRealIPHeader": "ஏஜெண்ட் உண்மையான ஐபி கோரிக்கை தலைப்பு",
147148
"UseDirectConnectingIP": "நேரடி இணைப்பு ஐபி பயன்படுத்தவும்",
148149
"IPChangeNotification": "ஐபி மாற்ற அறிவிப்பு",
149150
"FullIPNotification": "அறிவிப்பு செய்திகளில் முழு ஐபி முகவரியைக் காட்டுங்கள்",

src/locales/zh-CN/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@
146146
"DashboardOriginalHost": "Agent对接地址【域名/IP:端口】",
147147
"ConfigTLS": "Agent 使用 TLS 连接",
148148
"CustomPublicDNSNameserversforDDNS": "DDNS 的自定义公共 DNS 名称服务器",
149-
"RealIPHeader": "真实IP请求头",
149+
"WebRealIPHeader": "前端真实IP请求头",
150+
"AgentRealIPHeader": "Agent真实IP请求头",
150151
"UseDirectConnectingIP": "使用直连 IP",
151152
"IPChangeNotification": "IP变更通知",
152153
"FullIPNotification": "在通知消息中显示完整的 IP 地址",

src/locales/zh-TW/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@
146146
"DashboardOriginalHost": "Agent對接位址【網域名稱/IP:連接埠】",
147147
"ConfigTLS": "Agent 使用 TLS 連線",
148148
"CustomPublicDNSNameserversforDDNS": "DDNS 的自訂公共 DNS 名稱伺服器",
149-
"RealIPHeader": "真實IP請求頭",
149+
"WebRealIPHeader": "前端真實IP請求頭",
150+
"AgentRealIPHeader": "Agent真實IP請求頭",
150151
"UseDirectConnectingIP": "使用直連 IP",
151152
"IPChangeNotification": "IP變更通知",
152153
"FullIPNotification": "在通知訊息中顯示完整的 IP 位址",

src/routes/settings.tsx

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const settingFormSchema = z.object({
4444
install_host: asOptionalField(z.string()),
4545
custom_code: asOptionalField(z.string()),
4646
custom_code_dashboard: asOptionalField(z.string()),
47-
real_ip_header: asOptionalField(z.string()),
47+
web_real_ip_header: asOptionalField(z.string()),
48+
agent_real_ip_header: asOptionalField(z.string()),
4849

4950
tls: asOptionalField(z.boolean()),
5051
enable_ip_change_notification: asOptionalField(z.boolean()),
@@ -315,10 +316,10 @@ export default function SettingsPage() {
315316
/>
316317
<FormField
317318
control={form.control}
318-
name="real_ip_header"
319+
name="web_real_ip_header"
319320
render={({ field }) => (
320321
<FormItem>
321-
<FormLabel>{t("RealIPHeader")}</FormLabel>
322+
<FormLabel>{t("WebRealIPHeader")}</FormLabel>
322323
<FormControl>
323324
<div className="flex items-center">
324325
<Input
@@ -334,12 +335,51 @@ export default function SettingsPage() {
334335
if (checked) {
335336
field.disabled = true
336337
form.setValue(
337-
"real_ip_header",
338+
"web_real_ip_header",
338339
"NZ::Use-Peer-IP",
339340
)
340341
} else {
341342
field.disabled = false
342-
form.setValue("real_ip_header", "")
343+
form.setValue("web_real_ip_header", "")
344+
}
345+
}}
346+
/>
347+
<FormLabel className="font-normal ml-2">
348+
{t("UseDirectConnectingIP")}
349+
</FormLabel>
350+
</div>
351+
</FormControl>
352+
<FormMessage />
353+
</FormItem>
354+
)}
355+
/>
356+
<FormField
357+
control={form.control}
358+
name="agent_real_ip_header"
359+
render={({ field }) => (
360+
<FormItem>
361+
<FormLabel>{t("AgentRealIPHeader")}</FormLabel>
362+
<FormControl>
363+
<div className="flex items-center">
364+
<Input
365+
disabled={field.value == "NZ::Use-Peer-IP"}
366+
className="w-1/2"
367+
placeholder="CF-Connecting-IP"
368+
{...field}
369+
/>
370+
<Checkbox
371+
checked={field.value == "NZ::Use-Peer-IP"}
372+
className="ml-2"
373+
onCheckedChange={(checked) => {
374+
if (checked) {
375+
field.disabled = true
376+
form.setValue(
377+
"agent_real_ip_header",
378+
"NZ::Use-Peer-IP",
379+
)
380+
} else {
381+
field.disabled = false
382+
form.setValue("agent_real_ip_header", "")
343383
}
344384
}}
345385
/>

src/types/api.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,10 @@ export interface ModelSetting {
648648
/** 系统语言,默认 zh_CN */
649649
language: string
650650
oauth2_providers: string[]
651-
/** 真实IP */
652-
real_ip_header: string
651+
/** 前端真实IP */
652+
web_real_ip_header: string
653+
/** Agent真实IP */
654+
agent_real_ip_header: string
653655
site_name: string
654656
/** 用于前端判断生成的安装命令是否启用 TLS */
655657
tls: boolean
@@ -669,8 +671,10 @@ export interface ModelSettingForm {
669671
ip_change_notification_group_id: number
670672
/** @minLength 2 */
671673
language: string
672-
/** 真实IP */
673-
real_ip_header?: string
674+
/** 前端真实IP */
675+
web_real_ip_header?: string
676+
/** Agent真实IP */
677+
agent_real_ip_header?: string
674678
/** @minLength 1 */
675679
site_name: string
676680
tls?: boolean

0 commit comments

Comments
 (0)