Commit Graph

411 Commits

Author SHA1 Message Date
Andreas Gocht-Zech
059390b145 fix an error in the bindings 2023-09-05 23:07:42 +02:00
Andreas Gocht-Zech
a11eb726bf Merge branch 'raboof:main' into report_changes 2023-08-21 21:41:32 +02:00
Andreas Gocht-Zech
9d8c92356c fix 2023-08-20 22:28:43 +02:00
Andreas Gocht-Zech
668ae29c0a add reporting of changes since last request 2023-08-20 22:07:43 +02:00
Arnout Engelen
1c06371dcd Merge pull request #258 from AndreasGocht/main
fix python bindings
2023-07-13 22:13:41 +02:00
Andreas Gocht-Zech
b581af6990 fix python bindings 2023-07-12 20:46:59 +02:00
Arnout Engelen
f281ca30d1 Merge pull request #255 from DiedByDisgust/main
fix get_devlen function from being pointless
2023-04-23 11:09:55 +02:00
DiedByDisgust
bf44e39240 fix get_devlen function from being pointless 2023-04-22 18:02:44 -04:00
Arnout Engelen
24973112ba Merge pull request #251 from sgtcortez/main
Fix wrong extern declaration of pidsToWatch
2023-03-22 14:22:39 +01:00
Matheus Rambo
c55a10bf26 fix: Wrong definition of "pidsToWatch" #230 2023-03-22 10:00:52 -03:00
Arnout Engelen
8f43d02d8c Merge pull request #250 from orhun/docs/update_readme
Add Arch Linux instructions to README.md
2023-02-25 12:09:25 +01:00
Orhun Parmaksız
6763ff9aa2 Add Arch Linux instructions to README.md 2023-02-25 00:24:55 +03:00
Arnout Engelen
d30c5226a0 Format source code
It appears we have failed to run `make format` in the last few
commits. Doing it now. We should really add it to CI
2023-01-09 12:39:07 +01:00
Arnout Engelen
80df0044ec Merge pull request #242 from a1346054/fixes
Use `s` instead of `sec` for units of seconds
2022-10-17 09:00:13 +02:00
a1346054
56c9348372 Trim trailing whitespace 2022-10-13 00:05:35 +00:00
a1346054
22c43c5523 Fix typo 2022-10-13 00:05:35 +00:00
a1346054
aefa6cf194 Use s instead of sec for units of seconds 2022-10-12 23:55:29 +00:00
Arnout Engelen
0dcba3c81f Merge pull request #236 from NeilZhy/app-std-c++14
Add -std=c++14 for application build
2022-07-25 12:33:00 +02:00
yingzhang
4c30af3b9c Add -std=c++14 for application build 2022-07-25 18:27:19 +08:00
Arnout Engelen
93604685f4 Merge pull request #234 from qouoq/main
Additional useful capabilities
2022-07-11 09:11:58 +02:00
Elie Huvier
a9258d10f4 Additional capabilities required
Specify additional capabilities in main.cpp (error message and comment),
and in man page.
2022-07-10 05:26:51 +08:00
Arnout Engelen
90fb48d109 Merge pull request #233 from qouoq/main
Capabilities for reading process names
2022-07-07 08:48:28 +02:00
qouoq
a2b7881dbe Capabilities for reading process names
Adding cap_dac_read_search and cap_sys_ptrace to the setcap command, which allows non-root nethogs to display process names.
See https://stackoverflow.com/questions/41631927/read-proc-pid-fd-fd-without-full-root-access/47982314 and raboof/nethogs#142
2022-07-07 06:35:06 +08:00
Arnout Engelen
8a468d829c Merge pull request #231 from zevweiss/hide-cursor
Hide cursor during initialization and restore at exit
2022-06-21 11:56:41 +02:00
Zev Weiss
79ccaf8e97 Hide cursor during initialization and restore at exit
Showing the cursor while running (especially on terminals where it
blinks) is a bit visually distracting, and doesn't serve much purpose;
make it invisible in init_ui() and restore the original state in
exit_ui().
2022-06-21 02:37:17 -07:00
Arnout Engelen
517978bc40 Merge pull request #228 from msbit/app-std-c++14
Add `-std=c++14` for application build
2022-06-16 09:40:52 +02:00
Tom Sullivan
7efef02370 Add -std=c++14 for application build
To address:

  https://github.com/raboof/nethogs/issues/225

add the `-std=c++14` flag when building the application.

This then compiles properly with the Apple version of the Clang
compiler:

  Apple clang version 11.0.0 (clang-1100.0.33.17)

Additionally, this removed some warning noise regarding C++11
extensions used without the appropriate `-std=c++11` (or greater)
flag:

  ./process.h:38:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
  connection.cpp:107:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  connection.cpp:108:8: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  connection.cpp:162:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  connection.cpp:187:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
2022-06-16 13:49:16 +10:00
Arnout Engelen
918642f98c Merge pull request #224 from molysgaard/python-compile-fixes-ubuntu-20-04
Fix that on ubuntu 20.04, the current version of the code does not compile as a python package
2022-04-25 10:27:41 +02:00
Morten Olsen Lysgaard
2f651410c3 Fix that on ubuntu 20.04, the current version of the code does not compile as a python package
Steps to reproduce:

