mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Try to fix Remote Play issue
This commit is contained in:
parent
361ce057b7
commit
41fe12afc6
3
src/types/network.ts
Normal file
3
src/types/network.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export type RemotePlayConsoleAddresses = {
|
||||||
|
[key: string]: number[],
|
||||||
|
}
|
@ -9,6 +9,7 @@ import { XhomeInterceptor } from "./xhome-interceptor";
|
|||||||
import { XcloudInterceptor } from "./xcloud-interceptor";
|
import { XcloudInterceptor } from "./xcloud-interceptor";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref } from "./settings-storages/global-settings-storage";
|
||||||
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
|
|
||||||
type RequestType = 'xcloud' | 'xhome';
|
type RequestType = 'xcloud' | 'xhome';
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ function clearAllLogs() {
|
|||||||
clearDbLogs('XCloudAppLogs', 'logs');
|
clearDbLogs('XCloudAppLogs', 'logs');
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateIceCandidates(candidates: any, options: any) {
|
function updateIceCandidates(candidates: any, options: {preferIpv6Server: boolean, consoleAddrs?: RemotePlayConsoleAddresses}) {
|
||||||
const pattern = new RegExp(/a=candidate:(?<foundation>\d+) (?<component>\d+) UDP (?<priority>\d+) (?<ip>[^\s]+) (?<port>\d+) (?<the_rest>.*)/);
|
const pattern = new RegExp(/a=candidate:(?<foundation>\d+) (?<component>\d+) UDP (?<priority>\d+) (?<ip>[^\s]+) (?<port>\d+) (?<the_rest>.*)/);
|
||||||
|
|
||||||
const lst = [];
|
const lst = [];
|
||||||
@ -83,11 +84,11 @@ function updateIceCandidates(candidates: any, options: any) {
|
|||||||
|
|
||||||
if (options.consoleAddrs) {
|
if (options.consoleAddrs) {
|
||||||
for (const ip in options.consoleAddrs) {
|
for (const ip in options.consoleAddrs) {
|
||||||
const port = options.consoleAddrs[ip];
|
for (const port of options.consoleAddrs[ip]) {
|
||||||
|
|
||||||
newCandidates.push(newCandidate(`a=candidate:${newCandidates.length + 1} 1 UDP 1 ${ip} ${port} typ host`));
|
newCandidates.push(newCandidate(`a=candidate:${newCandidates.length + 1} 1 UDP 1 ${ip} ${port} typ host`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newCandidates.push(newCandidate('a=end-of-candidates'));
|
newCandidates.push(newCandidate('a=end-of-candidates'));
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ function updateIceCandidates(candidates: any, options: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function patchIceCandidates(request: Request, consoleAddrs?: {[index: string]: number}) {
|
export async function patchIceCandidates(request: Request, consoleAddrs?: RemotePlayConsoleAddresses) {
|
||||||
const response = await NATIVE_FETCH(request);
|
const response = await NATIVE_FETCH(request);
|
||||||
const text = await response.clone().text();
|
const text = await response.clone().text();
|
||||||
|
|
||||||
|
@ -7,9 +7,10 @@ import { STATES } from "./global";
|
|||||||
import { patchIceCandidates } from "./network";
|
import { patchIceCandidates } from "./network";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref } from "./settings-storages/global-settings-storage";
|
||||||
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
|
|
||||||
export class XhomeInterceptor {
|
export class XhomeInterceptor {
|
||||||
static #consoleAddrs: {[index: string]: number} = {};
|
static #consoleAddrs: RemotePlayConsoleAddresses = {};
|
||||||
|
|
||||||
static async #handleLogin(request: Request) {
|
static async #handleLogin(request: Request) {
|
||||||
try {
|
try {
|
||||||
@ -41,15 +42,19 @@ export class XhomeInterceptor {
|
|||||||
|
|
||||||
const serverDetails = obj.serverDetails;
|
const serverDetails = obj.serverDetails;
|
||||||
if (serverDetails.ipAddress) {
|
if (serverDetails.ipAddress) {
|
||||||
XhomeInterceptor.#consoleAddrs[serverDetails.ipAddress] = serverDetails.port;
|
XhomeInterceptor.#consoleAddrs[serverDetails.ipAddress] = [serverDetails.port];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverDetails.ipV4Address) {
|
if (serverDetails.ipV4Address) {
|
||||||
XhomeInterceptor.#consoleAddrs[serverDetails.ipV4Address] = serverDetails.ipV4Port;
|
const ports = new Set<number>();
|
||||||
|
ports.add(serverDetails.ipV4Port);
|
||||||
|
ports.add(9002);
|
||||||
|
|
||||||
|
XhomeInterceptor.#consoleAddrs[serverDetails.ipV4Address] = Array.from(ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverDetails.ipV6Address) {
|
if (serverDetails.ipV6Address) {
|
||||||
XhomeInterceptor.#consoleAddrs[serverDetails.ipV6Address] = serverDetails.ipV6Port;
|
XhomeInterceptor.#consoleAddrs[serverDetails.ipV6Address] = [serverDetails.ipV6Port];
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json = () => Promise.resolve(obj);
|
response.json = () => Promise.resolve(obj);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user