Monkey-patch os.hostname on Windows 7
This commit is contained in:
parent
82dad0d7f7
commit
96b864d6a9
11 changed files with 51 additions and 17 deletions
15
app/main.ts
15
app/main.ts
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2017-2022 Signal Messenger, LLC
|
// Copyright 2017-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because it patches "os" module
|
||||||
|
import '../ts/util/patchWindows7Hostname';
|
||||||
|
|
||||||
import { join, normalize } from 'path';
|
import { join, normalize } from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
@ -396,16 +399,6 @@ async function prepareUrl(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hostname: string;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// os.hostname() doesn't work on Windows 7 anymore
|
|
||||||
// See: https://github.com/electron/electron/issues/34404
|
|
||||||
hostname = os.hostname();
|
|
||||||
} catch {
|
|
||||||
hostname = 'Desktop';
|
|
||||||
}
|
|
||||||
|
|
||||||
const urlParams: RendererConfigType = {
|
const urlParams: RendererConfigType = {
|
||||||
name: packageJson.productName,
|
name: packageJson.productName,
|
||||||
locale: getLocale().name,
|
locale: getLocale().name,
|
||||||
|
@ -421,7 +414,7 @@ async function prepareUrl(
|
||||||
environment: enableCI ? Environment.Production : getEnvironment(),
|
environment: enableCI ? Environment.Production : getEnvironment(),
|
||||||
enableCI,
|
enableCI,
|
||||||
nodeVersion: process.versions.node,
|
nodeVersion: process.versions.node,
|
||||||
hostname,
|
hostname: os.hostname(),
|
||||||
appInstance: process.env.NODE_APP_INSTANCE || undefined,
|
appInstance: process.env.NODE_APP_INSTANCE || undefined,
|
||||||
proxyUrl: process.env.HTTPS_PROXY || process.env.https_proxy || undefined,
|
proxyUrl: process.env.HTTPS_PROXY || process.env.https_proxy || undefined,
|
||||||
contentProxyUrl: config.get<string>('contentProxyUrl'),
|
contentProxyUrl: config.get<string>('contentProxyUrl'),
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2019-2022 Signal Messenger, LLC
|
// Copyright 2019-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../ts/windows/shims';
|
||||||
|
|
||||||
import './window/phase1-dependencies';
|
import './window/phase1-dependencies';
|
||||||
import './window/phase2-signal';
|
import './window/phase2-signal';
|
||||||
import './window/phase3-sticker-functions';
|
import './window/phase3-sticker-functions';
|
||||||
|
|
13
ts/util/patchWindows7Hostname.ts
Normal file
13
ts/util/patchWindows7Hostname.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
|
// os.hostname() doesn't work on Windows 7 anymore
|
||||||
|
// See: https://github.com/electron/electron/issues/34404
|
||||||
|
if (process.platform === 'win32' && semver.satisfies(os.release(), '6.1.x')) {
|
||||||
|
os.hostname = () => 'Desktop';
|
||||||
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2018-2021 Signal Messenger, LLC
|
// Copyright 2018-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { contextBridge } from 'electron';
|
import { contextBridge } from 'electron';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2020-2021 Signal Messenger, LLC
|
// Copyright 2020-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import { contextBridge } from 'electron';
|
import { contextBridge } from 'electron';
|
||||||
|
|
||||||
import { SignalContext } from '../context';
|
import { SignalContext } from '../context';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2017-2022 Signal Messenger, LLC
|
// Copyright 2017-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
/* eslint-disable global-require */
|
/* eslint-disable global-require */
|
||||||
|
|
||||||
import * as log from '../../logging/log';
|
import * as log from '../../logging/log';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { contextBridge } from 'electron';
|
import { contextBridge } from 'electron';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// This has to be the first import because of monkey-patching
|
||||||
|
import '../shims';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { contextBridge, ipcRenderer } from 'electron';
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
|
|
4
ts/windows/shims.ts
Normal file
4
ts/windows/shims.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import '../util/patchWindows7Hostname';
|
Loading…
Reference in a new issue