```
  # install required packages
  apt-get install build-essential libncurses5-dev libpcap-dev pybind11-dev

  # create working directory
  mkdir nethogs-py
  cd nethogs-py

  # create virtualenv
  virtualenv -p python3 venv

  # activate virtualenv
  source venv/bin/activate

  # create requirements.txt file for pip
  echo "git+https://github.com/raboof/nethogs.git" > requirements.txt

  # build nethogs using pip
  pip install -r requirements.txt
```

The last step gives the following compile error on my Ubuntu 20.04
machine:

```
Processing ./nethogs
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: nethogs
  Building wheel for nethogs (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/lysgaard/work/nethogs-py/venv/bin/python /tmp/tmpbzq5d0ej build_wheel /tmp/tmpxbnq_o9a
       cwd: /tmp/pip-req-build-uxzyh5t6
  Complete output (50 lines):
  running bdist_wheel
  running build
  running build_ext
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/lysgaard/work/nethogs-py/venv/include -I/usr/include/python3.8 -c flagcheck.cpp -o flagcheck.o -std=c++17
  building 'nethogs' extension
  creating build
  creating build/temp.linux-x86_64-cpython-38
  creating build/temp.linux-x86_64-cpython-38/python
  creating build/temp.linux-x86_64-cpython-38/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/ -I/tmp/pip-build-env-kvg6xf6h/overlay/lib/python3.8/site-packages/pybind11/include -I/home/lysgaard/work/nethogs-py/venv/include -I/usr/include/python3.8 -c python/bindings.cpp -o build/temp.linux-x86_64-cpython-38/python/bindings.o -std=c++17 -fvisibility=hidden -g0 -Wall -Wextra -Wno-missing-field-initializers --std=c++0x -O3 -fPIC -DVERSION=\"0.8.7\"
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/ -I/tmp/pip-build-env-kvg6xf6h/overlay/lib/python3.8/site-packages/pybind11/include -I/home/lysgaard/work/nethogs-py/venv/include -I/usr/include/python3.8 -c src/connection.cpp -o build/temp.linux-x86_64-cpython-38/src/connection.o -std=c++17 -fvisibility=hidden -g0 -Wall -Wextra -Wno-missing-field-initializers --std=c++0x -O3 -fPIC -DVERSION=\"0.8.7\"
  src/connection.cpp: In function ‘Connection* findConnectionWithMatchingSource(Packet*, short int)’:
  src/connection.cpp:162:37: error: no matching function for call to ‘std::multiset<Connection*, ConnectionComparator>::lower_bound(Packet*)’
    162 |   auto it = connList->lower_bound(&p);
        |                                     ^
  In file included from /usr/include/c++/9/set:62,
                   from src/process.h:29,
                   from src/connection.cpp:34:
  /usr/include/c++/9/bits/stl_multiset.h:810:7: note: candidate: ‘std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = Connection*; _Compare = ConnectionComparator; _Alloc = std::allocator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::key_type = Connection*]’
    810 |       lower_bound(const key_type& __x)
        |       ^~~~~~~~~~~
  /usr/include/c++/9/bits/stl_multiset.h:810:35: note:   no known conversion for argument 1 from ‘Packet*’ to ‘Connection* const&’
    810 |       lower_bound(const key_type& __x)
        |                   ~~~~~~~~~~~~~~~~^~~
  /usr/include/c++/9/bits/stl_multiset.h:814:7: note: candidate: ‘std::multiset<_Key, _Compare, _Alloc>::const_iterator std::multiset<_Key, _Compare, _Alloc>::lower_bound(const key_type&) const [with _Key = Connection*; _Compare = ConnectionComparator; _Alloc = std::allocator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::key_type = Connection*]’
    814 |       lower_bound(const key_type& __x) const
        |       ^~~~~~~~~~~
  /usr/include/c++/9/bits/stl_multiset.h:814:35: note:   no known conversion for argument 1 from ‘Packet*’ to ‘Connection* const&’
    814 |       lower_bound(const key_type& __x) const
        |                   ~~~~~~~~~~~~~~~~^~~
  src/connection.cpp: In function ‘Connection* findConnectionWithMatchingRefpacketOrSource(Packet*, short int)’:
  src/connection.cpp:187:41: error: no matching function for call to ‘std::multiset<Connection*, ConnectionComparator>::lower_bound(Packet*&)’
    187 |   auto it = connList->lower_bound(packet);
        |                                         ^
  In file included from /usr/include/c++/9/set:62,
                   from src/process.h:29,
                   from src/connection.cpp:34:
  /usr/include/c++/9/bits/stl_multiset.h:810:7: note: candidate: ‘std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = Connection*; _Compare = ConnectionComparator; _Alloc = std::allocator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::key_type = Connection*]’
    810 |       lower_bound(const key_type& __x)
        |       ^~~~~~~~~~~
  /usr/include/c++/9/bits/stl_multiset.h:810:35: note:   no known conversion for argument 1 from ‘Packet*’ to ‘Connection* const&’
    810 |       lower_bound(const key_type& __x)
        |                   ~~~~~~~~~~~~~~~~^~~
  /usr/include/c++/9/bits/stl_multiset.h:814:7: note: candidate: ‘std::multiset<_Key, _Compare, _Alloc>::const_iterator std::multiset<_Key, _Compare, _Alloc>::lower_bound(const key_type&) const [with _Key = Connection*; _Compare = ConnectionComparator; _Alloc = std::allocator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<Connection*>; std::multiset<_Key, _Compare, _Alloc>::key_type = Connection*]’
    814 |       lower_bound(const key_type& __x) const
        |       ^~~~~~~~~~~
  /usr/include/c++/9/bits/stl_multiset.h:814:35: note:   no known conversion for argument 1 from ‘Packet*’ to ‘Connection* const&’
    814 |       lower_bound(const key_type& __x) const
        |                   ~~~~~~~~~~~~~~~~^~~
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for nethogs
Failed to build nethogs
ERROR: Could not build wheels for nethogs which use PEP 517 and cannot be installed directly

```

