2 Commits

Author SHA1 Message Date
engel 7350232362 v1.0.3: quiet update hint instead of interactive prompt 2026-05-17 21:41:34 +03:00
Engelgardt23 67447bc7f1 fix(v1.0.2): suppress netsh output to avoid mojibake on RU console
netsh emits in the OEM code page (CP866 on RU Windows); the modern console showed it as 'DHCP ╤Г╨╢╨╡ ╨▓╨║╨╗╤О╤З╨╡╨╜╨╛...'. Our own English Setting/Done lines remain, and Get-NetIPAddress already prints proper Unicode.
2026-05-17 18:10:09 +03:00
2 changed files with 40 additions and 29 deletions
+12 -1
View File
@@ -6,6 +6,14 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
## [Unreleased]
## [1.0.3] - 2026-05-17
### Changed
- Update check no longer interrupts startup with an interactive prompt. If a newer release is available, a quiet right-aligned `update available (vX.Y.Z)` hint is printed in dim grey directly under the banner — no key press required.
## [1.0.2] - 2026-05-17
### Fixed
- Suppress `netsh` output to avoid mojibake on non-UTF-8 consoles (Russian Windows printed `╤Г╨╢╨╡ ╨▓╨║╨╗╤О╤З╨╡╨╜╨╛...` because netsh emits in the OEM code page). Our own English status lines remain; the post-change `Get-NetIPAddress` block already prints Unicode.
## [1.0.1] - 2026-05-17
### Changed
- Dropped the `made by engelgardt` line from the startup banner — keep author credit in the README only.
@@ -23,5 +31,8 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
- Auto-update check on startup: polls GitHub `/releases/latest` with a 3-second timeout and offers to open the download page if a newer version exists. Silent on offline / API errors.
- MIT licensed.
[Unreleased]: https://github.com/Engelgardt23/netswitch/compare/v1.0.0...HEAD
[Unreleased]: https://github.com/Engelgardt23/netswitch/compare/v1.0.3...HEAD
[1.0.3]: https://github.com/Engelgardt23/netswitch/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/Engelgardt23/netswitch/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/Engelgardt23/netswitch/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0
+29 -29
View File
@@ -1,7 +1,7 @@
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
# made by engelgardt
$NetswitchVersion = '1.0.1'
$NetswitchVersion = '1.0.3'
$GithubRepo = 'Engelgardt23/netswitch'
$ErrorActionPreference = 'Stop'
@@ -19,20 +19,13 @@ if (-not $me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
exit
}
# --- Banner ---
Write-Host ""
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host " netswitch v$NetswitchVersion - NIC IP/DHCP toggle" -ForegroundColor Cyan
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host ""
# --- Update check ---
function Test-NetswitchUpdate {
# --- Update check (silent: returns latest tag if newer, else empty) ---
function Get-NetswitchUpdate {
try {
$url = "https://api.github.com/repos/$GithubRepo/releases/latest"
$r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" }
$latest = ($r.tag_name -as [string]) -replace '^v',''
if (-not $latest) { return }
if (-not $latest) { return '' }
$toTuple = { param($s)
$parts = ($s -split '\.') | ForEach-Object {
$n = 0; [void][int]::TryParse($_, [ref]$n); $n
@@ -42,24 +35,31 @@ function Test-NetswitchUpdate {
}
$L = & $toTuple $latest
$C = & $toTuple $NetswitchVersion
$isNewer = $false
for ($i = 0; $i -lt 3; $i++) {
if ($L[$i] -gt $C[$i]) { $isNewer = $true; break }
if ($L[$i] -lt $C[$i]) { break }
if ($L[$i] -gt $C[$i]) { return $r.tag_name }
if ($L[$i] -lt $C[$i]) { return '' }
}
if ($isNewer) {
Write-Host "Update available: v$NetswitchVersion -> $($r.tag_name)" -ForegroundColor Yellow
$ans = Read-Host "Open the download page in your browser? [Y/n]"
if ($ans -notmatch '^(n|N|no|NO)$') {
Start-Process $r.html_url
return ''
} catch {
return ''
}
}
$latestTag = Get-NetswitchUpdate
# --- Banner ---
Write-Host ""
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host " netswitch v$NetswitchVersion - NIC IP/DHCP toggle" -ForegroundColor Cyan
Write-Host "==============================================" -ForegroundColor Cyan
if ($latestTag) {
$msg = "update available ($latestTag)"
$w = 0
try { $w = $Host.UI.RawUI.WindowSize.Width } catch { $w = 0 }
if ($w -lt ($msg.Length + 2)) { $w = $msg.Length + 2 }
$pad = $w - $msg.Length - 1
Write-Host ((' ' * [Math]::Max(0, $pad)) + $msg) -ForegroundColor DarkGray
}
Write-Host ""
}
} catch {
# silent on offline / API errors
}
}
Test-NetswitchUpdate
# --- Pick adapter (physical wired only) ---
$skipDescriptionPattern = 'VPN|Virtual|AnyConnect|TAP-|TUN-|Bluetooth|Loopback|WAN Miniport|Hyper-V|VMware|VirtualBox|WireGuard|OpenVPN|Tailscale|ZeroTier'
@@ -107,8 +107,8 @@ if ($modeChoice.Trim() -eq '2') {
# --- DHCP ---
Write-Host ""
Write-Host "Setting $($nic.Name) to DHCP..." -ForegroundColor Yellow
& netsh interface ipv4 set address name="$($nic.Name)" source=dhcp
& netsh interface ipv4 set dnsservers name="$($nic.Name)" source=dhcp
$null = & netsh interface ipv4 set address name="$($nic.Name)" source=dhcp 2>&1
$null = & netsh interface ipv4 set dnsservers name="$($nic.Name)" source=dhcp 2>&1
Write-Host "Done." -ForegroundColor Green
}
else {
@@ -125,9 +125,9 @@ else {
Write-Host "Setting $($nic.Name) -> $ip / $mask$( if ($gw) { " via $gw" })" -ForegroundColor Yellow
if ([string]::IsNullOrWhiteSpace($gw)) {
& netsh interface ipv4 set address name="$($nic.Name)" static $ip $mask
$null = & netsh interface ipv4 set address name="$($nic.Name)" static $ip $mask 2>&1
} else {
& netsh interface ipv4 set address name="$($nic.Name)" static $ip $mask $gw
$null = & netsh interface ipv4 set address name="$($nic.Name)" static $ip $mask $gw 2>&1
}
Write-Host "Done." -ForegroundColor Green
}