Skip to content

Commit f49ff49

Browse files
authored
feat: add GeoIP location support (#151)
* feat: adding geoip
1 parent 64fd949 commit f49ff49

21 files changed

Lines changed: 1011 additions & 106 deletions

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ netstat iftop bandwhich RustNet tcpdump Wireshark
356356
| **Bandwidth per connection** | Yes | Yes | Yes | Yes | No | No | No |
357357
| **Connection filtering** | Yes | No | Yes | Yes | No | Yes | Yes (BPF) |
358358
| **DNS reverse lookup** | Yes | Yes | Yes | Yes | No | No | Yes |
359-
| **GeoIP lookup** | No | No | Yes | No | No | No | Yes |
359+
| **GeoIP lookup** | Yes | No | Yes | No | No | No | Yes |
360360
| **Notifications** | No | No | Yes | No | No | No | No |
361361
| **i18n (translations)** | No | No | Yes | No | No | No | No |
362362
| **Cross-platform** | Linux, macOS, Windows, FreeBSD | Linux, macOS | Linux, macOS, Windows | Linux, macOS, BSD | All | Linux | All |

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Before submitting a PR, please ensure:
2525
```bash
2626
cargo clippy --all-targets --all-features -- -D warnings
2727
```
28+
- **No clippy suppression**: Do not use `#[allow(clippy::...)]` to suppress warnings. Fix the underlying issue instead (e.g., reduce arguments, refactor code). If a suppression is truly unavoidable, discuss it in the PR.
2829
- **Formatting**: Run the formatter
2930
```bash
3031
cargo fmt

Cargo.lock

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ring = "0.17"
4141
aes = "0.8"
4242
serde = { version = "1.0", features = ["derive"] }
4343
serde_json = "1.0"
44+
maxminddb = "0.27"
4445

4546
[target.'cfg(target_os = "linux")'.dependencies]
4647
procfs = "0.18"

INSTALL.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This guide covers all installation methods for RustNet across different platform
1515
- [Using Docker](#using-docker)
1616
- [Prerequisites](#prerequisites)
1717
- [Permissions Setup](#permissions-setup)
18+
- [GeoIP Databases (Optional)](#geoip-databases-optional)
1819
- [Troubleshooting](#troubleshooting)
1920

2021
## Installing from Release Packages
@@ -686,6 +687,71 @@ getcap $(which rustnet)
686687
rustnet --help
687688
```
688689
690+
## GeoIP Databases (Optional)
691+
692+
RustNet supports GeoIP lookups to show country codes for remote IPs. To enable this, install the [GeoLite2](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) databases using MaxMind's `geoipupdate` tool (requires a free [MaxMind account](https://www.maxmind.com/en/geolite2/signup)):
693+
694+
### macOS (Homebrew)
695+
696+
```bash
697+
brew install geoipupdate
698+
# Edit the config with your MaxMind account credentials:
699+
# $(brew --prefix)/etc/GeoIP.conf
700+
geoipupdate
701+
```
702+
703+
Databases are installed to `$(brew --prefix)/share/GeoIP/`.
704+
705+
### Ubuntu/Debian
706+
707+
```bash
708+
sudo apt-get install geoipupdate
709+
# Edit /etc/GeoIP.conf with your MaxMind account credentials
710+
sudo geoipupdate
711+
```
712+
713+
Databases are installed to `/usr/share/GeoIP/`.
714+
715+
### Fedora/RHEL
716+
717+
```bash
718+
sudo dnf install geoipupdate
719+
# Edit /etc/GeoIP.conf with your MaxMind account credentials
720+
sudo geoipupdate
721+
```
722+
723+
Databases are installed to `/usr/share/GeoIP/`.
724+
725+
### Arch Linux
726+
727+
```bash
728+
sudo pacman -S geoipupdate
729+
# Edit /etc/GeoIP.conf with your MaxMind account credentials
730+
sudo geoipupdate
731+
```
732+
733+
Databases are installed to `/usr/share/GeoIP/`.
734+
735+
### FreeBSD
736+
737+
```bash
738+
pkg install geoipupdate
739+
# Edit /usr/local/etc/GeoIP.conf with your MaxMind account credentials
740+
sudo geoipupdate
741+
```
742+
743+
Databases are installed to `/usr/local/share/GeoIP/`.
744+
745+
### Manual Specification
746+
747+
If your databases are in a non-standard location, specify them directly:
748+
749+
```bash
750+
rustnet --geoip-country /path/to/GeoLite2-Country.mmdb --geoip-asn /path/to/GeoLite2-ASN.mmdb
751+
```
752+
753+
RustNet auto-discovers databases from standard locations. Run `rustnet --help` to see the full search path list.
754+
689755
## Troubleshooting
690756
691757
### Common Installation Issues

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A cross-platform network monitoring tool built with Rust. RustNet provides real-
2121
- **Smart Connection Lifecycle**: Protocol-aware timeouts with visual staleness indicators (white → yellow → red) before cleanup
2222
- **Process Identification**: Associate network connections with running processes
2323
- **Service Name Resolution**: Identify well-known services using port numbers
24+
- **GeoIP Location**: Show country codes for remote IPs using GeoLite2 databases (auto-discovered or manually specified)
2425
- **Reverse DNS Lookups**: Resolve IP addresses to hostnames with background async resolution and caching
2526
- **Cross-platform Support**: Works on Linux, macOS, Windows, and FreeBSD
2627
- **Advanced Filtering**: Real-time vim/fzf-style filtering with keyword support (`port:`, `src:`, `dst:`, `sni:`, `process:`, `state:`)

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ The experimental eBPF support provides efficient process identification but has
122122
- Parent process information
123123
- [ ] **Configuration File**: Support for persistent configuration (filters, UI preferences)
124124
- [ ] **Connection Alerts**: Notifications for new connections or suspicious activity
125-
- [ ] **GeoIP Integration**: Maybe add geographical location of remote IPs
125+
- [x] **GeoIP Integration**: Geographical location of remote IPs
126126
- [ ] **Protocol Statistics**: Summary view of protocol distribution
127127
- [ ] **Rate Limiting Detection**: Identify connections with unusual traffic patterns
128128

USAGE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ Options:
8686
-l, --log-level <LEVEL> Set the log level (if not provided, no logging will be enabled)
8787
--json-log <FILE> Enable JSON logging of connection events to specified file
8888
--pcap-export <FILE> Export captured packets to PCAP file for Wireshark analysis
89+
--no-color Disable all colors in the UI (also respects NO_COLOR env var)
90+
--geoip-country <PATH> Path to GeoLite2-Country.mmdb (auto-discovered if not specified)
91+
--geoip-asn <PATH> Path to GeoLite2-ASN.mmdb (auto-discovered if not specified)
92+
--no-geoip Disable GeoIP lookups entirely
8993
-f, --bpf-filter <FILTER> BPF filter expression for packet capture
9094
--no-sandbox Disable Landlock sandboxing (Linux only)
9195
--sandbox-strict Require full sandbox enforcement or exit (Linux only)
@@ -384,6 +388,7 @@ Press `s` to cycle through columns in left-to-right order:
384388
| **Protocol** | ↑ Ascending | Sort by protocol type (TCP, UDP, ICMP, etc.) |
385389
| **Local Address** | ↑ Ascending | Sort by local IP:port (useful for multi-interface systems) |
386390
| **Remote Address** | ↑ Ascending | Sort by remote IP:port |
391+
| **Location** | ↑ Ascending | Sort by country code (requires GeoIP database) |
387392
| **State** | ↑ Ascending | Sort by connection state (ESTABLISHED, etc.) |
388393
| **Service** | ↑ Ascending | Sort by service name or port number |
389394
| **Application** | ↑ Ascending | Sort by detected application protocol (HTTP, DNS, etc.) |

debian/postinst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ NETWORK PACKET CAPTURE PERMISSIONS:
5252
process detection. Check the TUI Statistics panel to see which detection
5353
method is active.
5454
55+
GEOIP (OPTIONAL):
56+
To show country codes for remote IPs, install GeoLite2 databases:
57+
sudo apt-get install geoipupdate
58+
Edit /etc/GeoIP.conf with your free MaxMind credentials, then run:
59+
sudo geoipupdate
60+
See: https://github.com/domcyrus/rustnet/blob/main/INSTALL.md#geoip-databases-optional
61+
5562
USAGE:
5663
rustnet # Start network monitoring
5764
rustnet --help # Show all options

rpm/rustnet.spec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ NETWORK PACKET CAPTURE PERMISSIONS:
109109
For more information, see the documentation at:
110110
%{_docdir}/%{name}/README.md
111111
112+
GEOIP (OPTIONAL):
113+
To show country codes for remote IPs, install GeoLite2 databases:
114+
sudo dnf install geoipupdate
115+
Edit /etc/GeoIP.conf with your free MaxMind credentials, then run:
116+
sudo geoipupdate
117+
See: https://github.com/domcyrus/rustnet/blob/main/INSTALL.md#geoip-databases-optional
118+
112119
USAGE:
113120
rustnet # Start network monitoring
114121
rustnet --help # Show all options

0 commit comments

Comments
 (0)