Commit Graph

387 Commits

Author SHA1 Message Date
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
unknown-spirit
040556d6a2 Added BusyTasks link to the list 2021-10-27 15:47:14 +02:00
Arnout Engelen
168d342a54 Merge pull request #210 from kretcheu/patch-1
Fix compilation error with [-Werror=format-security]
2021-10-11 10:33:56 +02:00
kretcheu
455daf357d Fix compilation error with [-Werror=format-security]
When compiling with [-Werror=format-security] in Debian packaging occurs this error:
```
cui.cpp: In function ‘void show_ncurses(Line**, int)’:                                          
cui.cpp:377:73: error: format not a string literal and no format arguments [-Werror=format-security]
  377 |   mvprintw(3 + 1 + i, cols - COLUMN_WIDTH_UNIT, desc_view_mode[viewMode]);              
      |                                                                         ^               
cui.cpp:379:29: warning: zero-length gnu_printf format string [-Wformat-zero-length]            
  379 |   mvprintw(totalrow + 1, 0, "");                                                        
      |                             ^~      
```

This patch solve the problem.

[]'s
kretcheu
2021-10-09 16:37:10 -03:00
Arnout Engelen
06fdccb419 Merge pull request #203 from takeoverjp/feature-garbage-collect-inodeproc
Issue: #96 - Garbage collect inodeproc on each ui refresh.
2021-02-17 15:26:49 +01:00
Kondo Takeo
8b2c55c3f3 Fix log message. 2021-02-17 23:13:50 +09:00
Kondo Takeo
b97fb4cfdf Issue: #96 - Garbage collect inodeproc once every 50 ui refresh as default.
- Reduce default frequency to avoid performance issue.
- The frequency of it can be modified with `-g` option
  and can be disabled with `-g 0`.
2021-02-17 23:02:27 +09:00
takeoverjp
12dbf5e28a Update src/inode2prog.cpp
Co-authored-by: Arnout Engelen <arnout@engelen.eu>
2021-02-17 22:31:21 +09:00
Kondo Takeo
0a54596bc6 Issue: #96 - Garbage collect inodeproc on each ui refresh. 2021-02-16 22:42:47 +09:00
Arnout Engelen
fefe0f0714 Merge pull request #202 from takeoverjp/feature-update-links
Add links to other network traffic monitoring tools.
2021-02-07 14:20:28 +01:00
Kondo Takeo
0e5f29a4ba Add links to other network traffic monitoring tools. 2021-02-07 20:37:52 +09:00
Arnout Engelen
8da07022e4 Merge pull request #201 from takeoverjp/fetaure-add-screenshot
Issue: #102 - Show screenshot in README.
2021-02-06 17:20:36 +01:00
Kondo Takeo
b5285a5bff Issue: #102 - Show screenshot in README. 2021-02-06 22:44:27 +09:00
Arnout Engelen
b482f04097 Merge pull request #200 from takeoverjp/feature-man-catchup
Update man page with the latest help message.
2021-02-06 10:15:45 +01:00
Kondo Takeo
975e11eddf Update man page with the latest help message. 2021-02-05 22:40:08 +09:00
Kondo Takeo
a4d2e550cb Fix typo in help message. 2021-02-05 22:39:01 +09:00
Arnout Engelen
7a0d9c0d41 Merge pull request #199 from takeoverjp/feature-udp-support
Issue: #62 - UDP support
2021-02-05 10:36:59 +01:00
Kondo Takeo
b7a42786bd Issue: #62 - Fix conninode_test. 2021-02-05 00:12:21 +09:00
Kondo Takeo
18629a3b33 Issue: #62 - Treat unlisted traffic as 'unknown UDP/TCP' 2021-02-04 23:43:29 +09:00
Kondo Takeo
ccda1b50c4 Issue: #62 - Parse udp proc only when catchall mode. 2021-02-04 23:35:52 +09:00
Kondo Takeo
e024d3eb33 Issue: #62 - UDP support 2021-02-04 00:31:40 +09:00
Arnout Engelen
d4f3b22140 Merge pull request #198 from kishorkunal-raj/main
Adding ppc64le architecture support on travis-ci
2020-12-11 19:09:06 +01:00
kishor kunal raj
259cfccffd Adding ppc64le architecture support on travis-ci 2020-12-11 12:58:08 +00:00
Arnout Engelen
cb0213fcf3 Merge tag 'v0.8.6' into main 2020-09-04 11:16:49 +02:00
Arnout Engelen
55f5abaaee accept sponsorships 2020-08-31 12:20:20 +02:00