Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7350232362 | |||
| 67447bc7f1 |
+12
-1
@@ -6,6 +6,14 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [1.0.1] - 2026-05-17
|
||||||
### Changed
|
### Changed
|
||||||
- Dropped the `made by engelgardt` line from the startup banner — keep author credit in the README only.
|
- 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.
|
- 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.
|
- 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
|
[1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0
|
||||||
|
|||||||
+28
-28
@@ -1,7 +1,7 @@
|
|||||||
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
|
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
|
||||||
# made by engelgardt
|
# made by engelgardt
|
||||||
|
|
||||||
$NetswitchVersion = '1.0.1'
|
$NetswitchVersion = '1.0.3'
|
||||||
$GithubRepo = 'Engelgardt23/netswitch'
|
$GithubRepo = 'Engelgardt23/netswitch'
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
@@ -19,20 +19,13 @@ if (-not $me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Banner ---
|
# --- Update check (silent: returns latest tag if newer, else empty) ---
|
||||||
Write-Host ""
|
function Get-NetswitchUpdate {
|
||||||
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 {
|
|
||||||
try {
|
try {
|
||||||
$url = "https://api.github.com/repos/$GithubRepo/releases/latest"
|
$url = "https://api.github.com/repos/$GithubRepo/releases/latest"
|
||||||
$r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" }
|
$r = Invoke-RestMethod -Uri $url -TimeoutSec 3 -Headers @{ 'User-Agent' = "netswitch/$NetswitchVersion" }
|
||||||
$latest = ($r.tag_name -as [string]) -replace '^v',''
|
$latest = ($r.tag_name -as [string]) -replace '^v',''
|
||||||
if (-not $latest) { return }
|
if (-not $latest) { return '' }
|
||||||
$toTuple = { param($s)
|
$toTuple = { param($s)
|
||||||
$parts = ($s -split '\.') | ForEach-Object {
|
$parts = ($s -split '\.') | ForEach-Object {
|
||||||
$n = 0; [void][int]::TryParse($_, [ref]$n); $n
|
$n = 0; [void][int]::TryParse($_, [ref]$n); $n
|
||||||
@@ -42,24 +35,31 @@ function Test-NetswitchUpdate {
|
|||||||
}
|
}
|
||||||
$L = & $toTuple $latest
|
$L = & $toTuple $latest
|
||||||
$C = & $toTuple $NetswitchVersion
|
$C = & $toTuple $NetswitchVersion
|
||||||
$isNewer = $false
|
|
||||||
for ($i = 0; $i -lt 3; $i++) {
|
for ($i = 0; $i -lt 3; $i++) {
|
||||||
if ($L[$i] -gt $C[$i]) { $isNewer = $true; break }
|
if ($L[$i] -gt $C[$i]) { return $r.tag_name }
|
||||||
if ($L[$i] -lt $C[$i]) { break }
|
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
|
|
||||||
}
|
|
||||||
Write-Host ""
|
|
||||||
}
|
}
|
||||||
|
return ''
|
||||||
} catch {
|
} catch {
|
||||||
# silent on offline / API errors
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Test-NetswitchUpdate
|
$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 ""
|
||||||
|
|
||||||
# --- Pick adapter (physical wired only) ---
|
# --- Pick adapter (physical wired only) ---
|
||||||
$skipDescriptionPattern = 'VPN|Virtual|AnyConnect|TAP-|TUN-|Bluetooth|Loopback|WAN Miniport|Hyper-V|VMware|VirtualBox|WireGuard|OpenVPN|Tailscale|ZeroTier'
|
$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 ---
|
# --- DHCP ---
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Setting $($nic.Name) to DHCP..." -ForegroundColor Yellow
|
Write-Host "Setting $($nic.Name) to DHCP..." -ForegroundColor Yellow
|
||||||
& netsh interface ipv4 set address name="$($nic.Name)" source=dhcp
|
$null = & netsh interface ipv4 set address name="$($nic.Name)" source=dhcp 2>&1
|
||||||
& netsh interface ipv4 set dnsservers name="$($nic.Name)" source=dhcp
|
$null = & netsh interface ipv4 set dnsservers name="$($nic.Name)" source=dhcp 2>&1
|
||||||
Write-Host "Done." -ForegroundColor Green
|
Write-Host "Done." -ForegroundColor Green
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -125,9 +125,9 @@ else {
|
|||||||
Write-Host "Setting $($nic.Name) -> $ip / $mask$( if ($gw) { " via $gw" })" -ForegroundColor Yellow
|
Write-Host "Setting $($nic.Name) -> $ip / $mask$( if ($gw) { " via $gw" })" -ForegroundColor Yellow
|
||||||
|
|
||||||
if ([string]::IsNullOrWhiteSpace($gw)) {
|
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 {
|
} 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
|
Write-Host "Done." -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user