1+ import { BrowserWindow , dialog , ipcMain , shell } from 'electron'
12import _ from 'lodash'
2- import { v4 as uuid } from 'uuid'
3- import { ipcMain , shell , dialog , BrowserWindow } from 'electron'
43import pingLib from 'ping'
4+ import { v4 as uuid } from 'uuid'
55
6- import { store } from '../store/store'
7- import { dnsService } from '../config'
8- import { Server , ServerStore } from '../../shared/interfaces/server.interface'
9- import { EventsKeys } from '../../shared/constants/eventsKeys.constant'
10- import { isValidDnsAddress } from '../../shared/validators/dns.validator'
116import LN from '../../i18n/i18n-node'
127import { Locales } from '../../i18n/i18n-types'
13- import { getLoggerPathFile , LogId , userLogger } from '../shared/logger'
8+ import { EventsKeys } from '../../shared/constants/eventsKeys.constant'
9+ import { Server , ServerStore } from '../../shared/interfaces/server.interface'
10+ import { isValidDnsAddress } from '../../shared/validators/dns.validator'
11+ import { dnsService } from '../config'
12+ import { WindowsPlatform } from '../platforms/windows/windows.platform'
1413import { getOverlayIcon } from '../shared/file'
14+ import { LogId , getLoggerPathFile , userLogger } from '../shared/logger'
1515import { updateOverlayIcon } from '../shared/overlayIcon'
16+ import { isWindows } from '../shared/platform'
17+ import { store } from '../store/store'
1618
1719ipcMain . handle ( EventsKeys . SET_DNS , async ( event , server : Server ) => {
1820 try {
21+ if ( isWindows ( ) ) {
22+ const winPlatform = new WindowsPlatform ( )
23+ const isAvailableWmic = await winPlatform . isWmicAvailable ( )
24+ if ( ! isAvailableWmic ) {
25+ return {
26+ server,
27+ success : false ,
28+ message : 'wmic_not_available' ,
29+ }
30+ }
31+ }
32+
1933 await dnsService . setDns ( server . servers )
2034 const currentLng = LN [ getCurrentLng ( ) ]
2135 const win = BrowserWindow . getAllWindows ( ) [ 0 ]
@@ -41,6 +55,18 @@ ipcMain.handle(EventsKeys.SET_DNS, async (event, server: Server) => {
4155
4256ipcMain . handle ( EventsKeys . CLEAR_DNS , async ( event , server : Server ) => {
4357 try {
58+ if ( isWindows ( ) ) {
59+ const winPlatform = new WindowsPlatform ( )
60+ const isAvailableWmic = await winPlatform . isWmicAvailable ( )
61+ if ( ! isAvailableWmic ) {
62+ return {
63+ server,
64+ success : false ,
65+ message : 'wmic_not_available' ,
66+ }
67+ }
68+ }
69+
4470 await dnsService . clearDns ( )
4571
4672 const currentLng = LN [ getCurrentLng ( ) ]
@@ -224,7 +250,18 @@ ipcMain.handle(EventsKeys.TOGGLE_PIN, async (event, server: Server) => {
224250 }
225251} )
226252
227- ipcMain . handle ( EventsKeys . GET_NETWORK_INTERFACE_LIST , ( ) => {
253+ ipcMain . handle ( EventsKeys . GET_NETWORK_INTERFACE_LIST , async ( ) => {
254+ if ( isWindows ( ) ) {
255+ const winPlatform = new WindowsPlatform ( )
256+ const isAvailableWmic = await winPlatform . isWmicAvailable ( )
257+ if ( ! isAvailableWmic ) {
258+ return {
259+ success : false ,
260+ message : 'wmic_not_available' ,
261+ }
262+ }
263+ }
264+
228265 return dnsService . getInterfacesList ( )
229266} )
230267
0 commit comments