2026-08-19 15:58:54 +02:00
2026-08-19 15:51:41 +02:00
2026-08-19 15:58:54 +02:00
2026-07-27 16:48:56 +02:00
2026-08-13 09:40:15 +02:00
2026-08-13 09:40:15 +02:00
2026-07-27 16:44:20 +02:00
2026-08-14 16:29:47 +02:00
2026-08-14 17:13:54 +02:00
2026-08-13 09:40:15 +02:00

findbaseport

findbaseport is a CLI tool that searches a specified port range and returns the starting port of the first contiguous block of available ports with the requested size.

Motivation

This tool was created to simplify finding a suitable base port for a CryoSPARC installation.

CryoSPARC requires a base port and expects a range of 10 contiguous ports to be available starting from that port. Finding an appropriate base port manually can be inconvenient, particularly on systems where some ports are already in use.

findbaseport automates this process by searching a specified port range and returning the first port from which the requested number of contiguous ports are available.

For example, when looking for a base port with the default requirement of 10 contiguous ports, the tool searches for a sequence such as:

8000  8001  8002  8003  8004  8005  8006  8007  8008  8009

If all 10 ports are available, 8000 can be used as the base port. If any of those ports are unavailable, the tool continues searching until it finds the next suitable contiguous block.

Description

The tool searches an inclusive port range for available ports.

Given a range and a requested block size, findbaseport finds the first sequence of contiguous available ports that is large enough and returns the starting port of that block.

For example, if the requested block size is 3 in a range of 8000 to 8020:

findbaseport --start 8000 --end 8020 --count 3

and ports 8000, 8001, and 8002 are available, the command returns:

8000

If those ports are unavailable but 8010, 8011, and 8012 are available, it returns:

8010

Installation

Build from source

Clone the repository and use the included Makefile:

git clone <repository-url>
cd <repository-directory>

make build

The resulting binary is placed in:

bin/findbaseport

You can then run it with:

./bin/findbaseport --help

Usage

./bin/findbaseport --help

The help output describes the available command-line options and arguments.

The command searches within the specified port range and returns the start port of the first contiguous block of available ports with the requested size.

Development

The project provides a Makefile with commands for formatting, static analysis, linting, and building.

Run everything

make

The default target runs:

  1. fmt
  2. vet
  3. lint
  4. build

Format

Format all Go source files:

make fmt

Vet

Run Go's static analysis:

make vet

Lint

Run golangci-lint:

make lint

Make sure golangci-lint is installed and available in your PATH.

Build

Build the CLI:

make build

The binary is written to:

bin/findbaseport

Clean

Remove build artifacts:

make clean

Requirements

  • Go
  • make
  • golangci-lint for linting

Make Targets

Target Description
make Format, vet, lint, and build
make fmt Format Go source code
make vet Run go vet
make lint Run golangci-lint
make build Build findbaseport into bin/
make clean Remove the bin/ directory

License

See the repository's LICENSE file for licensing information.

S
Description
A CLI tool that searches a specified port range and returns the starting port of the first contiguous block of available ports with the requested size.
Readme GPL-3.0
71 KiB
v0.1.0
Latest
2026-08-24 13:48:22 +02:00
Languages
Go 93.7%
Makefile 6.3%