Skip to content

Commit

Permalink
Get OUTPUT of MHDDOS from STDERR. Fixes for autoupdater
Browse files Browse the repository at this point in the history
  • Loading branch information
opengs committed Apr 3, 2024
1 parent 34a5845 commit 05df511
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/module/mhddosproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class MHDDOSProxy extends Module<Config> {
// Process statistics
let lastStatisticsEvent = null as Date | null
let statisticsBuffer = ''
handler.stderr.on('data', (data: Buffer) => {
handler.stdout.on('data', (data: Buffer) => {
statisticsBuffer += data.toString()

const lines = statisticsBuffer.trimEnd().split('\n')
Expand Down
14 changes: 14 additions & 0 deletions lib/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import decompress from 'decompress'
import { v4 as uuid4 } from 'uuid'
import { Settings } from '../../src-electron/handlers/settings'
import { getCPUArchitecture } from './archLib'
import { ca } from 'app/dist/electron/UnPackaged/assets/index.3949846e'

export type ModuleName = 'DB1000N' | 'DISTRESS' | 'MHDDOS_PROXY'

Expand Down Expand Up @@ -116,6 +117,8 @@ export abstract class Module<ConfigType extends BaseConfig> {
private _config?: ConfigType
protected abstract get defaultConfig(): ConfigType

private autoupdateInterval?: NodeJS.Timeout

protected async getInstallationDirectory () {
const settingsData = await this.settings.getData()
return path.join(settingsData.modules.dataPath, this.name)
Expand Down Expand Up @@ -366,6 +369,14 @@ export abstract class Module<ConfigType extends BaseConfig> {
config = await this.getConfig()
}

this.autoupdateInterval = setInterval(async () => {
const updateConfig = await this.getConfig()
if (updateConfig.autoUpdate && await this.installLatestVersion() && this.isRunning) {
await this.stop()
await this.start()
}
}, 1000 * 60 * 30) // Try to autoupdate once in 30 minutes

const installDirectory = await this.getInstallationDirectory()

if (config.selectedVersion === undefined) {
Expand Down Expand Up @@ -401,6 +412,9 @@ export abstract class Module<ConfigType extends BaseConfig> {
}

protected async stopExecutable (): Promise<void> {
clearInterval(this.autoupdateInterval)
this.autoupdateInterval = undefined

const handler = this.executedProcessHandler // Copy handler, because other async task can chenage it in the meantime

await new Promise<void>((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itarmykit",
"version": "1.3.6",
"version": "1.3.7",
"description": "IT Army Kit",
"productName": "IT Army Kit",
"author": {
Expand Down

0 comments on commit 05df511

Please sign in to comment.