most-box 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -6
- package/electron/deepLink.js +29 -0
- package/electron/main.js +87 -20
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/AppShell-BOtfY12t.js +1 -0
- package/out/assets/FilePreviewOverlay-C5qK9HAE.js +1 -0
- package/out/assets/LanguageToggle-Di5b88mK.js +1 -0
- package/out/assets/MarketingHeader-BOytKcCc.js +1 -0
- package/out/assets/MarketingLayout-B8m1Q7Pa.js +1 -0
- package/out/assets/{MarketingThemeToggle-qlwCZU1o.js → MarketingThemeToggle-C6fggkl7.js} +1 -1
- package/out/assets/{MilkdownEditor-_TGlDyA_.js → MilkdownEditor-Cfze75zl.js} +1 -1
- package/out/assets/OpenSidebarButton-DDuALgJ2.js +1 -0
- package/out/assets/SidebarAccount-bo1ypzrJ.js +1 -0
- package/out/assets/arrow-right-RldN7Rwi.js +1 -0
- package/out/assets/circle-alert-BQoSDxUe.js +1 -0
- package/out/assets/cloud-DHoTMeZY.js +1 -0
- package/out/assets/copy-BtJHJnqH.js +1 -0
- package/out/assets/download-Bg-OdoxM.js +1 -0
- package/out/assets/downloadValidation-CUvbvj9f.js +1 -0
- package/out/assets/external-link-m8ZIQe4p.js +1 -0
- package/out/assets/file-text-DG1orIkZ.js +1 -0
- package/out/assets/game-s6irY8hS.js +1 -0
- package/out/assets/hard-drive-BB-sllXA.js +1 -0
- package/out/assets/index-3OD3Chi9.css +1 -0
- package/out/assets/index-BSOvFG3o.css +1 -0
- package/out/assets/index-C0xqKeu-.css +1 -0
- package/out/assets/index-CrAXrmfP.js +31 -0
- package/out/assets/index.lazy-0Njp0U6I.js +1 -0
- package/out/assets/index.lazy-BTndBeBF.js +1 -0
- package/out/assets/index.lazy-Bq39jYTl.js +1 -0
- package/out/assets/index.lazy-Bu93oGzJ.js +2 -0
- package/out/assets/index.lazy-BvdBwgHx.js +1 -0
- package/out/assets/index.lazy-CIx8ist6.js +3 -0
- package/out/assets/index.lazy-DK7R297q.js +1 -0
- package/out/assets/index.lazy-DVOcrcEB.js +2 -0
- package/out/assets/index.lazy-DejOniAm.js +1 -0
- package/out/assets/index.lazy-DfsgyiMN.js +1 -0
- package/out/assets/index.lazy-DpNIiSXF.js +1 -0
- package/out/assets/index.lazy-Vnvz-t7T.js +1 -0
- package/out/assets/index.lazy-v7nBJ-sF.js +1 -0
- package/out/assets/key-round-DIQ3Xt5F.js +1 -0
- package/out/assets/lock-tf1t2yuy.js +1 -0
- package/out/assets/message-square-DaQH7q-P.js +1 -0
- package/out/assets/mp-DvFTsIL9.js +1 -0
- package/out/assets/music-DaFvU2DL.js +1 -0
- package/out/assets/notebook-pen-CqEFOHKx.js +1 -0
- package/out/assets/play-B7q6F75-.js +1 -0
- package/out/assets/plus-H2i2mspM.js +1 -0
- package/out/assets/refresh-cw-roxAhABl.js +1 -0
- package/out/assets/save-DR0O9ReR.js +1 -0
- package/out/assets/search-ncblG-zw.js +1 -0
- package/out/assets/send-m1XCcuPn.js +1 -0
- package/out/assets/shield-check-BwcvTU4U.js +1 -0
- package/out/assets/trash-2-CNpsqYc1.js +1 -0
- package/out/assets/triangle-alert-DP9EP7IM.js +1 -0
- package/out/assets/upload-V--8p13l.js +1 -0
- package/out/assets/useChannelMessages-46C52EyL.js +3 -0
- package/out/assets/useGameRoom-BtxPpfck.js +1 -0
- package/out/assets/useNavigate-DWlBD_-b.js +1 -0
- package/out/assets/userStore-C4vdYsQp.js +4 -0
- package/out/assets/wallet-CozFU6yK.js +1 -0
- package/out/assets/wifi-DIR3g_8A.js +1 -0
- package/out/chat/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +9 -1
- package/server/index.js +36 -7
- package/server/src/core/channelIdentity.js +6 -0
- package/server/src/core/gameRoom.js +15 -5
- package/server/src/core/mostLink.js +8 -7
- package/server/src/core/zhajinhua.js +6 -0
- package/server/src/games/gandengyan.js +10 -0
- package/server/src/http/access.js +63 -12
- package/server/src/http/app.js +34 -838
- package/server/src/http/nodeStatus.js +101 -9
- package/server/src/http/routePolicy.js +2 -0
- package/server/src/http/routes/channelRoutes.js +163 -0
- package/server/src/http/routes/fileRoutes.js +345 -0
- package/server/src/http/routes/nodeRoutes.js +323 -0
- package/server/src/http/routes/seedRoutes.js +58 -0
- package/server/src/index.js +197 -16
- package/server/src/node/config.js +2 -6
- package/server/src/utils/avatar.js +30 -15
- package/server/src/utils/downloadMessages.js +0 -2
- package/out/assets/AppShell-OiOEqXPr.js +0 -1
- package/out/assets/ChatUi-Cif5LRF3.js +0 -1
- package/out/assets/CopyButton-Dm7krgbq.js +0 -1
- package/out/assets/LanguageToggle-B4ZNuBCV.js +0 -1
- package/out/assets/MarketingHeader-yIZuQP7m.js +0 -1
- package/out/assets/MarketingLayout-DVH0Nx7S.js +0 -1
- package/out/assets/MoveModal-BVr4Q7-b.js +0 -1
- package/out/assets/Nav-5xeettNJ.js +0 -1
- package/out/assets/NoteSidebar-DpniUKmy.js +0 -1
- package/out/assets/OpenSidebarButton-BfgG2HIT.js +0 -1
- package/out/assets/PemBlock-CxwIepth.js +0 -1
- package/out/assets/SidebarAccount-Zg5DZblE.js +0 -1
- package/out/assets/arrow-right-CL9YSDVS.js +0 -1
- package/out/assets/channelApi-DNdJfsJ-.js +0 -1
- package/out/assets/chevron-down-CnLh_-aO.js +0 -1
- package/out/assets/circle-alert-oiiRDvhx.js +0 -1
- package/out/assets/cloud-BEe2N89j.js +0 -1
- package/out/assets/code-9LB8QqxL.js +0 -1
- package/out/assets/copy-giX4rmFJ.js +0 -1
- package/out/assets/download-D0oMEYQZ.js +0 -1
- package/out/assets/downloadValidation-Bk1VsBBo.js +0 -1
- package/out/assets/external-link-Cm2WCUxv.js +0 -1
- package/out/assets/filePreview-BZ50vZZf.js +0 -1
- package/out/assets/game-Bvz4dspe.js +0 -1
- package/out/assets/hard-drive-B3CQbcp2.js +0 -1
- package/out/assets/index-8eWJAjpY.css +0 -1
- package/out/assets/index-BZc4blbW.css +0 -1
- package/out/assets/index-BkZvz4WA.css +0 -1
- package/out/assets/index-WCK14Vja.js +0 -34
- package/out/assets/index.lazy-5Q6GuMNT.js +0 -1
- package/out/assets/index.lazy-5jq6EFXa.js +0 -3
- package/out/assets/index.lazy-7n1Q-NrA.js +0 -3
- package/out/assets/index.lazy-BFnOyQFj.js +0 -1
- package/out/assets/index.lazy-B_oPp6qK.js +0 -1
- package/out/assets/index.lazy-BvY50KVz.js +0 -1
- package/out/assets/index.lazy-C0Kn_amZ.js +0 -1
- package/out/assets/index.lazy-C3cek3Gn.js +0 -1
- package/out/assets/index.lazy-CLpPkdy1.js +0 -1
- package/out/assets/index.lazy-Cpr1kApf.js +0 -2
- package/out/assets/index.lazy-CuwLZiUK.js +0 -1
- package/out/assets/index.lazy-DDc3Ylgf.js +0 -2
- package/out/assets/index.lazy-Dg3aqOss.js +0 -1
- package/out/assets/key-round-CzuljhND.js +0 -1
- package/out/assets/lock-D2NhNoJW.js +0 -1
- package/out/assets/message-square-DwBq_Go5.js +0 -1
- package/out/assets/mp-Bln2MB9G.js +0 -1
- package/out/assets/music-CB73K5Gz.js +0 -1
- package/out/assets/notebook-pen-Up7r5zoI.js +0 -1
- package/out/assets/play-OszVgROb.js +0 -1
- package/out/assets/plus-BbxQG_Ai.js +0 -1
- package/out/assets/save-CiqyiifY.js +0 -1
- package/out/assets/search-gqAPOsgS.js +0 -1
- package/out/assets/send-vwCWsZGP.js +0 -1
- package/out/assets/shield-check-CxWxsNLc.js +0 -1
- package/out/assets/trash-2-DNGr8IgF.js +0 -1
- package/out/assets/triangle-alert-B_1BlX1b.js +0 -1
- package/out/assets/upload-Dxl7GUzb.js +0 -1
- package/out/assets/useChannelMessages-7bYKXU_R.js +0 -3
- package/out/assets/useGameRoom-DqA1mkfk.js +0 -1
- package/out/assets/wallet-DlkawdPJ.js +0 -1
- package/out/assets/wifi-sBOKcPFM.js +0 -1
- package/out/demo/index.html +0 -0
- /package/out/avatars/default/{ocean.svg → dolphin.svg} +0 -0
- /package/out/avatars/default/{violet.svg → owl.svg} +0 -0
- /package/out/avatars/default/{mint.svg → panda.svg} +0 -0
- /package/out/avatars/default/{dusk.svg → snow-mountain.svg} +0 -0
- /package/out/avatars/default/{ember.svg → tiger.svg} +0 -0
- /package/out/avatars/default/{sage.svg → turtle.svg} +0 -0
- /package/public/avatars/default/{ocean.svg → dolphin.svg} +0 -0
- /package/public/avatars/default/{violet.svg → owl.svg} +0 -0
- /package/public/avatars/default/{mint.svg → panda.svg} +0 -0
- /package/public/avatars/default/{dusk.svg → snow-mountain.svg} +0 -0
- /package/public/avatars/default/{ember.svg → tiger.svg} +0 -0
- /package/public/avatars/default/{sage.svg → turtle.svg} +0 -0
|
@@ -110,7 +110,7 @@ export function deriveGameRoomLobby(messages = [], options = {}) {
|
|
|
110
110
|
if (!event) continue
|
|
111
111
|
|
|
112
112
|
if (event.event === 'room:create') {
|
|
113
|
-
const player = createPlayerFromPayload(event.payload?.player, message
|
|
113
|
+
const player = createPlayerFromPayload(event.payload?.player, message)
|
|
114
114
|
if (!player) continue
|
|
115
115
|
if (!hostAddress) hostAddress = player.address
|
|
116
116
|
upsertPlayer(players, playerMap, player)
|
|
@@ -118,7 +118,7 @@ export function deriveGameRoomLobby(messages = [], options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (event.event === 'player:join') {
|
|
121
|
-
const player = createPlayerFromPayload(event.payload?.player, message
|
|
121
|
+
const player = createPlayerFromPayload(event.payload?.player, message)
|
|
122
122
|
if (player) upsertPlayer(players, playerMap, player)
|
|
123
123
|
continue
|
|
124
124
|
}
|
|
@@ -157,18 +157,28 @@ export function getLatestGameState(messages = [], options = {}) {
|
|
|
157
157
|
return latest
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export function createPlayerFromPayload(input,
|
|
160
|
+
export function createPlayerFromPayload(input, messageOrAuthor) {
|
|
161
161
|
if (!input || typeof input !== 'object') return null
|
|
162
|
+
const message =
|
|
163
|
+
messageOrAuthor && typeof messageOrAuthor === 'object'
|
|
164
|
+
? messageOrAuthor
|
|
165
|
+
: { author: messageOrAuthor }
|
|
166
|
+
const author = message.author
|
|
162
167
|
const address = normalizeAddress(input.address || author)
|
|
163
168
|
if (!address || normalizeAddress(author) !== address) return null
|
|
164
|
-
const name =
|
|
169
|
+
const name =
|
|
170
|
+
String(message.authorName || input.name || '').trim().slice(0, 50) ||
|
|
171
|
+
shortAddress(address)
|
|
172
|
+
const avatar = String(message.avatar || input.avatar || '').trim()
|
|
165
173
|
const publicKey = String(input.publicKey || '').trim()
|
|
166
|
-
|
|
174
|
+
const player = {
|
|
167
175
|
address,
|
|
168
176
|
name,
|
|
169
177
|
publicKey,
|
|
170
178
|
joinedAt: Number(input.joinedAt || Date.now()),
|
|
171
179
|
}
|
|
180
|
+
if (avatar) player.avatar = avatar.slice(0, 4096)
|
|
181
|
+
return player
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
export function normalizeGamePlayer(input) {
|
|
@@ -9,7 +9,6 @@ export const MOST_LINK_ERROR_CODES = {
|
|
|
9
9
|
INVALID_URL: 'invalid_url',
|
|
10
10
|
INVALID_PROTOCOL: 'invalid_protocol',
|
|
11
11
|
UNSUPPORTED_PATH: 'unsupported_path',
|
|
12
|
-
FILENAME_REQUIRED: 'filename_required',
|
|
13
12
|
UNSUPPORTED_QUERY_PARAM: 'unsupported_query_param',
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -79,7 +78,7 @@ export function parseMostLink(link) {
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
const cidString = url.hostname
|
|
82
|
-
const
|
|
81
|
+
const rawFileName = url.searchParams.get('filename')
|
|
83
82
|
const unsupportedParam = [...url.searchParams.keys()].find(
|
|
84
83
|
key => key !== 'filename'
|
|
85
84
|
)
|
|
@@ -89,10 +88,6 @@ export function parseMostLink(link) {
|
|
|
89
88
|
return invalidLink(validation.errorCode)
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
if (!fileName || !fileName.trim()) {
|
|
93
|
-
return invalidLink(MOST_LINK_ERROR_CODES.FILENAME_REQUIRED)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
91
|
if (unsupportedParam) {
|
|
97
92
|
return invalidLink(
|
|
98
93
|
MOST_LINK_ERROR_CODES.UNSUPPORTED_QUERY_PARAM,
|
|
@@ -100,9 +95,15 @@ export function parseMostLink(link) {
|
|
|
100
95
|
)
|
|
101
96
|
}
|
|
102
97
|
|
|
98
|
+
const fileName = rawFileName?.trim() || cidString
|
|
99
|
+
|
|
103
100
|
return { cid: cidString, fileName }
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
export function buildMostLink(cid, fileName) {
|
|
107
|
-
|
|
104
|
+
const trimmedFileName = String(fileName || '').trim()
|
|
105
|
+
if (!trimmedFileName) {
|
|
106
|
+
return `most://${cid}`
|
|
107
|
+
}
|
|
108
|
+
return `most://${cid}?filename=${encodeURIComponent(trimmedFileName)}`
|
|
108
109
|
}
|
|
@@ -196,6 +196,7 @@ export function startRound({ roomCode, players, hostAddress, previousSeq = 0, pr
|
|
|
196
196
|
return {
|
|
197
197
|
address: player.address,
|
|
198
198
|
name: player.name,
|
|
199
|
+
avatar: cleanAvatar(player.avatar),
|
|
199
200
|
publicKey: player.publicKey,
|
|
200
201
|
chips: Number(player.chips) - ZHJ_ANTE,
|
|
201
202
|
status: 'active',
|
|
@@ -597,6 +598,7 @@ function normalizeRoundPlayer(input) {
|
|
|
597
598
|
return {
|
|
598
599
|
address,
|
|
599
600
|
name: String(input.name || shortAddress(address)).slice(0, 50),
|
|
601
|
+
avatar: cleanAvatar(input.avatar),
|
|
600
602
|
publicKey: String(input.publicKey || ''),
|
|
601
603
|
chips: Math.max(0, Number(input.chips) || 0),
|
|
602
604
|
status: input.status === 'folded' ? 'folded' : 'active',
|
|
@@ -614,6 +616,10 @@ function shortAddress(address) {
|
|
|
614
616
|
return address ? `${address.slice(0, 6)}...${address.slice(-4)}` : ''
|
|
615
617
|
}
|
|
616
618
|
|
|
619
|
+
function cleanAvatar(value) {
|
|
620
|
+
return String(value || '').trim().slice(0, 4096)
|
|
621
|
+
}
|
|
622
|
+
|
|
617
623
|
function clone(value) {
|
|
618
624
|
return JSON.parse(JSON.stringify(value))
|
|
619
625
|
}
|
|
@@ -18,6 +18,7 @@ export function createGanDengYanRoom({
|
|
|
18
18
|
roomPlayers.unshift({
|
|
19
19
|
address: normalizeAddress(ownerAddress),
|
|
20
20
|
name: cleanName(ownerName),
|
|
21
|
+
avatar: '',
|
|
21
22
|
})
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -29,6 +30,7 @@ export function createGanDengYanRoom({
|
|
|
29
30
|
players: roomPlayers.slice(0, 6).map((player, seat) => ({
|
|
30
31
|
address: player.address,
|
|
31
32
|
name: cleanName(player.name),
|
|
33
|
+
avatar: cleanAvatar(player.avatar),
|
|
32
34
|
seat,
|
|
33
35
|
hand: [],
|
|
34
36
|
handCount: 0,
|
|
@@ -62,6 +64,7 @@ export function syncGanDengYanLobby(room, players = []) {
|
|
|
62
64
|
.map((player, seat) => ({
|
|
63
65
|
address: player.address,
|
|
64
66
|
name: cleanName(player.name),
|
|
67
|
+
avatar: cleanAvatar(player.avatar),
|
|
65
68
|
seat,
|
|
66
69
|
hand: [],
|
|
67
70
|
handCount: 0,
|
|
@@ -257,6 +260,7 @@ export function publicGanDengYanRoom(room) {
|
|
|
257
260
|
players: orderedPlayers(room).map(player => ({
|
|
258
261
|
address: player.address,
|
|
259
262
|
name: player.name,
|
|
263
|
+
avatar: cleanAvatar(player.avatar),
|
|
260
264
|
seat: player.seat,
|
|
261
265
|
handCount: player.hand?.length ?? player.handCount ?? 0,
|
|
262
266
|
score: Number(player.score ?? INITIAL_SCORE),
|
|
@@ -431,6 +435,7 @@ function normalizePlayers(players) {
|
|
|
431
435
|
.map(player => ({
|
|
432
436
|
address: normalizeAddress(player.address),
|
|
433
437
|
name: cleanName(player.name),
|
|
438
|
+
avatar: cleanAvatar(player.avatar),
|
|
434
439
|
publicKey: String(player.publicKey || ''),
|
|
435
440
|
}))
|
|
436
441
|
.filter(player => {
|
|
@@ -446,6 +451,7 @@ function normalizeRoundPlayer(input) {
|
|
|
446
451
|
return {
|
|
447
452
|
address,
|
|
448
453
|
name: cleanName(input.name),
|
|
454
|
+
avatar: cleanAvatar(input.avatar),
|
|
449
455
|
seat: Number(input.seat || 0),
|
|
450
456
|
hand: Array.isArray(input.hand) ? input.hand.map(normalizeCard).filter(Boolean) : [],
|
|
451
457
|
handCount: Number(input.handCount || 0),
|
|
@@ -679,3 +685,7 @@ function normalizeAddress(value) {
|
|
|
679
685
|
function cleanName(name) {
|
|
680
686
|
return String(name || '玩家').trim().slice(0, 16) || '玩家'
|
|
681
687
|
}
|
|
688
|
+
|
|
689
|
+
function cleanAvatar(avatar) {
|
|
690
|
+
return String(avatar || '').trim().slice(0, 4096)
|
|
691
|
+
}
|
|
@@ -37,6 +37,53 @@ function isLocalHostname(hostname) {
|
|
|
37
37
|
return ['localhost', '127.0.0.1', '::1', '[::1]'].includes(value)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function normalizeNetworkAddress(address) {
|
|
41
|
+
const value = String(address || '')
|
|
42
|
+
.trim()
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.replace(/^\[|\]$/g, '')
|
|
45
|
+
|
|
46
|
+
if (value.startsWith('::ffff:')) {
|
|
47
|
+
return value.slice('::ffff:'.length)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return value
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function isPrivateNetworkHostname(hostname) {
|
|
54
|
+
const value = normalizeNetworkAddress(hostname)
|
|
55
|
+
|
|
56
|
+
if (value === '::1' || value === 'localhost') {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (
|
|
61
|
+
value.includes(':') &&
|
|
62
|
+
(value.startsWith('fc') ||
|
|
63
|
+
value.startsWith('fd') ||
|
|
64
|
+
value.startsWith('fe80:'))
|
|
65
|
+
) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const parts = value.split('.').map(part => Number(part))
|
|
70
|
+
if (
|
|
71
|
+
parts.length !== 4 ||
|
|
72
|
+
parts.some(part => !Number.isInteger(part) || part < 0 || part > 255)
|
|
73
|
+
) {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [first, second] = parts
|
|
78
|
+
return (
|
|
79
|
+
first === 10 ||
|
|
80
|
+
first === 127 ||
|
|
81
|
+
(first === 169 && second === 254) ||
|
|
82
|
+
(first === 172 && second >= 16 && second <= 31) ||
|
|
83
|
+
(first === 192 && second === 168)
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
40
87
|
export function isPublicListenHost(listenHost) {
|
|
41
88
|
const hostname = extractHostname(listenHost)
|
|
42
89
|
if (!hostname) return false
|
|
@@ -76,23 +123,27 @@ export function isLoopbackRemoteAddress(address) {
|
|
|
76
123
|
)
|
|
77
124
|
}
|
|
78
125
|
|
|
79
|
-
export function isLocalRequest(c) {
|
|
126
|
+
export function isLocalRequest(c, options = {}) {
|
|
80
127
|
const host = c.req.header('host')
|
|
81
|
-
if (host) {
|
|
82
|
-
return
|
|
128
|
+
if (host && isLocalRequestHost(host)) {
|
|
129
|
+
return true
|
|
83
130
|
}
|
|
84
|
-
const clientIp =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
const clientIp = c.env?.incoming?.socket?.remoteAddress || ''
|
|
132
|
+
return (
|
|
133
|
+
isLoopbackRemoteAddress(clientIp) ||
|
|
134
|
+
(options.trustPrivateNetwork && isPrivateNetworkHostname(clientIp))
|
|
135
|
+
)
|
|
89
136
|
}
|
|
90
137
|
|
|
91
|
-
export function isLocalUpgradeRequest(req) {
|
|
92
|
-
if (req.headers.host) {
|
|
93
|
-
return
|
|
138
|
+
export function isLocalUpgradeRequest(req, options = {}) {
|
|
139
|
+
if (req.headers.host && isLocalRequestHost(req.headers.host)) {
|
|
140
|
+
return true
|
|
94
141
|
}
|
|
95
|
-
|
|
142
|
+
const remoteAddress = req.socket?.remoteAddress
|
|
143
|
+
return (
|
|
144
|
+
isLoopbackRemoteAddress(remoteAddress) ||
|
|
145
|
+
(options.trustPrivateNetwork && isPrivateNetworkHostname(remoteAddress))
|
|
146
|
+
)
|
|
96
147
|
}
|
|
97
148
|
|
|
98
149
|
export function isRemoteAccessRequest({ invite, origin, listenHost, local }) {
|