Add setting to bypass region restriction

This commit is contained in:
redphx
2024-07-13 17:27:40 +07:00
parent ce1901b300
commit ef2e0892bc
7 changed files with 33 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ export enum BxEvent {
REMOTE_PLAY_FAILED = 'bx-remote-play-failed',
XCLOUD_SERVERS_READY = 'bx-servers-ready',
XCLOUD_SERVERS_UNAVAILABLE = 'bx-servers-unavailable',
DATA_CHANNEL_CREATED = 'bx-data-channel-created',

View File

@@ -13,6 +13,8 @@ const browserHasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoi
const userAgentHasTouchSupport = !isTv && !isVr && browserHasTouchSupport;
export const STATES: BxStates = {
supportedRegion: true,
isPlaying: false,
appContext: {},
serverRegions: {},

View File

@@ -1,5 +1,5 @@
import { CE } from "@utils/html";
import { SUPPORTED_LANGUAGES, t } from "@utils/translation";
import { SUPPORTED_LANGUAGES, t, ut } from "@utils/translation";
import { SettingElement, SettingElementType } from "@utils/settings";
import { UserAgent } from "@utils/user-agent";
import { StreamStat } from "@modules/stream/stream-stats";
@@ -17,6 +17,8 @@ export enum PrefKey {
BETTER_XCLOUD_LOCALE = 'bx_locale',
SERVER_REGION = 'server_region',
SERVER_BYPASS_RESTRICTION = 'server_bypass_restriction',
PREFER_IPV6_SERVER = 'prefer_ipv6_server',
STREAM_TARGET_RESOLUTION = 'stream_target_resolution',
STREAM_PREFERRED_LOCALE = 'stream_preferred_locale',
@@ -122,6 +124,12 @@ export class Preferences {
label: t('region'),
default: 'default',
},
[PrefKey.SERVER_BYPASS_RESTRICTION]: {
label: ut('Bypass region restriction'),
note: ut('⚠️ Use this at your own risk'),
default: false,
},
[PrefKey.STREAM_PREFERRED_LOCALE]: {
label: t('preferred-game-language'),
default: 'default',

View File

@@ -12,7 +12,17 @@ import { getPreferredServerRegion } from "./region";
export
class XcloudInterceptor {
static async #handleLogin(request: RequestInfo | URL, init?: RequestInit) {
if (getPref(PrefKey.SERVER_BYPASS_RESTRICTION)) {
(request as Request).headers.set('X-Forwarded-For', '9.9.9.9');
}
const response = await NATIVE_FETCH(request, init);
if (response.status !== 200) {
// Unsupported region
BxEvent.dispatch(window, BxEvent.XCLOUD_SERVERS_UNAVAILABLE);
return response;
}
const obj = await response.clone().json();
// Preload Remote Play