I have tracked this down to that the `setup.py` file uses the wrong
C++-standard-flag.

This is corrected in this commit.

I have also reduced the optimization level from 3 to 2.
The rationale is that optimization level 3 contains
optimazitions that potentially change the behaviour of code, eg.
floating point behaviour. General convention is that optimization level
2 is more than sufficient unless you are working with extremely tight
budget, eg linear algebra kernels or similar. If optimization level 3
is still wanted, I can revert this.
2022-04-25 10:19:57 +02:00
Arnout Engelen
ea161b0509 Merge pull request #223 from CyberShadow/pull-20220323-015738
Improve performance with many connections
2022-04-04 16:27:44 +02:00
Vladimir Panteleev
92fb73116a Replace ConnList linked list with multiset
Keeping a sorted multi-set allows faster search by source /
source+destination address.

Fixes O(n^2) complexity when handling a lot of connections (now it's
O(n log n)).
2022-03-23 17:28:09 +00:00
Vladimir Panteleev
f46954525d packet: Fix matchSource not checking address family 2022-03-23 01:57:45 +00:00
Arnout Engelen
a663b3a157 Merge pull request #222 from AuraVisionLabs/main
Add python bindings
2022-03-17 14:15:18 +01:00
Jaime Lomeli
f4f85997b1 add include dirs 2022-03-17 13:11:41 +00:00
Jaime Lomeli-R
6be888892e Update README.md 2022-03-17 13:09:18 +00:00
jimmylomro
fcacd7efdb added nethogsmonitor_loop_devices and moved code to python dir 2022-03-16 18:58:28 +00:00
jimmylomro
257b576221 add python bindings 2022-03-15 21:35:11 +00:00
Arnout Engelen
358f445d9e Merge pull request #218 from sgtcortez/feat-process-filter
Add process filter
2022-03-02 14:11:58 +01:00
Matheus Rambo
cabc2a1ea3 feat: Filter by process #217
It is possible to filter by process id!
Add the -P <pid> flag.
Example: `nethogs -P 123 -P 333` to filter the processes: 123 and 333
2022-02-28 21:00:11 -03:00
Arnout Engelen
ca8fa246be Merge pull request #221 from schuellerf/main
Use "--tags" parameter to get the correct git-tag
2022-01-31 15:15:18 +01:00
Florian Schüller
99494bf2d1 Use "--tags" parameter to get the correct git-tag 2022-01-31 14:10:50 +01:00
Arnout Engelen
2acedff5d7 Merge pull request #216 from sgtcortez/feat-add-basename-support
feat: Add basename support #155
2021-12-22 14:41:39 +01:00
Matheus Rambo
b94cd9f227 feat: Add basename support
Now, the user can decide to show only the program name, instead of the
full program path. It is useful, when you have a very long hierarchy of
directories, which, with the full path name, the user might not see the
program name.
2021-12-22 10:01:00 -03:00
Matheus Rambo
82a30bb644 refactor: Change bughunt mode to 'x' 2021-12-22 09:58:45 -03:00
Arnout Engelen
54f88038f6 Merge pull request #215 from ncfavier/capability-check
Disable capability check, handle failure better
2021-12-02 14:14:32 +01:00
Naïm Favier
afb5759cc3 Disable capability check, handle failure better
Fixes #214
2021-12-02 14:04:08 +01:00
Arnout Engelen
3e0bba6966 Merge pull request #213 from chenjiandongx/add-links
Add bandwhich and sniffer links
2021-11-21 14:16:36 +01:00
chenjiandongx
1ebf118409 Correct fomrat 2021-11-21 21:05:38 +08:00
chenjiandongx
5bbdb7de86 Add bandwhich and sniffer links 2021-11-21 21:03:47 +08:00
Arnout Engelen
ff3d8c64d1 Merge pull request #212 from unknown-spirit/patch-1
Added BusyTasks link to the list
2021-10-31 15:49:13 +01:00