Integration API creates Newt sites with an invalid address prefix
Describe the Bug
Integration API creates Newt sites with an invalid address prefix
Version: Pangolin 1.21.1 Edition: Community / OSS Database: SQLite
When creating a Newt site through the Integration API:
PUT /v1/org/{orgId}/sitewith:
{
"name": "integration-test",
"type": "newt"
}the created site receives an address without the organization's CIDR prefix.
For example:
"address": "100.90.128.2"Starting Newt with the returned credentials successfully establishes the websocket and tunnel connection, but then fails while configuring connectivity with:
Failed to ensure WireGuard interface: invalid IP address format: 100.90.128.2The issue appears to come from server/routers/site/createSite.ts:
const { value: newClientAddress, release } =
await getNextAvailableClientSubnet(orgId);
releaseSubnetLock = release;
updatedAddress = newClientAddress.split("/")[0];getNextAvailableClientSubnet() intentionally allocates individual /32 addresses, while its implementation also notes that site/client addresses are stored using the organization's block size.
The Dashboard site-creation flow results in addresses such as:
100.90.128.2/20A tested fix is:
updatedAddress =
`${newClientAddress.split("/")[0]}/${org.subnet!.split("/")[1]}`;After rebuilding Pangolin 1.21.1 with this change, a site created through the Integration API was stored as:
100.90.128.4/20and Newt successfully completed setup:
Websocket connected
Tunnel connection to server established successfully!
Client connectivity setup. Ready to accept connections from clients!I can submit a pull request with the change if this matches the intended behavior.
Environment
- OS Type & Version: Ubuntu 24.04
- Pangolin Version: 1.21.1
- Edition (Community or Enterprise): Community / OSS
- Gerbil Version: 1.4.2
- Traefik Version: 3.6
- Newt Version: 1.14.0
- Client Version: N/A
To Reproduce
Run Pangolin 1.21.1 Community / OSS with the Integration API enabled. Create a Newt site through the Integration API: PUT /v1/org/{orgId}/site
with:
{ "name": "integration-test", "type": "newt" } Observe that the created site address is returned without the organization CIDR prefix, for example: 100.90.128.2 Start Newt using the returned newtId and secret. Newt connects to the Pangolin server and establishes the tunnel, but then fails during interface setup with: Failed to ensure WireGuard interface: invalid IP address format: 100.90.128.2
Expected Behavior
A Newt site created through the Integration API should be assigned and stored with the same address format used by the Dashboard site creation flow.
For example, if the organization subnet is /20, the site address should be stored as:
100.90.128.2/20
Newt should then be able to complete its connectivity setup successfully without an invalid IP address format error.
Source: fosrl/pangolin