Add extra_hosts settings field for resolving internal hostnames#55
Open
Add extra_hosts settings field for resolving internal hostnames#55
Conversation
Maps hostname → IP in settings.json (user/project/local layers, merged with higher precedence winning). The mitmproxy addon writes entries to the shared mitmproxy-config volume, and wg-client appends them to /etc/hosts inside a sentinel block at startup; the agent inherits the file via network_mode: service:wg-client. Resolves #54. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for resolving internal (non-public-DNS) hostnames inside the Sandcat sandbox by introducing an extra_hosts settings field that is merged across settings layers and applied at runtime via /etc/hosts.
Changes:
- Add
extra_hoststo settings merge semantics and document it in the root README. - Extend the mitmproxy addon to validate and write
extra_hostsmappings into the sharedmitmproxy-configvolume. - Update
wg-clientinit to append the generated mappings into/etc/hosts, and add unit tests covering merge/validation/output format.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Documents extra_hosts merge rules and how internal hostname resolution works end-to-end. |
| cli/test/mitmproxy/test_mitmproxy_addon.py | Adds tests for extra_hosts merging, validation, and file output format. |
| cli/templates/devcontainer/sandcat/scripts/wg-client-init.sh | Appends shared-volume extra_hosts content into /etc/hosts inside a sentinel block. |
| cli/templates/devcontainer/sandcat/scripts/mitmproxy_addon.py | Implements extra_hosts merge + validation, and writes an /etc/hosts-format file into the shared volume. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+135
to
+143
| if [ -f "$EXTRA_HOSTS_FILE" ]; then | ||
| sed -i '/^# sandcat extra_hosts BEGIN/,/^# sandcat extra_hosts END/d' /etc/hosts | ||
| if [ -s "$EXTRA_HOSTS_FILE" ]; then | ||
| { | ||
| echo "# sandcat extra_hosts BEGIN" | ||
| cat "$EXTRA_HOSTS_FILE" | ||
| echo "# sandcat extra_hosts END" | ||
| } >> /etc/hosts | ||
| fi |
Comment on lines
61
to
+65
| self.env = merged["env"] | ||
| self._load_secrets(merged["secrets"]) | ||
| self._load_network_rules(merged["network"]) | ||
| self._write_placeholders_env() | ||
| self._write_extra_hosts(merged["extra_hosts"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Maps hostname → IP in settings.json (user/project/local layers, merged with higher precedence winning). The mitmproxy addon writes entries to the shared mitmproxy-config volume, and wg-client appends them to /etc/hosts inside a sentinel block at startup; the agent inherits the file via network_mode: service:wg-client. Resolves #54.