forked from hugle2012/win-network-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
650 lines (586 loc) · 23.4 KB
/
install.ps1
File metadata and controls
650 lines (586 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# Network Configuration Tool
# Advanced Windows network optimization and configuration manager
param(
[switch]$Persistent = $false
)
# Check if running as Administrator
function Test-Administrator {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Get current network configuration
function Get-NetworkConfig {
Write-Host "`n=== Current Network Configuration ===" -ForegroundColor Green
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
foreach ($adapter in $adapters) {
Write-Host "Interface: $($adapter.Name)" -ForegroundColor Cyan
$dns = Get-DnsClientServerAddress -InterfaceIndex $adapter.InterfaceIndex -AddressFamily IPv4
Write-Host "DNS Servers: $($dns.ServerAddresses -join ', ')"
$ip = Get-NetIPAddress -InterfaceIndex $adapter.InterfaceIndex -AddressFamily IPv4 | Where-Object {$_.IPAddress -notlike "169.254.*"}
if ($ip) {
Write-Host "IP Address: $($ip.IPAddress)"
}
# Check MTU
$mtu = Get-NetIPInterface -InterfaceIndex $adapter.InterfaceIndex -AddressFamily IPv4
Write-Host "MTU: $($mtu.NlMtu)"
Write-Host ""
}
# Check DoH status
$dohStatus = Get-DnsClientDohServerAddress -ErrorAction SilentlyContinue
if ($dohStatus) {
Write-Host "DoH Status: Enabled" -ForegroundColor Green
} else {
Write-Host "DoH Status: Disabled" -ForegroundColor Yellow
}
# Check hosts file modifications
$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
$hostsContent = Get-Content $hostsPath -ErrorAction SilentlyContinue
$customEntries = $hostsContent | Where-Object { $_ -notmatch "^#" -and $_ -match "\S" -and $_ -notmatch "localhost" }
if ($customEntries) {
Write-Host "Custom Hosts Entries: $($customEntries.Count)" -ForegroundColor Yellow
} else {
Write-Host "Custom Hosts Entries: None"
}
}
# Set DNS servers
function Set-DNSServers {
param(
[string]$Primary,
[string]$Secondary,
[string]$Name
)
try {
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
foreach ($adapter in $adapters) {
Set-DnsClientServerAddress -InterfaceIndex $adapter.InterfaceIndex -ServerAddresses $Primary, $Secondary
}
Write-Host "DNS set to $Name ($Primary, $Secondary)" -ForegroundColor Green
# Save persistent settings if enabled
if ($global:PersistentMode) {
Save-PersistentSettings -DNSPrimary $Primary -DNSSecondary $Secondary -DNSName $Name
Write-Host "Configuration saved - will persist after reboot" -ForegroundColor Yellow
} else {
Write-Host "Configuration is temporary (will reset on reboot)" -ForegroundColor Yellow
}
# Flush DNS cache after changing
Clear-DNSCache
} catch {
Write-Host "Error setting DNS: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Save persistent settings
function Save-PersistentSettings {
param(
[string]$DNSPrimary,
[string]$DNSSecondary,
[string]$DNSName
)
try {
$regPath = "HKCU:\Software\NetworkConfigTool"
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
Set-ItemProperty -Path $regPath -Name "DNSPrimary" -Value $DNSPrimary
Set-ItemProperty -Path $regPath -Name "DNSSecondary" -Value $DNSSecondary
Set-ItemProperty -Path $regPath -Name "DNSName" -Value $DNSName
Set-ItemProperty -Path $regPath -Name "PersistentMode" -Value $true
} catch {
Write-Host "Warning: Could not save persistent settings: $($_.Exception.Message)" -ForegroundColor Yellow
}
}
# Load persistent settings on startup
function Import-PersistentSettings {
try {
$regPath = "HKCU:\Software\NetworkConfigTool"
if (Test-Path $regPath) {
$persistentMode = Get-ItemProperty -Path $regPath -Name "PersistentMode" -ErrorAction SilentlyContinue
if ($persistentMode.PersistentMode) {
$primary = (Get-ItemProperty -Path $regPath -Name "DNSPrimary" -ErrorAction SilentlyContinue).DNSPrimary
$secondary = (Get-ItemProperty -Path $regPath -Name "DNSSecondary" -ErrorAction SilentlyContinue).DNSSecondary
$name = (Get-ItemProperty -Path $regPath -Name "DNSName" -ErrorAction SilentlyContinue).DNSName
if ($primary -and $secondary) {
Write-Host "Applying persistent DNS settings: $name" -ForegroundColor Yellow
Set-DNSServers -Primary $primary -Secondary $secondary -Name $name
}
}
}
} catch {
Write-Host "Warning: Could not load persistent settings" -ForegroundColor Yellow
}
}
# Clear persistent settings
function Clear-PersistentSettings {
try {
$regPath = "HKCU:\Software\NetworkConfigTool"
if (Test-Path $regPath) {
Remove-Item -Path $regPath -Recurse -Force
}
} catch {
Write-Host "Warning: Could not clear persistent settings" -ForegroundColor Yellow
}
}
# Flush DNS cache
function Clear-DNSCache {
try {
ipconfig /flushdns | Out-Null
Clear-DnsClientCache -ErrorAction SilentlyContinue
Write-Host "DNS cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing DNS cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear browser cache for common browsers
function Clear-BrowserCache {
Write-Host "`n=== Browser Cache Management ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Chrome/Chromium"
Write-Host "2. Firefox"
Write-Host "3. Edge"
Write-Host "4. Brave"
Write-Host "5. Opera"
Write-Host "6. All browsers"
Write-Host "0. Back to main menu"
Write-Host ""
$choice = Read-Host "Select browser to clear cache"
switch ($choice) {
"1" { Clear-ChromeCache }
"2" { Clear-FirefoxCache }
"3" { Clear-EdgeCache }
"4" { Clear-BraveCache }
"5" { Clear-OperaCache }
"6" { Clear-AllBrowserCache }
"0" { return }
default {
Write-Host "Invalid option" -ForegroundColor Red
Start-Sleep 2
}
}
}
# Clear Chrome/Chromium cache
function Clear-ChromeCache {
try {
$chromePaths = @(
"$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache",
"$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Code Cache",
"$env:LOCALAPPDATA\Chromium\User Data\Default\Cache",
"$env:LOCALAPPDATA\Chromium\User Data\Default\Code Cache"
)
foreach ($path in $chromePaths) {
if (Test-Path $path) {
Remove-Item -Path "$path\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Chrome/Chromium cache cleared: $path" -ForegroundColor Green
}
}
Write-Host "Chrome/Chromium cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing Chrome cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear Firefox cache
function Clear-FirefoxCache {
try {
$firefoxPaths = @(
"$env:LOCALAPPDATA\Mozilla\Firefox\Profiles"
)
foreach ($profilePath in $firefoxPaths) {
if (Test-Path $profilePath) {
$profiles = Get-ChildItem $profilePath -Directory | Where-Object { $_.Name -match ".*\.default.*" }
foreach ($profile in $profiles) {
$cachePath = "$profile\cache2"
if (Test-Path $cachePath) {
Remove-Item -Path "$cachePath\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Firefox cache cleared: $cachePath" -ForegroundColor Green
}
}
}
}
Write-Host "Firefox cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing Firefox cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear Edge cache
function Clear-EdgeCache {
try {
$edgePaths = @(
"$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Cache",
"$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Code Cache"
)
foreach ($path in $edgePaths) {
if (Test-Path $path) {
Remove-Item -Path "$path\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Edge cache cleared: $path" -ForegroundColor Green
}
}
Write-Host "Edge cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing Edge cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear Brave cache
function Clear-BraveCache {
try {
$bravePaths = @(
"$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\User Data\Default\Cache",
"$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\User Data\Default\Code Cache"
)
foreach ($path in $bravePaths) {
if (Test-Path $path) {
Remove-Item -Path "$path\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Brave cache cleared: $path" -ForegroundColor Green
}
}
Write-Host "Brave cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing Brave cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear Opera cache
function Clear-OperaCache {
try {
$operaPaths = @(
"$env:LOCALAPPDATA\Opera Software\Opera Stable\Cache",
"$env:LOCALAPPDATA\Opera Software\Opera Stable\Code Cache"
)
foreach ($path in $operaPaths) {
if (Test-Path $path) {
Remove-Item -Path "$path\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Opera cache cleared: $path" -ForegroundColor Green
}
}
Write-Host "Opera cache cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing Opera cache: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Clear all browser caches
function Clear-AllBrowserCache {
try {
Write-Host "Clearing all browser caches..." -ForegroundColor Yellow
Clear-ChromeCache
Clear-FirefoxCache
Clear-EdgeCache
Clear-BraveCache
Clear-OperaCache
Write-Host "All browser caches cleared successfully" -ForegroundColor Green
} catch {
Write-Host "Error clearing all browser caches: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Enable DNS over HTTPS
function Enable-DoH {
try {
# Enable DoH for common DNS servers
$dnsServers = @(
@{Server="1.1.1.1"; Template="https://cloudflare-dns.com/dns-query"},
@{Server="8.8.8.8"; Template="https://dns.google/dns-query"},
@{Server="9.9.9.9"; Template="https://dns.quad9.net/dns-query"}
)
foreach ($dns in $dnsServers) {
Add-DnsClientDohServerAddress -ServerAddress $dns.Server -DohTemplate $dns.Template -AllowFallbackToUdp $true -AutoUpgrade $true -ErrorAction SilentlyContinue
}
Write-Host "DNS over HTTPS enabled for common servers" -ForegroundColor Green
} catch {
Write-Host "Error enabling DoH: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Disable DNS over HTTPS
function Disable-DoH {
try {
$dohServers = Get-DnsClientDohServerAddress -ErrorAction SilentlyContinue
if ($dohServers) {
foreach ($server in $dohServers) {
Remove-DnsClientDohServerAddress -ServerAddress $server.ServerAddress -ErrorAction SilentlyContinue
}
}
Write-Host "DNS over HTTPS disabled" -ForegroundColor Green
} catch {
Write-Host "Error disabling DoH: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Optimize network settings
function Optimize-NetworkSettings {
try {
Write-Host "Applying network optimizations..." -ForegroundColor Yellow
# TCP Window Auto-Tuning
netsh int tcp set global autotuninglevel=normal | Out-Null
# Enable TCP Chimney Offload
netsh int tcp set global chimney=enabled | Out-Null
# Enable RSS (Receive Side Scaling)
netsh int tcp set global rss=enabled | Out-Null
# Optimize TCP settings
netsh int tcp set global timestamps=disabled | Out-Null
netsh int tcp set global ecncapability=enabled | Out-Null
# Set optimal MTU for active adapters
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
foreach ($adapter in $adapters) {
Set-NetIPInterface -InterfaceIndex $adapter.InterfaceIndex -NlMtu 1500 -ErrorAction SilentlyContinue
}
Write-Host "Network optimization completed" -ForegroundColor Green
Write-Host "Restart required for full effect" -ForegroundColor Yellow
} catch {
Write-Host "Error optimizing network: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Reset network optimizations
function Reset-NetworkOptimizations {
try {
Write-Host "Resetting network optimizations..." -ForegroundColor Yellow
netsh int tcp reset | Out-Null
netsh winsock reset | Out-Null
Write-Host "Network settings reset to defaults" -ForegroundColor Green
Write-Host "Restart required to complete reset" -ForegroundColor Yellow
} catch {
Write-Host "Error resetting network: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Manage hosts file
function Edit-HostsFile {
$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
do {
Clear-Host
Write-Host "=== Hosts File Management ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. View current hosts file"
Write-Host "2. Add custom entry"
Write-Host "3. Remove custom entries"
Write-Host "4. Backup hosts file"
Write-Host "5. Restore hosts file"
Write-Host "0. Back to main menu"
Write-Host ""
$choice = Read-Host "Select an option"
switch ($choice) {
"1" {
Write-Host "`n=== Current Hosts File ===" -ForegroundColor Green
Get-Content $hostsPath | Write-Host
Read-Host "`nPress Enter to continue"
}
"2" {
$domain = Read-Host "Enter domain to block/redirect"
$ip = Read-Host "Enter IP (127.0.0.1 to block, or custom IP)"
if (-not $ip) { $ip = "127.0.0.1" }
try {
Add-Content $hostsPath "`n$ip`t$domain"
Write-Host "Entry added successfully" -ForegroundColor Green
Write-Host "`n⚠️ IMPORTANT: Restart your browser or clear browser cache for changes to take effect!" -ForegroundColor Yellow
Write-Host " Use Option 7 (Clear Browser Cache) to automatically clear cache" -ForegroundColor Cyan
} catch {
Write-Host "Error adding entry: $($_.Exception.Message)" -ForegroundColor Red
}
Read-Host "`nPress Enter to continue"
}
"3" {
try {
$backup = Get-Content $hostsPath
$defaultContent = $backup | Where-Object { $_ -match "^#" -or $_ -match "localhost" -or $_ -notmatch "\S" }
Set-Content $hostsPath $defaultContent
Write-Host "Custom entries removed" -ForegroundColor Green
} catch {
Write-Host "Error removing entries: $($_.Exception.Message)" -ForegroundColor Red
}
Read-Host "`nPress Enter to continue"
}
"4" {
try {
Copy-Item $hostsPath "$hostsPath.backup"
Write-Host "Hosts file backed up to $hostsPath.backup" -ForegroundColor Green
} catch {
Write-Host "Error backing up: $($_.Exception.Message)" -ForegroundColor Red
}
Read-Host "`nPress Enter to continue"
}
"5" {
if (Test-Path "$hostsPath.backup") {
try {
Copy-Item "$hostsPath.backup" $hostsPath -Force
Write-Host "Hosts file restored from backup" -ForegroundColor Green
} catch {
Write-Host "Error restoring: $($_.Exception.Message)" -ForegroundColor Red
}
} else {
Write-Host "No backup file found" -ForegroundColor Red
}
Read-Host "`nPress Enter to continue"
}
"0" { return }
default {
Write-Host "Invalid option" -ForegroundColor Red
Start-Sleep 2
}
}
} while ($true)
}
# Reset to automatic DNS
function Reset-DNS {
try {
$adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
foreach ($adapter in $adapters) {
Set-DnsClientServerAddress -InterfaceIndex $adapter.InterfaceIndex -ResetServerAddresses
}
Clear-DNSCache
Write-Host "DNS reset to automatic (ISP default)" -ForegroundColor Green
} catch {
Write-Host "Error resetting DNS: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Advanced network diagnostics
function Test-NetworkDiagnostics {
Write-Host "`n=== Network Diagnostics ===" -ForegroundColor Green
# Test connectivity
$testSites = @("google.com", "cloudflare.com", "github.com")
foreach ($site in $testSites) {
$result = Test-NetConnection -ComputerName $site -Port 80 -InformationLevel Quiet
$status = if ($result) { "OK" } else { "FAIL" }
$color = if ($result) { "Green" } else { "Red" }
Write-Host "$site : $status" -ForegroundColor $color
}
# DNS resolution test
Write-Host "`n=== DNS Resolution Test ===" -ForegroundColor Green
foreach ($site in $testSites) {
try {
$resolved = Resolve-DnsName $site -ErrorAction Stop
Write-Host "$site : $($resolved[0].IPAddress)" -ForegroundColor Green
} catch {
Write-Host "$site : FAILED" -ForegroundColor Red
}
}
# Speed test simulation
Write-Host "`n=== Connection Quality ===" -ForegroundColor Green
$ping = Test-NetConnection google.com -InformationLevel Detailed
if ($ping.PingSucceeded) {
Write-Host "Ping to Google: $($ping.PingReplyDetails.RoundtripTime)ms" -ForegroundColor Green
} else {
Write-Host "Ping to Google: FAILED" -ForegroundColor Red
}
}
# Main menu
function Show-Menu {
Clear-Host
Write-Host "=== Advanced Network Configuration Tool ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "DNS Configuration:"
Write-Host "1. View current configuration"
Write-Host "2. Set Cloudflare DNS (1.1.1.1) - Fast & Secure"
Write-Host "3. Set Google DNS (8.8.8.8) - Reliable"
Write-Host "4. Set OpenDNS (208.67.222.222) - Family Safe"
Write-Host "5. Set Quad9 DNS (9.9.9.9) - Malware Protection"
Write-Host "6. Flush DNS Cache"
Write-Host "7. Clear Browser Cache"
Write-Host ""
Write-Host "Advanced Features:"
Write-Host "8. Enable DNS over HTTPS (DoH)"
Write-Host "9. Disable DNS over HTTPS (DoH)"
Write-Host "10. Optimize network settings"
Write-Host "11. Reset network optimizations"
Write-Host "12. Manage hosts file"
Write-Host "13. Run network diagnostics"
Write-Host ""
Write-Host "System:"
Write-Host "14. Reset to ISP default"
Write-Host "15. Toggle persistent mode (Current: $($global:PersistentMode))"
Write-Host "0. Exit"
Write-Host ""
}
# Initialize
if (-not (Test-Administrator)) {
Write-Host "This tool requires administrator privileges." -ForegroundColor Red
Write-Host "Please run PowerShell as Administrator and try again." -ForegroundColor Red
Read-Host "Press Enter to exit"
exit
}
$global:PersistentMode = $Persistent
Write-Host "Advanced Network Configuration Tool loaded successfully!" -ForegroundColor Green
Write-Host "Administrator privileges: OK" -ForegroundColor Green
# Load persistent settings if they exist
if (-not $Persistent) {
Import-PersistentSettings
}
do {
Show-Menu
$choice = Read-Host "Select an option"
switch ($choice) {
"1" {
Get-NetworkConfig
Read-Host "`nPress Enter to continue"
}
"2" {
Set-DNSServers -Primary "1.1.1.1" -Secondary "1.0.0.1" -Name "Cloudflare"
Read-Host "`nPress Enter to continue"
}
"3" {
Set-DNSServers -Primary "8.8.8.8" -Secondary "8.8.4.4" -Name "Google"
Read-Host "`nPress Enter to continue"
}
"4" {
Set-DNSServers -Primary "208.67.222.222" -Secondary "208.67.220.220" -Name "OpenDNS"
Read-Host "`nPress Enter to continue"
}
"5" {
Set-DNSServers -Primary "9.9.9.9" -Secondary "149.112.112.112" -Name "Quad9"
Read-Host "`nPress Enter to continue"
}
"6" {
Clear-DNSCache
Read-Host "`nPress Enter to continue"
}
"7" {
Clear-BrowserCache
}
"8" {
Enable-DoH
Read-Host "`nPress Enter to continue"
}
"9" {
Disable-DoH
Read-Host "`nPress Enter to continue"
}
"10" {
Optimize-NetworkSettings
Read-Host "`nPress Enter to continue"
}
"11" {
Reset-NetworkOptimizations
Read-Host "`nPress Enter to continue"
}
"12" {
Edit-HostsFile
}
"13" {
Test-NetworkDiagnostics
Read-Host "`nPress Enter to continue"
}
"14" {
Reset-DNS
Disable-DoH
Clear-PersistentSettings
Read-Host "`nPress Enter to continue"
}
"15" {
$global:PersistentMode = -not $global:PersistentMode
Write-Host "Persistent mode: $($global:PersistentMode)" -ForegroundColor Yellow
if (-not $global:PersistentMode) {
Clear-PersistentSettings
Write-Host "Persistent settings cleared" -ForegroundColor Green
}
Read-Host "`nPress Enter to continue"
}
"0" {
if (-not $global:PersistentMode) {
$reset = Read-Host "Reset all settings to default before exit? (y/N)"
if ($reset -eq "y" -or $reset -eq "Y") {
Reset-DNS
Disable-DoH
Clear-PersistentSettings
Write-Host "Settings reset to default" -ForegroundColor Green
}
}
Write-Host "Goodbye!" -ForegroundColor Green
break
}
default {
Write-Host "Invalid option. Please try again." -ForegroundColor Red
Start-Sleep 2
}
}
} while ($true)