mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6906] [Feature]: Traffic statistics can be configured to select the network interface card #4578
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4578
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Originally created by @zyxwhj7777-png on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6906
Is your feature request related to a problem?
The sent and received traffic on the network card in the system status doesn't match the cloud provider's traffic statistics. When 3x-ui's 'System Status' summarises network card traffic, it probably just adds up the traffic of all non-loopback interfaces in /proc/net/dev. This way, your actual proxy traffic (like about 30GB) gets counted once for eth0 and once for enP6129s1, so the total naturally becomes about 60GB, exactly double the client traffic.
Describe the solution you'd like
In the panel settings, you can select the network interface used for traffic statistics
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Statistics / traffic counters
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Oct 23, 2026):
Your reading of the code is right: the panel has no setting to choose an interface. The "System Status" network totals add up every interface that is not on a hard-coded list of virtual names, and
enP6129s1is not on that list. Being able to pick the interface is a reasonable feature request.How the totals are built (
internal/web/service/server.go:637-655):isVirtualInterface(internal/web/service/server.go:1498-1522) only skipslo/lo0and names that start withloopback,docker,br-,veth,virbr,tun,tap,wg,tailscaleorzt. Every other interface gets added to the total. The sameNetTraffictotals also feed the Telegram report (internal/web/service/tgbot/tgbot_report.go:156) and the Discord report (internal/web/service/discord/report.go:111-113), so those reports show the doubled figure too. This filter came in with commitad302987("Exclude virtual interfaces from network stats"). It has no tests, and I found no other setting that changes it.Why the total is doubled on your server (my inference, not confirmed in this repo): names like
enP<n>s<n>are what Azure's Accelerated Networking gives the SR-IOV virtual function. That function is attached as a secondary device under the syntheticeth0, and the kernel'seth0counters already include the traffic that goes through it. Adding both interfaces counts the same bytes twice. You can check this on your server:If it shows
master eth0, the panel is double-counting. The same thing would happen with other stacked setups the prefix list doesn't catch, such as bond member interfaces (counted under the bond as well) or VLAN sub-interfaces.Two other differences from your cloud provider's numbers come from how the counters work, so even a single-interface option would not remove them:
The data needed for your idea is already there:
net.IOCounters(true)returns per-interface counters, so an "interface for traffic statistics" setting would just restrict the existing loop. Skipping any interface that has a master device would also fix this case automatically, without the user setting anything. I couldn't open your screenshots, but the explanation above doesn't depend on them. I found no earlier issue asking for this.Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.
@HamedSanaei commented on GitHub (Oct 27, 2026):
I've implemented a proposed solution for this feature request.
The PR adds configurable network interface selection for system traffic statistics:
This allows users with stacked network interfaces (including Azure Accelerated Networking setups) to avoid double-counting by monitoring the appropriate interface.
The implementation also handles counter discontinuities when interfaces change or counters reset, and includes regression tests.
The automatic selection approach was inspired by my existing IPv6Monitor project:
https://github.com/HamedSanaei/ipv6monitor
PR: https://github.com/MHSanaei/3x-ui/pull/6972
Feedback and testing on affected systems are welcome.