mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-02 11:26:46 +02:00
Add setting to bypass region restriction
This commit is contained in:
@@ -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',
|
||||
|
||||
|
@@ -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: {},
|
||||
|
@@ -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',
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user