1301 Commits

Author SHA1 Message Date
Stephan de Wit
329d94de23 Unbound: Logger: remove unused argument 2023-01-10 10:02:37 +01:00
Stephan de Wit
8a1215aeee Reporting: Unbound DNS: include resolved hostnames in detailed grid as well 2023-01-09 12:42:21 +01:00
Franco Fichtner
a6c4113508 system: syslog.LOG_DEAMON is a facility
Might have unintentional side effecs but bitmask use with wrong
numeric value is dangerous as well.

See: https://docs.python.org/3/library/syslog.html
2023-01-09 12:22:45 +01:00
Stephan de Wit
0c0380295a Unbound: redirect logger errors to syslog 2023-01-09 12:17:05 +01:00
Stephan de Wit
0d9c4fa625 Unbound: use daemon -f instead of nohup 2023-01-09 11:57:02 +01:00
Stephan de Wit
78e575b53f Unbound: catch socket.herror as well, make sure to catch bidirectional changes
in reverse DNS results
2023-01-09 11:44:07 +01:00
Stephan de Wit
5a3765a0c1 Reporting: Unbound DNS: resolve hostnames for clients 2023-01-09 11:12:13 +01:00
Stephan de Wit
0474d2558f unbound: nohup and background logger instead of daemonizing it 2023-01-09 11:08:26 +01:00
Franco Fichtner
7a6a102913 ipsec: fix permission 2023-01-06 15:04:01 +01:00
Stephan de Wit
4a5406424f Reporting: Unbound DNS: Tweak UI and usability improvements
- Increase the reporting interval for 12 & 24 hours to 10 minutes.
- Always display a list for the top (blocked) domains
- Remove block/whitelist buttons when blocklists are disabled
2023-01-03 13:47:37 +01:00
Ad Schellevis
720ffdc561 Interfaces: Diagnostics: Packet Capture - support mac addresses in "Host Address" field. closes https://github.com/opnsense/core/issues/6159 2023-01-02 17:46:38 +01:00
Stephan de Wit
e5d6acd2eb
Unbound / Blocklists: add exact domain blocking and integrate into overview page (#6205)
This include the ability to whitelist it from the same page as well. Relevant to both
the top passed/blocked domains, as well as the detailed query grid.

blocklists.py has been modified in such a way that it will detect whether it needs to
start the download process or simply administrate locally. The latter currently only happens
when custom domains for blocking have been added/removed by a user. The reasoning is
that we can easily extend/shrink the current blocklist when it comes to blocking exact
domains as this is handled on the incoming side. However, while we can modify the current
list to accomodate a new whitelist entry (which can be regex), we (currently) cannot know which domains
were skipped in the process of retrieving them in the first place if a user explicitly removes
a whitelist entry. Therefore we decide to re-run the download on a whitelist action.

furthermore, the updateBlocklistAction in the controller administrates how the model is updated
(e.g. when a blocked item is whitelisted, it should be removed from the blocklist model entry and
added to the whitelist)

In the future we could optimize the whole process by checking if a remote file has changed in
date or size.
2023-01-02 14:06:53 +01:00
Ad Schellevis
7723ccaf86 VPN/IPsec - send up/down events to charon syslog 2022-12-29 10:10:29 +01:00
Ad Schellevis
67f220c4d0 VPN/IPsec - regression in previous commit (event handler, detection of automatic rules) 2022-12-29 08:55:06 +01:00
Ad Schellevis
759dd48aed VPN/IPsec - add event handler for manual spd entries if reqid is set. 2022-12-28 22:09:46 +01:00
Ad Schellevis
58759bd1ab shaper - minor coverity fixes:
1527330 Bad use of null-like value in __init__.py
1527326 Bad use of null-like value in __init__.py
1527315 Bad use of null-like value in __init__.py
2022-12-23 14:29:55 +01:00
kulikov-a
360d4a45e5
unbound: catch exception on blocklist reading (#6035) 2022-12-21 14:15:18 +01:00
Ad Schellevis
6f46fe3080 System/Log Files - add "Service Log (this boot)" including parser as an option to provide access to entries collected in https://github.com/opnsense/core/issues/6099 (proposal for 23.1) 2022-12-19 10:08:44 +01:00
kulikov-a
bee24edaea
change working dir before check (#6197) 2022-12-17 18:14:19 +01:00
Stephan de Wit
5e1e03df35 unbound / overview: add support for TTLs 2022-12-16 15:18:38 +01:00
Franco Fichtner
b8e9bde8f8 interfaes: add -backhole to prefix route #3304 2022-12-16 12:53:31 +01:00
Stephan de Wit
a4ae646327
unbound / overview: migrate to duckdb (#6182)
* unbound / overview: migrate to duckdb

* unbound: make ajax calls concurrent, no need to wait on each other

* unbound / overview: adjust to DataFrame optimization

While previous insert statements with SQLite had to be rate limited to prevent blocking on the
side of the logger, this limitation can be ditched entirely with the approach of appending DataFrames.

Also, the client chart expects timestamps for the entirety of the dataset, so make use of
the NaN value.

* unbound / overview: connection can be none

* unbound / overview: include DNSSEC and timing information and refactor logger

The logger was lacking some error handling due to it being daemonized. On a restart the process
will still produce a core dump likely associated with daemonization, but this will be addressed in a separate issue

To accomodate future additions, DNSSEC and RTT information is now also included in the data set.

* remove leftover syslog message

* unbound / overview: add UUID as well

* unbound / overview: account for null return_msg objects

* unbound / overview: Move DNS statistics to reporting->dns, add detailed grid

This also introduces the option to clear the DNS data. Also restructure the data to a more sensible flow representation.
2022-12-15 10:45:16 +01:00
Ad Schellevis
cf840140d8 Firewall: Diagnostics: States - re-add labels removed by https://github.com/opnsense/core/commit/63eeaffe21f7 2022-12-13 11:36:18 +01:00
Ad Schellevis
5752bd6eb3
VPN/IPsec add new MVC module (#6187)
Add new component to manage IPsec connections in a similar format as `swanctl.conf` is defined (https://docs.strongswan.org/docs/5.9/swanctl/swanctlConf.html).  As this needs to work in conjunction with the legacy IPsec module, some minor changes are needed to the current state. 

o VPN/IPsec/Pre-Shared Keys - add optional remote identifier (merges in `ipsec.inc`)
o VPN/IPsec/Virtual Tunnel Interfaces - new component to show existing VTI's and add new ones (as these are separate entities)
o VPN/IPsec/Connections [new] - configuration tool to build `swanctl.conf` 
o Integrate MVC generated `swanctl.conf` into `ipsec.inc` (legacy overlays)
o Integrate manually configured VTI's into `ipsec.inc` (`array_merge(ipsec_get_configured_vtis(), (new \OPNsense\IPsec\Swanctl())->getVtiDevices())`)
o fix minor php warning when changing reqid's (`$local|remote_configured` initialisation when `$configured_intf[$intf]` not found)
2022-12-12 10:37:43 +01:00
Ad Schellevis
63eeaffe21 Firewall: Diagnostics: States - Performance improvements and better address parsing in search.
As the output of pfctl -vvss can grow quite rapidly, it seemed like a good idea to run this code through a profiler. Some of the hotspots (like parsing addresses) are now cached in memory to prevent over enthusiastic computation, which can save quite some processing time. Pushing down the string join on which the pattern search should match does help prevent to prevent compiling a search string which turns out to be irrelevant later (no filter or ip[+port] filter).

The network (address) search handles (optional) ports as well now, which allows for patterns like `10.0.0.1:80` and `10.0.0.0/24:80`.
2022-12-07 09:40:48 +01:00
Ad Schellevis
f5cd86b61d Filter / Diagnostics - performance improvement when fetching rule labels.
Since rule labels are directly hooked to the modification time of /tmp/rules.debug, we don't have to recalculate the offsets on every request. This patch saves the labels and the last modification time so we can refresh when changed or non-existent.
2022-12-05 18:41:43 +01:00
Ad Schellevis
ae8e0ce4a4 syslog/lockout handler - better trap ssh messages and improve lockout behaviour.
As the client still might have a state when being kicked-out, we should kill any state the client has while adding it to the alias. Apparantly our ssh messages are only catched partially, so add ".*Authentication error for .*" to the list as well. To ease testing, better detect the location of the timestamp so we can use a construction like this to feed amn existing log:

lockout_handler < /var/log/audit/audit_20221205.log
2022-12-05 14:52:16 +01:00
Ad Schellevis
13ea70af04 unbound: change working directory before check. closes https://github.com/opnsense/core/issues/6171 2022-12-05 11:42:53 +01:00
kulikov-a
623b2643e6
unbound: typo (#6168) 2022-12-05 08:42:38 +01:00
Stephan de Wit
53dd65709a
unbound: add client activity chart (#6161)
* unbound / overview: add client activity chart, include logarithmic scale on both charts

* unbound: remove tooltip from workaround datapoints

* unbound / overview: also end the x axis properly on log scale

* unbound / overview: prevent queries on non-existing database

* unbound / overview: replace cache hits with blocklist size and update icons

* unbound / overview: refactor rolling API call
2022-12-02 10:57:20 +01:00
Franco Fichtner
a68700be02 src: style sweep 2022-11-25 12:57:45 +01:00
Stephan de Wit
b20ddbe00f
unbound: add overview dashboard (#6101)
Adds a reporting backend for Unbound as well as a dashboard showing an overview of interesting statistics:

    Total DNS queries (over a maximum period of 7 days)
    Blocked queries
    Cache hits
    local-data hits
    A traffic graph with variable intervals
    top N passed/blocked domains (with associated blocklist)

There are a couple of hardcoded values:

    The underlying database is kept up-to-date for the last 7 days.
    The ring buffer used to decouple unbound from the logging backend has a size of 100000 entries.
    In very busy networks, db commits are done for a max of 4000 entries, which according to testing seems to be a good break-even point for DNS throughput vs. insert performance. Everything below this is flushed to the database every 5 seconds.
    To facilitate the variable interval traffic graph, multiple views with varying detail in time slots are created: 1, 5 and 30 minute buckets. These can easily be extended should different intervals be necessary.
2022-11-25 11:42:38 +01:00
Franco Fichtner
fe21864884 health: clean up scripts/systemheath location #5877
Unfortunately this requires relocating the logging plugins to its
proper location which also affects plugins using that location.
2022-11-04 09:45:10 +01:00
Franco Fichtner
4edf223b2f src: style sweep 2022-11-01 08:50:03 +01:00
Ad Schellevis
f573082418
Virtual IP MVC/API conversion (#6105) (#6109)
Refactor status page, replace menu registration and add ACL
2022-10-29 14:22:45 +02:00
Franco Fichtner
0964483780 src: style sweep 2022-10-26 20:32:20 +02:00
Ad Schellevis
7d4597efe5
Virtual IP MVC/API conversion (#6105)
closes #5984 refactors legacy pages, includes the following:

o remove type field as this seems to be redundant and confusing
o input form additions (show hide related fields)
o add button for carp type to select first unused vhid
o implement configure action, caching removed addresses in /tmp/delete_vip_{$uuid}.todo files (by the controller)
o add mode filter to search action and complete with relevant fields for our grid
o fix warning in interfaces.inc (interface_proxyarp_configure()), array creation issue
o add validation for addresses used in port forwards and outbound nat rules. previous version tried to rename forwards, we choose to be consistent when it comes to edit/delete.
o change ACL to use the new endpoints, remove "show only" ACL. we can always consider putting it back later, but the experience of only able to reach the grid likely won't be practical.
o remove old firewall_virtual_ip*.php files
2022-10-26 16:42:46 +02:00
Franco Fichtner
607faca9ba firmware: in retrospect always fetch the signature file
When we move to the next major the file contents for
the txz are all the same but their signature is not.
So until the next changelog sync was carried out the
CHECKSUM matched and the signature will stay stale.
2022-10-26 12:53:38 +02:00
Franco Fichtner
5c65f49bce firmware: use effective ABI in changelog fetch 2022-10-26 12:48:06 +02:00
Franco Fichtner
2a15defa74 firmware: filename not prefix 2022-10-25 10:02:23 +02:00
Franco Fichtner
6f7aeba069 firmware: also ignore core.license 2022-10-25 09:59:00 +02:00
Franco Fichtner
166758a2e5 firmware: ignore os-OPNBEcore plugin since dependency is automatic 2022-10-25 09:48:53 +02:00
Franco Fichtner
1388f28006 unbound: make start script never fail early 2022-10-20 09:45:53 +02:00
Ad Schellevis
c20fd9a47a Services: Unbound DNS - minor start/stop changes
o make sure we are not going to exit the start script if rm fails for whatever reason
o add stop action which stops the service and unmounts volumes mounted by start, the current state only kills unbounds primary pid (without optional dhcp integration or mountpoints)
2022-10-20 09:08:13 +02:00
Franco Fichtner
5d62b395d1 unbound: fix bail on python glue chown (read-only error) 2022-10-17 11:04:51 +02:00
Stephan de Wit
d14ffae466
unbound: rework DNSBL implementation to python module (#6083)
Replaces the current blocklist implementation to use python instead of relying on unbound-control. The latter had the drawback of a very long execution time to administrate the local-data entries both locally and in Unbound. The memory footprint was also considerably larger due to unbound internals, while the python module keeps it all in memory in a simple dictionary - reducing the total amount of memory consumption by more than a factor of 10. A drawback is a potential decrease in performance of ~15%, although most setups shouldn't be affected by this as most hardware which is capable of running this should be scaled towards its intended use.

The option of returning NXDOMAIN has also been added (fixes #6027), which in this implementation is a lot easier than what we would have to do if local-data were to be used.
2022-10-14 17:02:23 +02:00
Franco Fichtner
8d50193182 firmware: remove faulty changelog to force a clean refetch 2022-10-12 10:01:45 +02:00
Ad Schellevis
0adf843ff6
VPN / IPsec - migrate ipsec.conf to swanctl.conf (#6076)
* VPN/IPsec - work in progress refactoring ipsec.conf to swanctl.conf for https://github.com/opnsense/core/issues/5636

Wrap the following blocks in functions:

o generation of strongswan.conf
o write and cleanup IPsec's CA database
o write certificates used by IPsec
o write RSA Key Pairs
o construct ipsec.secrets for swanctl, combining different sources, phase1 PSK's, certificates, keypairs
o replace VPN: IPsec: Lease Status with new mvc version that uses swanctl underneath

Remap ipsec.conf to swanctl.conf attributes using https://wiki.strongswan.org/projects/strongswan/wiki/Fromipsecconf

Remove lifetime defaults from phase 1 and 2 so new connections will use Strongswan's defaults and move the option in phase above Margintime/Rekeyfuzz as these combined are being migrated (see margintime in Fromipsecconf doc).

Restructure used path directives so we can use the default structure as descried in https://docs.strongswan.org/docs/5.9/swanctl/swanctlDir.html and installed via ports.

IPsec status overview needs a small fix as well (passthrough network seems to be returned by vici, but doesn't contain a class (which crashes list_status.py).)

While here, also remove some php warnings.
2022-10-10 19:52:36 +02:00
Ad Schellevis
385d182798 Firewall: Aliases - support Maxmind's unclassified EU (region, country unknown) as country selector EU
6255148,en,EU,Europe,,,0

Although the same applies for Asia, we can't use AS as country code here, so we do have to skip this for now until we find a better alternative.

6255147,en,AS,Asia,,,0

closes https://github.com/opnsense/core/issues/6063
2022-10-10 18:24:32 +02:00
Franco Fichtner
26ccc7839f system: remove _defaultgw(v6) file handling; closes #5900
Try to avoid touching default routes in dhclient-script which we
already partially do now.  PPPoE linkdown certainly doesn't need
to handle the file as well to remove the default route then.
2022-10-06 09:29:12 +02:00