Skip to content

Commit e9115ab

Browse files
fix: update header pattern in TcpSettings and adjust default header handling in HostModal
1 parent 09e5a4e commit e9115ab

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

app/core/hosts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,11 @@ async def _prepare_subscription_inbound_data(
177177
elif network in ("tcp", "raw", "http", "h2"):
178178
# TCP/HTTP/H2 all use TCP transport
179179
tcps = ts.tcp_settings if ts else None
180+
header_type = inbound_header_type or tcps.header if tcps else inbound_header_type
180181
transport_config = TCPTransportConfig(
181182
path=path,
182183
host=host_list,
183-
header_type=tcps.header if tcps else inbound_header_type,
184+
header_type=header_type,
184185
request=tcps.request.model_dump(by_alias=True, exclude_none=True) if tcps and tcps.request else None,
185186
response=tcps.response.model_dump(by_alias=True, exclude_none=True) if tcps and tcps.response else None,
186187
http_headers=host.http_headers,

app/models/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class HTTPRequest(HTTPBase):
101101

102102

103103
class TcpSettings(BaseModel):
104-
header: str = Field("none", pattern=r"^(:?none|http)$")
104+
header: str = Field("none", pattern=r"^(?:|none|http)$")
105105
request: HTTPRequest | None = Field(default=None)
106106
response: HTTPResponse | None = Field(default=None)
107107

dashboard/src/components/dialogs/host-modal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,13 +1635,17 @@ const HostModal: React.FC<HostModalProps> = ({ isDialogOpen, onOpenChange, onSub
16351635
render={({ field }) => (
16361636
<FormItem className="col-span-2">
16371637
<FormLabel>{t('hostsDialog.tcp.header')}</FormLabel>
1638-
<Select onValueChange={field.onChange} value={field.value}>
1638+
<Select
1639+
onValueChange={value => field.onChange(value === '__default' ? '' : value)}
1640+
value={field.value === '' || field.value == null ? '__default' : field.value}
1641+
>
16391642
<FormControl>
16401643
<SelectTrigger>
16411644
<SelectValue />
16421645
</SelectTrigger>
16431646
</FormControl>
16441647
<SelectContent>
1648+
<SelectItem value="__default">{t('hostsDialog.tcp.defaultHeader', { defaultValue: 'Use default' })}</SelectItem>
16451649
<SelectItem value="none">None</SelectItem>
16461650
<SelectItem value="http">HTTP</SelectItem>
16471651
</SelectContent>

dashboard/src/components/hosts/hosts-list.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
import { Button } from '@/components/ui/button'
2+
import { Card, CardContent } from '@/components/ui/card'
3+
import { Input } from '@/components/ui/input'
4+
import useDirDetection from '@/hooks/use-dir-detection'
5+
import { cn } from '@/lib/utils'
16
import { BaseHost, CreateHost, createHost, modifyHosts } from '@/service/api'
27
import { queryClient } from '@/utils/query-client'
38
import { closestCenter, DndContext, DragEndEvent, KeyboardSensor, PointerSensor, UniqueIdentifier, useSensor, useSensors } from '@dnd-kit/core'
49
import { arrayMove, rectSortingStrategy, SortableContext, sortableKeyboardCoordinates } from '@dnd-kit/sortable'
510
import { zodResolver } from '@hookform/resolvers/zod'
6-
import { useEffect, useState, useMemo } from 'react'
11+
import { RefreshCw, Search, X } from 'lucide-react'
12+
import { useEffect, useMemo, useState } from 'react'
713
import { Resolver, useForm } from 'react-hook-form'
814
import { useTranslation } from 'react-i18next'
915
import { toast } from 'sonner'
1016
import * as z from 'zod'
1117
import HostModal from '../dialogs/host-modal'
1218
import SortableHost from './sortable-host'
13-
import { Input } from '@/components/ui/input'
14-
import { Button } from '@/components/ui/button'
15-
import { RefreshCw, Search, X } from 'lucide-react'
16-
import useDirDetection from '@/hooks/use-dir-detection'
17-
import { cn } from '@/lib/utils'
18-
import { Card, CardContent } from '@/components/ui/card'
1919

2020
interface Brutal {
2121
enable?: boolean
@@ -207,7 +207,7 @@ const transportSettingsSchema = z
207207
.optional(),
208208
tcp_settings: z
209209
.object({
210-
header: z.enum(['none', 'http']).nullish().optional(),
210+
header: z.enum(['none', 'http', '']).nullish().optional(),
211211
request: z
212212
.object({
213213
version: z.enum(['1.0', '1.1', '2.0', '3.0']).nullish().optional(),

dashboard/src/service/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Do not edit manually.
44
* PasarGuardAPI
55
* Unified GUI Censorship Resistant Solution
6-
* OpenAPI spec version: 1.10.1
6+
* OpenAPI spec version: 1.11.0
77
*/
88
import { useMutation, useQuery } from '@tanstack/react-query'
99
import type {
@@ -815,7 +815,7 @@ export type TcpSettingsResponse = HTTPResponse | null
815815
export type TcpSettingsRequest = HTTPRequest | null
816816

817817
export interface TcpSettings {
818-
/** @pattern ^(:?none|http)$ */
818+
/** @pattern ^(?:|none|http)$ */
819819
header?: string
820820
request?: TcpSettingsRequest
821821
response?: TcpSettingsResponse

0 commit comments

Comments
 (0)