mirror of
https://github.com/fatedier/frp.git
synced 2026-10-25 17:33:29 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3845587393 |
@@ -140,8 +140,6 @@ func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UDPPacket, sendCh chan<-
|
|||||||
_, err = udpConn.Write(buf)
|
_, err = udpConn.Write(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
udpConn.Close()
|
udpConn.Close()
|
||||||
} else {
|
|
||||||
_ = udpConn.SetReadDeadline(time.Now().Add(30 * time.Second))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
+35
-114
@@ -77,9 +77,8 @@
|
|||||||
<div v-if="filteredProxies.length > 0" class="proxies-list">
|
<div v-if="filteredProxies.length > 0" class="proxies-list">
|
||||||
<ProxyCard
|
<ProxyCard
|
||||||
v-for="proxy in filteredProxies"
|
v-for="proxy in filteredProxies"
|
||||||
:key="`${proxy.type}:${proxy.name}`"
|
:key="proxy.name"
|
||||||
:proxy="proxy"
|
:proxy="proxy"
|
||||||
:show-type="activeType === 'all'"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="!loading" class="empty-state">
|
<div v-else-if="!loading" class="empty-state">
|
||||||
@@ -130,14 +129,12 @@ const route = useRoute()
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const proxyTypes = [
|
const proxyTypes = [
|
||||||
{ label: 'All', value: 'all' },
|
|
||||||
{ label: 'TCP', value: 'tcp' },
|
{ label: 'TCP', value: 'tcp' },
|
||||||
{ label: 'UDP', value: 'udp' },
|
{ label: 'UDP', value: 'udp' },
|
||||||
{ label: 'HTTP', value: 'http' },
|
{ label: 'HTTP', value: 'http' },
|
||||||
{ label: 'HTTPS', value: 'https' },
|
{ label: 'HTTPS', value: 'https' },
|
||||||
{ label: 'TCPMUX', value: 'tcpmux' },
|
{ label: 'TCPMUX', value: 'tcpmux' },
|
||||||
{ label: 'STCP', value: 'stcp' },
|
{ label: 'STCP', value: 'stcp' },
|
||||||
{ label: 'XTCP', value: 'xtcp' },
|
|
||||||
{ label: 'SUDP', value: 'sudp' },
|
{ label: 'SUDP', value: 'sudp' },
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -203,48 +200,15 @@ const filteredProxies = computed(() => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by search text across multiple fields
|
// Filter by search text
|
||||||
if (searchText.value) {
|
if (searchText.value) {
|
||||||
const search = searchText.value.toLowerCase()
|
const search = searchText.value.toLowerCase()
|
||||||
result = result.filter((p) => {
|
result = result.filter((p) => p.name.toLowerCase().includes(search))
|
||||||
const fields: unknown[] = [
|
|
||||||
p.name,
|
|
||||||
p.type,
|
|
||||||
p.clientID,
|
|
||||||
p.user,
|
|
||||||
p.addr,
|
|
||||||
p.port,
|
|
||||||
p.customDomains,
|
|
||||||
p.subdomain,
|
|
||||||
]
|
|
||||||
return fields.some((v) => matchesSearch(v, search))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
// Normalize a field of unknown shape (string / number / array / null) to a
|
|
||||||
// lowercase string for case-insensitive substring matching. Arrays are joined
|
|
||||||
// so e.g. customDomains: ["A.com","B.com"] is searchable as one blob.
|
|
||||||
const matchesSearch = (value: unknown, needle: string): boolean => {
|
|
||||||
if (value === null || value === undefined) return false
|
|
||||||
let str: string
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
str = value
|
|
||||||
.filter((v) => v !== null && v !== undefined)
|
|
||||||
.map((v) => String(v))
|
|
||||||
.join(' ')
|
|
||||||
} else if (typeof value === 'number') {
|
|
||||||
if (value === 0) return false
|
|
||||||
str = String(value)
|
|
||||||
} else {
|
|
||||||
str = String(value)
|
|
||||||
}
|
|
||||||
if (!str) return false
|
|
||||||
return str.toLowerCase().includes(needle)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onClientFilterChange = (key: string) => {
|
const onClientFilterChange = (key: string) => {
|
||||||
if (key) {
|
if (key) {
|
||||||
const client = clientOptions.value.find((c) => c.key === key)
|
const client = clientOptions.value.find((c) => c.key === key)
|
||||||
@@ -285,88 +249,45 @@ const fetchServerInfo = async () => {
|
|||||||
return serverInfo
|
return serverInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertProxies = async (
|
|
||||||
type: string,
|
|
||||||
json: any,
|
|
||||||
): Promise<BaseProxy[]> => {
|
|
||||||
if (type === 'tcp') {
|
|
||||||
return json.proxies.map((p: any) => new TCPProxy(p))
|
|
||||||
}
|
|
||||||
if (type === 'udp') {
|
|
||||||
return json.proxies.map((p: any) => new UDPProxy(p))
|
|
||||||
}
|
|
||||||
if (type === 'http') {
|
|
||||||
const info = await fetchServerInfo()
|
|
||||||
if (info && info.vhostHTTPPort) {
|
|
||||||
return json.proxies.map(
|
|
||||||
(p: any) => new HTTPProxy(p, info.vhostHTTPPort, info.subdomainHost),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
if (type === 'https') {
|
|
||||||
const info = await fetchServerInfo()
|
|
||||||
if (info && info.vhostHTTPSPort) {
|
|
||||||
return json.proxies.map(
|
|
||||||
(p: any) => new HTTPSProxy(p, info.vhostHTTPSPort, info.subdomainHost),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
if (type === 'tcpmux') {
|
|
||||||
const info = await fetchServerInfo()
|
|
||||||
if (info && info.tcpmuxHTTPConnectPort) {
|
|
||||||
return json.proxies.map(
|
|
||||||
(p: any) =>
|
|
||||||
new TCPMuxProxy(p, info.tcpmuxHTTPConnectPort, info.subdomainHost),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
if (type === 'stcp') {
|
|
||||||
return json.proxies.map((p: any) => new STCPProxy(p))
|
|
||||||
}
|
|
||||||
if (type === 'sudp') {
|
|
||||||
return json.proxies.map((p: any) => new SUDPProxy(p))
|
|
||||||
}
|
|
||||||
// Fallback for types without a dedicated class (e.g. xtcp). Matches the
|
|
||||||
// pattern in ProxyDetail.vue so the type tag and meta render correctly.
|
|
||||||
return json.proxies.map((p: any) => {
|
|
||||||
const bp = new BaseProxy(p)
|
|
||||||
bp.type = type
|
|
||||||
return bp
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const allProxyTypes = [
|
|
||||||
'tcp',
|
|
||||||
'udp',
|
|
||||||
'http',
|
|
||||||
'https',
|
|
||||||
'tcpmux',
|
|
||||||
'stcp',
|
|
||||||
'xtcp',
|
|
||||||
'sudp',
|
|
||||||
]
|
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
proxies.value = []
|
proxies.value = []
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const type = activeType.value
|
const type = activeType.value
|
||||||
|
|
||||||
if (type === 'all') {
|
|
||||||
const results = await Promise.all(
|
|
||||||
allProxyTypes.map(async (t) => {
|
|
||||||
const json = await getProxiesByType(t)
|
|
||||||
return convertProxies(t, json)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
proxies.value = results.flat()
|
|
||||||
} else {
|
|
||||||
const json = await getProxiesByType(type)
|
const json = await getProxiesByType(type)
|
||||||
proxies.value = await convertProxies(type, json)
|
|
||||||
|
if (type === 'tcp') {
|
||||||
|
proxies.value = json.proxies.map((p: any) => new TCPProxy(p))
|
||||||
|
} else if (type === 'udp') {
|
||||||
|
proxies.value = json.proxies.map((p: any) => new UDPProxy(p))
|
||||||
|
} else if (type === 'http') {
|
||||||
|
const info = await fetchServerInfo()
|
||||||
|
if (info && info.vhostHTTPPort) {
|
||||||
|
proxies.value = json.proxies.map(
|
||||||
|
(p: any) => new HTTPProxy(p, info.vhostHTTPPort, info.subdomainHost),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (type === 'https') {
|
||||||
|
const info = await fetchServerInfo()
|
||||||
|
if (info && info.vhostHTTPSPort) {
|
||||||
|
proxies.value = json.proxies.map(
|
||||||
|
(p: any) =>
|
||||||
|
new HTTPSProxy(p, info.vhostHTTPSPort, info.subdomainHost),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (type === 'tcpmux') {
|
||||||
|
const info = await fetchServerInfo()
|
||||||
|
if (info && info.tcpmuxHTTPConnectPort) {
|
||||||
|
proxies.value = json.proxies.map(
|
||||||
|
(p: any) =>
|
||||||
|
new TCPMuxProxy(p, info.tcpmuxHTTPConnectPort, info.subdomainHost),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (type === 'stcp') {
|
||||||
|
proxies.value = json.proxies.map((p: any) => new STCPProxy(p))
|
||||||
|
} else if (type === 'sudp') {
|
||||||
|
proxies.value = json.proxies.map((p: any) => new SUDPProxy(p))
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
|
|||||||
Reference in New Issue
Block a user