7 Commits

Author SHA1 Message Date
Engelgardt23 e80e673a10 release: v1.0.1
Drop 'made by engelgardt' from the startup banner — author credit stays in README only. Exe now ships the embedded icon (CI uses -iconFile assets/icon.ico).
2026-05-17 18:06:13 +03:00
Engelgardt23 408126f177 ci: pass iconFile to ps2exe so the exe gets the bundled icon 2026-05-17 17:55:00 +03:00
Engelgardt23 c4d98dd5e3 add app icon (assets/icon.ico) + generator script
Embed icon into the exe via ps2exe -iconFile. Regenerate with tools/make_icon.ps1.
2026-05-17 17:54:16 +03:00
engel 789c7b3750 refactor: move source into src/
src/netswitch.ps1 (single file, ~150 lines). CI updated to build from this
path. Added CONTRIBUTING.md describing layout, build, and release flow.

No user-visible behaviour change.
2026-05-16 12:28:10 +03:00
engel a854d8e3f7 Add CI release workflow, CHANGELOG.md, issue templates
- .github/workflows/release.yml: on tag push, build exe via ps2exe,
  package portable zip, attach SHA-256, create GitHub Release.
- CHANGELOG.md: Keep a Changelog format, semver.
- .github/ISSUE_TEMPLATE/: bug_report.yml + feature_request.yml + config.yml
  routing security reports to private advisories.
