mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
fix: use internal-ip package
fixes https://github.com/tiddly-gittly/TiddlyGit-Desktop/issues/136
This commit is contained in:
parent
be5809bac7
commit
3eb2dbedaf
3 changed files with 197 additions and 302 deletions
490
package-lock.json
generated
490
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -46,9 +46,9 @@
|
|||
"i18next-electron-fs-backend": "2.0.0",
|
||||
"i18next-fs-backend": "1.1.1",
|
||||
"intercept-stdout": "0.1.2",
|
||||
"internal-ip": "^7.0.0",
|
||||
"inversify": "6.0.1",
|
||||
"inversify-inject-decorators": "3.1.0",
|
||||
"ip": "1.1.5",
|
||||
"jimp": "0.16.1",
|
||||
"lodash": "4.17.21",
|
||||
"menubar": "9.1.0",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { address } from 'ip';
|
||||
import { internalIpV4Sync } from 'internal-ip';
|
||||
import { defaultServerIP } from '@/constants/urls';
|
||||
import { logger } from './log';
|
||||
|
||||
|
|
@ -8,9 +8,10 @@ import { logger } from './log';
|
|||
* @param originalUrl might be `"http://0.0.0.0:5212/"`
|
||||
*/
|
||||
export function getLocalHostUrlWithActualIP(originalUrl: string): string {
|
||||
const localHostUrlWithActualIP = originalUrl.replace(/((?:\d{1,3}\.){3}\d{1,3}|localhost)/, address('public') ?? defaultServerIP);
|
||||
const internalIp = internalIpV4Sync();
|
||||
const localHostUrlWithActualIP = originalUrl.replace(/((?:\d{1,3}\.){3}\d{1,3}|localhost)/, internalIp ?? defaultServerIP);
|
||||
logger.debug(
|
||||
`Current available address: address() returns ${address('public') ?? 'undefined'}
|
||||
`Current available address: address() returns ${internalIp ?? 'undefined'}
|
||||
originalUrl: ${originalUrl} , localHostUrlWithActualIP ${localHostUrlWithActualIP}`,
|
||||
);
|
||||
return localHostUrlWithActualIP;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue