Commit graph

30 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
fdba19c0c3
structs fields reorganized
Structs' fields reorganized based on fieldalignment tool feedback.
2024-01-13 22:15:23 +01:00
Gustavo Iñiguez Goia
24fd94c168 netfilter: do not unbind the queues on exit
On exit we were calling nfq_unbind_pf for AF_INET and AF_INET6, which
usually stcuked the daemon for a very long time, and other times
caused a segfault.

According to the docs (..), calling nfq_destroy_queue() is enough to
exit cleanly:
"This call also unbind from the nfqueue handler, so you don't have to
call nfq_unbind_pf."
https://netfilter.org/projects/libnetfilter_queue/doxygen/html/group__Queue.html#ga32a1461e9a36c95a03cb4476109f33bb

Closes #919

(cherry picked from commit 430c280687)
2024-01-08 15:55:58 +01:00
Gustavo Iñiguez Goia
cb4d82f9ac
respect packet mark when requeueing packet 2023-07-23 22:33:08 +02:00
Gustavo Iñiguez Goia
19890062ff
added more logs for better issues debugging
- Log packet mark, which may help debugging VPN connections for example.
- Log the nfqueue number when we fail to setup the queue.
  * Suggest to restart the computer on one particular case (#912).
2023-04-21 23:28:13 +02:00
Gustavo Iñiguez Goia
274a3483d7
improvements to ui, ebpf, netfilter
- Fixed firewall dialog label alignment.
 - Fixed potential race condition when stopping the daemon, and there're
   connections being enqueued.
 - Added "clear" button to GUI's filter line (#786)
 - Create ebpf cache object only if the modules have been loaded.
 - Set default stats workers to the sme amount defined in configuration.

Closes #785
2022-12-23 14:39:49 +01:00
Gustavo Iñiguez Goia
4a0f7a3e2b
rules: allow to filter by network interface name
Now you can create rules to filter network interface name.
Regular expresions allowed: "eth[0-9]"

Closes #726
2022-09-24 17:12:09 +02:00
Gustavo Iñiguez Goia
37caf49ca3 removed unused channel
It caused sometimes panics on exit.
2022-05-23 14:52:51 +02:00
Gustavo Iñiguez Goia
0ba5fc44c9 run tests on every change, fixed fw options
- Run unit tests on every push/pr.
- Silence gcc warnings, it doesn't seem to work and causes unit tests to
  fail:
  https://github.com/golang/go/issues/6883#issuecomment-383800123
- Improved firewall configuration contraints, to meet with this table:
  https://wiki.nftables.org/wiki-nftables/index.php/Netfilter_hooks#Hooks_by_family_and_chain_type
2022-05-18 17:47:39 +02:00
cinerea0
a550252f79 daemon: allow building on musl 2022-02-18 20:36:56 -05:00
themighty1
6f6e91ac41 wait for success when sending packet to chan, don't error out after first failed attempt.
When testing this patch under a heavy load of 300 new connections per second running for 12 hours, I saw a few timeouts.
This means that there are legitimate cases when sending the packet to the channel will not go through
no matter how long we wait.
However, compared to the old behavior, the amount of dropped packets decreased by a factor of 100x.

The value of timeout is chosen to be 1 millisecond, because it feels reasonable that if after so long the packet did
not go through, it is not due to a congested channel but due to some other error which will not go away even if we wait longer.
2021-02-19 09:01:01 +03:00
luz paz
d15d3465a9 Fix random typos
Found via `codespell v2.1.dev0`  
`codespell -q 3 -L ans`
2020-12-23 13:24:59 -05:00
Gustavo Iñiguez Goia
e13015ce67 updated import paths 2020-12-09 18:18:42 +01:00
Gustavo Iñiguez Goia
df952d974e fixed errors when IPv6 is not enabled in the system
If IPv6 was not enabled we failed to add IPv6 rules.

closes #96
2020-11-26 16:25:48 +01:00
Gustavo Iñiguez Goia
b547067f61 close nfqueue descriptors gracefully
When the daemon is stopped, we need to close opened netfilter recurses.
Otherwise we can fall into a situation where we leave NFQUEUE queues
opened, which causes opensnitch to not run anymore until system restart
or a manual intervention, because there's a NFQUEUE queue already created
with the same ID.

This is what was happening as a collateral effect of #41.
2020-07-17 01:29:58 +02:00
Gustavo Iñiguez Goia
506b9b6d87 fixed daemon running with old libnetfilter_queue libs
In old libnetfilter_queue libs, we can't know the UID of the packet
because the function nfq_get_uid is not present.

We check it dynamically on run time, but we were doing it wrong, so the
daemon didn't run with old libs.

Thaks to Pain-Patate for reporting it in #18.
2020-06-14 12:01:34 +02:00
Gustavo Iñiguez Goia
b9af7c2837 fixed compiling for arm and i386 2020-04-11 00:23:27 +02:00
Gustavo Iñiguez Goia
dbb86d7df8 avoid to crash if opensnitchd is already running 2020-03-13 12:47:04 +01:00
Gustavo Iñiguez Goia
8782b77625 Allow to compile the daemon with outdated libnetfilter-queue
On Ubuntu 18.04 the libnetfilter-queue is not the latest one (1.0.3) and
it doesn't have UID/GID support.
2020-02-09 19:28:27 +01:00
Gustavo Iñiguez Goia
5d92cbb893 Load nfq_get_uid dynamically
nfq_get_uid symbol does not exist on some systems.
2019-12-05 01:48:21 +01:00
Gustavo Iñiguez Goia
65c3790106 Prompt the user to allow/deny all outgoing connections
With the current implementation, it's not possible to know what
process/pid has created an outgoing connection, but there's still
valuable information that the user may want to know, so:

- display outgoing connections even if the process name/path is unknown.
 (src ip, dst ip, dst port, uid)
- get outgoing connection uid if kernel > 3.6.
2019-10-25 00:55:32 +02:00
Jerzy Kozera
22c4aca5d0 IPv6 support 2018-11-21 22:57:43 +01:00
evilsocket
026d2fad6f
misc: small fix or general refactoring i did not bother commenting 2018-04-10 14:25:02 +02:00
evilsocket
3feeabf000
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:36:30 +02:00
evilsocket
8ff583dcbe
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:31:58 +02:00
evilsocket
7ddb8e577c
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:20:00 +02:00
evilsocket
cc7322d6ce
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:16:40 +02:00
evilsocket
e3db27dfc3
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:15:30 +02:00
evilsocket
fc97f5b431
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:06:02 +02:00
evilsocket
de1d7cd414
misc: small fix or general refactoring i did not bother commenting 2018-04-10 12:52:01 +02:00
evilsocket
7e474a0514
refactored netfilter code, implemented SetVerdictAndMark method 2018-04-08 20:13:35 +02:00