[PR #17640] [MERGED] Add support for socks connection to Git backend #15151

Closed
opened 2025-12-30 00:20:17 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17640
Author: @arthanson
Created: 9/28/2024
Status: Merged
Merged: 10/1/2024
Merged by: @jeremystretch

Base: developHead: git-datasource


📝 Commits (10+)

📊 Changes

4 files changed (+125 additions, -3 deletions)

View changed files

📝 docs/features/synchronized-data.md (+3 -0)
📝 netbox/core/data_backends.py (+17 -3)
📝 netbox/utilities/constants.py (+4 -0)
netbox/utilities/socks.py (+101 -0)

📄 Description

Fixes: #17639

Note: will also need to install the python_socks library along with the Dulwich library to use this:

pip install dulwich
pip install python_socks

To test locally, start a socks proxy in a docker container. Make a HTTP request and observe it using the proxy:

$ docker run -d --name socks5 -p 1080:1080 serjs/go-socks5-proxy
$ docker logs -f socks5

Specify the local proxy in Netbox configuration.py:

HTTP_PROXIES = {
   'http': 'socks5h://localhost:1080',
   'https': 'socks5h://localhost:1080',
}

Add a remote GIT datasource and you should see the traffic logs in the terminal. Setup a DataSource in Netbox, I was using the following in the form:

Name = GitSync
Type = Git
URL = https://github.com/bogdancordos/netbox_scripts.git

The URL just has a selection of scripts so you can see that it actually syncs the data source. Press the [Sync] button and make sure it actually syncs.

For SOCKs auth scenario it can be setup as follows:

docker run -d --name socks5 -p 1080:1080 -e PROXY_USER=aaa -e PROXY_PASSWORD=bbb  serjs/go-socks5-proxy

Then in configuration.py:

HTTP_PROXIES = {
    'http': 'socks5h://aaa:bbb@localhost:1080',
    'https': 'socks5h://aaa:bbb@localhost:1080',
}

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

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/17640 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 9/28/2024 **Status:** ✅ Merged **Merged:** 10/1/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `git-datasource` --- ### 📝 Commits (10+) - [`4198f77`](https://github.com/netbox-community/netbox/commit/4198f77855563f851e715208b0cb25cb0ff5bebd) Add support for socks connection to Git backend - [`2d46bcd`](https://github.com/netbox-community/netbox/commit/2d46bcdd18d7d310a1e7ec7d386baf90c4b5839a) cleanup socks detection - [`01ec68d`](https://github.com/netbox-community/netbox/commit/01ec68d80a2186c1e23b82114f5e2fe3dcd50bed) add documentation for installing python_socks - [`c287e86`](https://github.com/netbox-community/netbox/commit/c287e868a3b31ccc07bf86b9f3c3ad38223ef58b) dont need lower() - [`ed64af0`](https://github.com/netbox-community/netbox/commit/ed64af0c59a8dd4b7e46968a61655e67008a14db) cleanup - [`c4915ae`](https://github.com/netbox-community/netbox/commit/c4915ae521c7a167f6c23a0c2338df938af2335f) refactor Socks to utilities - [`76a0403`](https://github.com/netbox-community/netbox/commit/76a0403d7e8366daf0fc81b34d0591a74b032b01) fix imports - [`dadbfac`](https://github.com/netbox-community/netbox/commit/dadbfac207e7c6e5ae73f1fa2a2aef2eba392f2e) fix missing comma - [`d40b928`](https://github.com/netbox-community/netbox/commit/d40b9283942a4b9f66cd04072c394f61c69173d8) Update docs/features/synchronized-data.md - [`0a5de27`](https://github.com/netbox-community/netbox/commit/0a5de27335d8a39ec438ca2b24fd7e131f1eb431) review feedback ### 📊 Changes **4 files changed** (+125 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/features/synchronized-data.md` (+3 -0) 📝 `netbox/core/data_backends.py` (+17 -3) 📝 `netbox/utilities/constants.py` (+4 -0) ➕ `netbox/utilities/socks.py` (+101 -0) </details> ### 📄 Description ### Fixes: #17639 **Note:** will also need to install the python_socks library along with the Dulwich library to use this: ``` pip install dulwich pip install python_socks ``` To test locally, start a socks proxy in a docker container. Make a HTTP request and observe it using the proxy: ``` $ docker run -d --name socks5 -p 1080:1080 serjs/go-socks5-proxy $ docker logs -f socks5 ``` Specify the local proxy in Netbox configuration.py: ``` HTTP_PROXIES = { 'http': 'socks5h://localhost:1080', 'https': 'socks5h://localhost:1080', } ``` Add a remote GIT datasource and you should see the traffic logs in the terminal. Setup a DataSource in Netbox, I was using the following in the form: ``` Name = GitSync Type = Git URL = https://github.com/bogdancordos/netbox_scripts.git ``` The URL just has a selection of scripts so you can see that it actually syncs the data source. Press the [Sync] button and make sure it actually syncs. For SOCKs auth scenario it can be setup as follows: ``` docker run -d --name socks5 -p 1080:1080 -e PROXY_USER=aaa -e PROXY_PASSWORD=bbb serjs/go-socks5-proxy ``` Then in configuration.py: ``` HTTP_PROXIES = { 'http': 'socks5h://aaa:bbb@localhost:1080', 'https': 'socks5h://aaa:bbb@localhost:1080', } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:20:17 +01:00
adam closed this issue 2025-12-30 00:20:18 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15151