Mcat12
0543f2c174
Don't hold a reference to shared memory across locks in resolve.c
...
Fixes #567
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2019-05-21 17:31:40 -07:00
DL6ER
93d17a332a
Merge branch 'development' into tweak/remove_global_objects
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-16 18:04:40 +02:00
Mark Drobnak
271150b07f
Merge pull request #550 from pi-hole/tweak/static_analysis
...
Static code analysis improvements
2019-04-15 23:28:59 -04:00
DL6ER
6fcbce6c34
Improve code based on a full static analysis of our code. There are no real bugs, nowever, we use the obtained knowledge to improve the code such as unify declarations and function definitions, reduce the scope of local variables, mark many function arguments and local variables const when they are, fix the type expected by %x and fix one if-condition
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-15 22:35:14 +02:00
DL6ER
7a5eb9d715
Simplify code further. This removes the if statements at the end of the client/forward loops
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 21:35:57 +02:00
DL6ER
cfa9120ccc
Use newflag instead of .new booleans to avoid needing a further lock
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 21:22:24 +02:00
DL6ER
b29b9abb49
Also lock access to the counters and combine locks where convenient
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 21:19:03 +02:00
DL6ER
9c0da2f209
Wrap all access to the forwarded and clients structures in locks. This is sometimes a bit cumbersome, however, it is necessary as we cannot completely lock the routines because this would prevent DNS resolution from being able to work
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 21:10:24 +02:00
DL6ER
cc88ed765a
Lock more than less
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 21:00:52 +02:00
DL6ER
89957271ea
Newname can be freed without if as we check for NULL already one level higher
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 20:56:24 +02:00
DL6ER
3ab4076738
Lock SHM when using getstr() and addstr()
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-14 14:14:32 +02:00
DL6ER
9c4c9d701f
Move global constants RESOLVE_INTERVAL and RERESOLVE_INTERVAL to FTL.h
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-12 16:23:50 +02:00
DL6ER
8e67784b81
Swap out common code in resolve.c into its own subroutine
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-12 16:17:34 +02:00
DL6ER
cc0b3782f1
Review comments 1
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-10 16:49:16 +02:00
DL6ER
e24360517f
Align debugging output to the output produced by addstr()
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-05 09:35:33 +02:00
DL6ER
540dba6a53
Make sure we release allocated memory once we don't need it any longer
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-05 09:31:38 +02:00
DL6ER
4184141557
Add debug output
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-05 09:28:54 +02:00
DL6ER
a9dc5564aa
Only store hostnames of domains and upstream servers if they have changed. Currently, we are storing their host names each time we reresolve the IP addresses, even if they have been found to be identical. This allows us to save memory in FTL processes that are running for a long time without being restarted.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-04-05 09:26:04 +02:00
DL6ER
36fee76052
Merge branch 'development' into tweak/remove_global_objects
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-14 21:39:58 +01:00
DL6ER
0d6f424f1f
Enforce prototyping. This ensures that function that are not explicitly made globally available across files (through an explicit prototype in a header file) need to be marked static such that their scope is limited to where they are actually used. This also enforces strict prototyping, i.e., a function with zero arguments needs to be written explicitly as function(void) as a non-strict prototype such as function() would in fact allow an arbitrary amount of parameters.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-10 15:31:14 +01:00
DL6ER
8c11628e71
Skip magic byte validation when we're just about to create the entry for the first time (magic byte hasn't ben initialized yet)
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-06 18:53:33 +01:00
DL6ER
0b5d6c3eae
Shorten name of structs. This is only of cosmetic nature and does not change any functionality in the code.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-06 17:47:34 +01:00
DL6ER
dd2ae55811
Remove globally defined forwarded array.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-06 17:30:44 +01:00
DL6ER
6466a69da4
Remove globally defined clients array.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-06 16:52:20 +01:00
DL6ER
68d9036c9e
Ensure that lock is released when resolving host names. This is necessary as we'd otherwise block the main thread which is actually supposed to do the resolving.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-12-25 13:57:45 +01:00
Mcat12
befc0f81fe
Fix reference to old lock functions
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-11-21 15:04:52 -05:00
DL6ER
85290bb73e
Merge branch 'development' into new/shmem
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-11-21 20:44:37 +01:00
DL6ER
9f860376b1
Change logic of onlynew variable: If onlynew is set and an item is NOT new, we skip this one. In all other cases, we try to resolve.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-27 21:08:48 +02:00
DL6ER
e6157da42e
Also re-resolve upstream host names every hour
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-27 21:06:06 +02:00
DL6ER
fd53505d97
Rename routines/variables to reflect "DNS client"
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-27 20:54:45 +02:00
DL6ER
1a3a595e26
Use "DNS client" as custom thread name for the new name resolving thread
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-27 19:29:25 +02:00
DL6ER
513566328d
Call to ">reresolve" also re-resolves host names of all known forward destinations
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-26 20:17:37 +02:00
DL6ER
f10b49cd69
Remove obsolete debug output
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-25 19:56:39 +02:00
DL6ER
f2f3566980
Move resolution of client and upstream host names to a dedicated thread. Fixes #404
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-10-25 19:53:29 +02:00
Mcat12
3d439adcaf
Merge remote-tracking branch 'origin/development' into new/shmem
...
# Conflicts:
# dnsmasq_interface.c
# resolve.c
2018-09-17 11:54:49 -04:00
Mcat12
ae1bb5b71a
Move counters to shared memory
...
This requires that it be accessed through a pointer, so most of the
changes are just changing `counters.` to `counters->`
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-09-03 14:25:16 -04:00
Mcat12
c9e468b850
Don't forget to reset "new" flag on client struct when name is resolved
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-09-03 01:09:48 -04:00
DL6ER
b7da12b600
Use strbuffer also for client IPs and host names
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-08-01 18:37:48 +02:00
DL6ER
3e8849049e
Store forward destination IP address and host name in contiguous string buffer
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-08-01 18:04:43 +02:00
DL6ER
81f72c3d11
Provacy mode: Actually return host name "hidden" instead of trying to resolve 0.0.0.0
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-04-12 11:01:16 +02:00
DL6ER
e2d0529993
Implement name resolving power back for FTLDNS. This re-implements lots of already extensively tested code that was present in pre-FTLDNS for over a year. This implementation is only slightly different by ensuring that name resolution is done in a specific non-blocking way.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-04-11 18:20:06 +02:00