mirror of
https://github.com/fosrl/newt.git
synced 2026-03-09 07:12:28 -05:00
[PR #65] [MERGED] Newt Container Network Checking #98
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/newt/pull/65
Author: @JonnyBooker
Created: 6/10/2025
Status: ✅ Merged
Merged: 6/22/2025
Merged by: @oschwartz10612
Base:
dev← Head:docker-network-checking📝 Commits (10+)
a4d4976Update to use docker network checking against newt networkinga52260bAdd an enforce network validation flag for docker to not break previous functionalityd4b88c3Merge branch 'fosrl:main' into docker-network-checkinge335bb8Rename added functions for docker clientcbbd5b0Add extra pre-condition check for enforcing docker network126ced6Merge branch 'docker-network-checking' of https://github.com/JonnyBooker/newt into docker-network-checking5476a69Log the container name and ide26552aSmall refinement to how the docker enforcement setting is applied5cb86f3Update to readme with new configuration settings6d9160aSimplified based on PR feedback and support checking use of "bridge" network📊 Changes
3 files changed (+234 additions, -54 deletions)
View changed files
📝
README.md(+37 -2)📝
docker/client.go(+130 -32)📝
main.go(+67 -20)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
Added functionality to be able to restrict the visibility/accessibility of containers that Newt sends to pangolin. Checks will be carried out to ensure that only containers that are available on the same Docker network are sent over to Pangolin.
Default behaviour is as is before to maintain previous behaviour to not break the upgrade path. There is an extra configuration options added to make these checks take place of
DOCKER_ENFORCE_NETWORK_VALIDATIONor CLI commanddocker-enforce-network-validation.This will find the host container, use it to get the networks the Newt container is on, retrieve other containers and using their networks, determine if the Network ID of the Newt Container and other container networks match. If not, they are not sent to Pangolin.
It would be possible to still manually add the container IP/hostname to the Pangolin UI as a target. If validation is enforced, the target will be validated to ensure that it can be seen by Newt, a log will be output as a warning stating the target has not been added due to this new enforcement setting:

Changes have also been made as to how the hostname/IP address of the container is determined. When run as a Newt Docker container, it will be determined under what network mode the Newt container is running on. This has been done to make it so that when using a dedicated docker network, it is accessed internally on the docker network using its hostname rather then an IP, which is more liable to change. The following scenarios will result in the use of IP addresses or hostnames:
Example of this functionality in use using a specified docker network:

Example of it being used in network "bridge" mode:

This validation is not possible when the container is run in "host" mode. As it has escalated privileges and also then shares the hostname with the host machine it is running on. This will result in an error of "failed to find host container" being output to the logs.
Example if it being used in network "host" mode with no network validation enabled:

How to test?
docker-compose.ymlit is possible to test not sending back containers on other networksFurther testing can be carried out changing the network mode by changing the
network_modetobridgeandhostExample output:

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.