Skip to content

Commit cdac70a

Browse files
committed
tweaks support in single file
1 parent ff6ef91 commit cdac70a

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const menuTemplate = require('./view/menuTemplate');
1010

1111
import { LogMessage } from "./model/LogMessage";
1212
import { winstonLogger } from "./winstonLoggerSystem";
13+
import { tweaks_geoLocationOverride, tweaks_WebRTCAnoym } from "./tweaks";
1314

1415
//BOT Loader
1516
const puppeteer = require('puppeteer');
@@ -23,6 +24,11 @@ var isOpenHeadless: boolean = false; // option for open chromium in headless mod
2324
var isBotLaunched: boolean = false; // flag for check whether the bot is running
2425
var puppeteerContainer: any; // puppeteer page object
2526

27+
var puppeteerCustomArgs: string[] = ['--no-sandbox', '--disable-setuid-sandbox'];
28+
if (tweaks_WebRTCAnoym === false) { // tweaks_WebRTCAnoym : Local IP WebRTC Anonymization for the bot. MORE INFO : tweaks.ts
29+
puppeteerCustomArgs.push('--disable-features=WebRtcHideLocalIpsWithMdns');
30+
}
31+
2632
const MenuItemSwitch = {
2733
announceMsg: false,
2834
superAdminKey: false
@@ -65,6 +71,13 @@ ipcMain.on('room-make-action', (event: any, arg: any) => { // webRender.js
6571
arg.password = null;
6672
}
6773
hostRoomConfig = arg;
74+
if (tweaks_geoLocationOverride.patch === true) { // tweaks_geoLocationOverride : GeoLocation overriding for the room. MORE INFO : tweaks.ts
75+
hostRoomConfig.geo = {
76+
code: tweaks_geoLocationOverride.code
77+
, lat: tweaks_geoLocationOverride.lat
78+
, lon: tweaks_geoLocationOverride.lon
79+
}
80+
}
6881
hostRoomConfig.maxPlayers = parseInt(arg.maxPlayers, 10); // do type casting because conveyed maxPlayers value is string type
6982
if(isBotLaunched != true) {
7083
if(Menu.getApplicationMenu().getMenuItemById('headlessModeMenuItem').checked == true) { // if headless mode checkbox is checked
@@ -186,17 +199,12 @@ async function nodeStorageInit() {
186199

187200
async function bot(hostConfig: string) {
188201
console.log('\x1b[32m%s\x1b[0m', "The headless host has started.");
202+
189203
//await nodeStorage.init();
190204

191-
192-
/*
193-
If you are hosting on a VPS using Chrome version 78 or greater
194-
then it is required to disable the Local IP WebRTC Anonymization feature for the host to work.
195-
Run chrome with the command flag --disable-features=WebRtcHideLocalIpsWithMdns to disable the feature.
196-
*/
197205
const browser = await puppeteer.launch({
198206
headless: isOpenHeadless,
199-
args: ['--no-sandbox', '--disable-setuid-sandbox'] // add --disable-features=WebRtcHideLocalIpsWithMdns if you are using vps
207+
args: puppeteerCustomArgs
200208
});
201209
await browser.on('disconnected', () => {
202210
clearInterval(storageLoop);

tweaks.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SOME TWEAKS FOR SUPPORT BOT PROBLEMS ON YOUR ENVIRONMENT
2+
3+
// tweaks_WebRTCAnoym : Local IP WebRTC Anonymization for the bot
4+
// if you are suffering connection problem with vps server, disable this option
5+
export const tweaks_WebRTCAnoym: boolean = true; //true: enable, false: disable
6+
7+
// tweaks_geoLocationOverride : GeoLocation overriding for the room
8+
// if your bot has wrong location, enable this patch option
9+
export const tweaks_geoLocationOverride = {
10+
patch: false // true: enable, false: disable
11+
// GeoLocation Setting for Seoul
12+
,code: "KR"
13+
,lat: 37.5665
14+
,lon: 126.978
15+
}

0 commit comments

Comments
 (0)