2026-05-16 11:59:18 +03:00
engel 18eac693e9 SECURITY.md: keep only GitHub private advisories, drop SLA 2026-05-16 11:56:05 +03:00
engel ebe64363c6 Add SECURITY.md (private vuln reporting policy) 2026-05-16 11:52:34 +03:00
10 changed files with 353 additions and 2 deletions
+55
View File
@@ -0,0 +1,55 @@
name: Bug report
description: Something doesn't work as expected
labels: ["bug"]
body:
- type: input
id: version
attributes:
label: Version
description: Visible in the startup banner.
placeholder: v1.0.0
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
placeholder: |
1. ...
2. ...
3. ...
validations:
required: true
- type: textarea
id: expected
attributes:
label: What you expected to happen
validations:
required: true
- type: textarea
id: actual
attributes:
label: What actually happened
description: Paste any error output verbatim. Screenshots are welcome.
validations:
required: true
- type: input
id: os
attributes:
label: Windows version
placeholder: e.g. Windows 11 24H2
- type: input
id: adapter
attributes:
label: Adapter (if relevant)
placeholder: e.g. Realtek USB GbE Family Controller
- type: textarea
id: extra
attributes:
label: Anything else?
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Security vulnerability
url: https://github.com/Engelgardt23/netswitch/security/advisories/new
about: Please report security issues privately via GitHub Security Advisories — not as a public issue.
@@ -0,0 +1,23 @@
name: Feature request
description: Suggest a new feature or an improvement
labels: ["enhancement"]
body:
- type: textarea
id: motivation
attributes:
label: What's the use case?
description: What are you trying to do, and why is the current behavior not enough?
validations:
required: true
- type: textarea
id: proposal
attributes:
label: Proposed solution
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
+78
View File
@@ -0,0 +1,78 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Resolve version from tag
id: ver
shell: bash
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Install ps2exe
shell: pwsh
run: Install-Module -Name ps2exe -Scope CurrentUser -Force -AllowClobber
- name: Build executable
shell: pwsh
run: |
Import-Module ps2exe
$ver = '${{ steps.ver.outputs.version }}'
Invoke-ps2exe -inputFile src/netswitch.ps1 -outputFile netswitch.exe `
-title "netswitch" -description "NIC IP/DHCP toggle - made by engelgardt" `
-company "engelgardt" -version "$ver.0" `
-iconFile assets/icon.ico `
-requireAdmin
- name: Package portable folder
shell: pwsh
run: |
$ver = '${{ steps.ver.outputs.version }}'
$folder = "netswitch-v$ver"
New-Item -ItemType Directory -Path $folder | Out-Null
Copy-Item netswitch.exe $folder/
@"
netswitch v$ver - portable edition
made by engelgardt
Quickly set a Windows network adapter to a static IP or back to DHCP.
USAGE
Double-click netswitch.exe.
Accept the UAC prompt.
Pick the NIC, then choose mode (Static / DHCP).
Press Enter to exit.
NOTES
- Nothing is installed. Delete the folder to remove.
- Requires Windows 10/11.
- PowerShell is bundled into the exe via ps2exe; nothing extra needed.
"@ | Out-File -FilePath "$folder/README.txt" -Encoding UTF8
Compress-Archive -Path $folder -DestinationPath "netswitch-portable-v$ver.zip"
- name: Generate SHA-256 checksum
shell: pwsh
run: |
$ver = '${{ steps.ver.outputs.version }}'
$zip = "netswitch-portable-v$ver.zip"
$hash = (Get-FileHash -Algorithm SHA256 $zip).Hash.ToLower()
"$hash $zip" | Out-File -FilePath "$zip.sha256" -Encoding ASCII -NoNewline
Get-Content "$zip.sha256"
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
netswitch-portable-v${{ steps.ver.outputs.version }}.zip
netswitch-portable-v${{ steps.ver.outputs.version }}.zip.sha256
generate_release_notes: true
+27
View File
@@ -0,0 +1,27 @@
# Changelog
All notable changes to **netswitch** are documented in this file.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.0.1] - 2026-05-17
### Changed
- Dropped the `made by engelgardt` line from the startup banner — keep author credit in the README only.
### Added
- Embedded application icon in the exe (via ps2exe `-iconFile assets/icon.ico`).
## [1.0.0] - 2026-05-16
### Added
- First public release on GitHub.
- Portable `.exe` (~30 KB) built from PowerShell via ps2exe.
- Self-elevation through UAC.
- Physical wired NIC filter — Wi-Fi, VPN, virtual, Hyper-V, VMware, VirtualBox, TAP/TUN, WireGuard, OpenVPN, Tailscale, ZeroTier, Bluetooth, Loopback and WAN Miniport adapters are hidden from the picker.
- Two modes: **Static** (default `10.10.10.1/24`, optional gateway) and **DHCP**.
- Current IPv4 configuration is printed after the change.
- 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
[1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0
+62
View File
@@ -0,0 +1,62 @@
# Contributing
> Project layout, build, and release flow. **If you only want to use the tool — read [README](README.md) instead.**
## Repo layout
```
netswitch/
├── .github/
│ ├── workflows/release.yml ← CI: tag-driven build + GitHub Release
│ └── ISSUE_TEMPLATE/ ← bug / feature / security routing
├── src/
│ └── netswitch.ps1 ← the whole tool (~150 lines)
├── CHANGELOG.md ← Keep a Changelog format, newest first
├── CONTRIBUTING.md ← this file
├── LICENSE / README.md / SECURITY.md
└── .gitignore
```
## Run from source (no exe)
```
powershell -ExecutionPolicy Bypass -File src/netswitch.ps1
```
The script self-elevates through UAC if you launched it without admin.
## Build the portable .exe locally
```
Install-Module ps2exe -Scope CurrentUser
Invoke-ps2exe -inputFile src/netswitch.ps1 -outputFile netswitch.exe `
-title "netswitch" -description "NIC IP/DHCP toggle - made by engelgardt" `
-company "engelgardt" -version "1.0.0.0" `
-requireAdmin
```
## Cut a release
1. Update `src/netswitch.ps1` — bump `$NetswitchVersion` to `X.Y.Z`.
2. Update `CHANGELOG.md` — move items from `[Unreleased]` into a new `[X.Y.Z]` section with today's date.
3. Commit: `git commit -am "vX.Y.Z: …"`.
4. Tag: `git tag vX.Y.Z`.
5. Push: `git push && git push --tags`.
GitHub Actions picks up the tag, builds the exe via ps2exe, writes the SHA-256, and creates the GitHub Release with the zip attached.
## Where features go
The whole tool is a single PowerShell file with these sections (in order):
1. `$NetswitchVersion` / `$GithubRepo` — top of file.
2. **Self-elevate** block — UAC if non-admin.
3. **Banner** — Write-Host title.
4. **`Test-NetswitchUpdate`** — GitHub /releases/latest poll.
5. **Adapter filter + picker**`$skipDescriptionPattern`, `$skipMediaTypes`, `Get-NetAdapter | Where-Object {...}`.
6. **Mode prompt** — Static / DHCP.
7. **Static branch**`netsh interface ipv4 set address ... static ...`.
8. **DHCP branch**`netsh interface ipv4 set address ... source=dhcp`.
9. **Current config display**`Get-NetIPAddress | Format-Table`.
If a section grows past ~50 lines, factor it into `src/lib/<thing>.ps1` and dot-source it from the main file.
+33
View File
@@ -0,0 +1,33 @@
# Security policy
Thanks for taking the time to look at this. Even small tools can introduce real
risk — this one reconfigures network adapters from an elevated process — so
vulnerability reports are very welcome.
## Supported versions
Only the latest tagged release on GitHub is supported. Older versions will not
get fixes; please upgrade first.
## How to report a vulnerability
**Please do not open a public issue** for security-sensitive findings.
Use GitHub's private security advisories: go to the
[Security tab](../../security/advisories/new) of this repo and click
"Report a vulnerability". GitHub will route it privately.
Please include:
- The version you tested (the startup banner is enough).
- Steps to reproduce.
- An assessment of impact.
Reports are reviewed and addressed on a best-effort basis. A fix and a public
advisory will be published once the issue is resolved. Reporters are credited
unless they prefer to stay anonymous.
## Out of scope
- Behavior when run **without** administrator privileges (the tool refuses to
start in that case anyway).
- Issues that require the attacker to already control the user's machine.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

+1 -2
View File
@@ -1,7 +1,7 @@
# netswitch v1.0.0 - quick NIC IP / DHCP toggle
# made by engelgardt
$NetswitchVersion = '1.0.0'
$NetswitchVersion = '1.0.1'
$GithubRepo = 'Engelgardt23/netswitch'
$ErrorActionPreference = 'Stop'
@@ -23,7 +23,6 @@ if (-not $me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host ""
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host " netswitch v$NetswitchVersion - NIC IP/DHCP toggle" -ForegroundColor Cyan
Write-Host " made by engelgardt" -ForegroundColor DarkCyan
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host ""
+69
View File
@@ -0,0 +1,69 @@
# Regenerate assets/icon.ico for this project.
# Edit $Text / colors below and re-run.
param(
[string]$Text = "NET",
[int[]]$ColorFrom = @(120, 220, 140),
[int[]]$ColorTo = @(20, 110, 60),
[string]$OutPath = "$PSScriptRoot\..\assets\icon.ico"
)
Add-Type -AssemblyName System.Drawing
$outDir = Split-Path $OutPath -Parent
if (-not (Test-Path $outDir)) { New-Item -ItemType Directory -Path $outDir -Force | Out-Null }
$bgFrom = [System.Drawing.Color]::FromArgb(255, $ColorFrom[0], $ColorFrom[1], $ColorFrom[2])
$bgTo = [System.Drawing.Color]::FromArgb(255, $ColorTo[0], $ColorTo[1], $ColorTo[2])
$sizes = 256, 128, 64, 48, 32, 16
$pngs = @()
foreach ($s in $sizes) {
$bmp = New-Object System.Drawing.Bitmap $s, $s
$g = [System.Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = 'AntiAlias'
$g.TextRenderingHint = 'AntiAliasGridFit'
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
$r = $s - 2
$path.AddEllipse(1, 1, $r, $r)
$brush = New-Object System.Drawing.Drawing2D.PathGradientBrush($path)
$brush.CenterColor = $bgFrom
$brush.SurroundColors = @($bgTo)
$g.FillEllipse($brush, 1, 1, $r, $r)
$pen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(60, 0, 0, 0)), ([float]($s/64))
$g.DrawEllipse($pen, 1, 1, $r, $r)
$fontSize = [float]($s * 0.32)
$font = New-Object System.Drawing.Font "Segoe UI Black", $fontSize, ([System.Drawing.FontStyle]::Bold), ([System.Drawing.GraphicsUnit]::Pixel)
$sf = New-Object System.Drawing.StringFormat
$sf.Alignment = 'Center'; $sf.LineAlignment = 'Center'
$shadow = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(80, 0, 0, 0))
$g.DrawString($Text, $font, $shadow, [float]($s/2 + $s*0.02), [float]($s/2 + $s*0.02), $sf)
$g.DrawString($Text, $font, [System.Drawing.Brushes]::White, [float]($s/2), [float]($s/2), $sf)
$g.Dispose()
$ms = New-Object System.IO.MemoryStream
$bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
$pngs += ,@{ size = $s; bytes = $ms.ToArray() }
$ms.Dispose(); $bmp.Dispose()
}
$fs = [System.IO.File]::Create($OutPath)
$bw = New-Object System.IO.BinaryWriter $fs
$bw.Write([uint16]0)
$bw.Write([uint16]1)
$bw.Write([uint16]$pngs.Count)
$offset = 6 + 16 * $pngs.Count
foreach ($p in $pngs) {
$w = if ($p.size -ge 256) { 0 } else { $p.size }
$bw.Write([byte]$w); $bw.Write([byte]$w)
$bw.Write([byte]0); $bw.Write([byte]0)
$bw.Write([uint16]1); $bw.Write([uint16]32)
$bw.Write([uint32]$p.bytes.Length); $bw.Write([uint32]$offset)
$offset += $p.bytes.Length
}
foreach ($p in $pngs) { $bw.Write($p.bytes) }
$bw.Close(); $fs.Close()
Write-Host "Wrote $OutPath"