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
d653f4dd85
Declare input data for swrite() as const void*
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-10 19:44:31 +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
32be41ed5d
Declare attributes for functions in FTL. These attributes help the compiler to optimize functions calls and to check our code more carefully during compilation. See pull reqeust text for details.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-03-08 11:36:11 +01:00
DL6ER
2c41ae7b73
Offer fine grained debugging options through independentally configurable debug flags. The debugging output of FTL gre considerable over the last year and became overwhelming for users that are not used to it. With this addition, users will be able to switch on only what they want to see.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2019-01-16 09:14:35 +01:00
DL6ER
bd6c9aadd0
Move locking/unlocking to the place where the functions that need it are called. This fixes a bug where socket.c tried to release a lock that was already released in request.c. Furthermore, this prevents obtaining a lock for both, API calls that do not need a lock and also for unknown API calls.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-12-25 14:20:33 +01:00
Mcat12
d7b4ce8a5f
Remove read lock and simplify lock names
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-10-11 15:59:52 -04:00
Mcat12
8c68aac456
Add shared memory lock
...
This replaces the previous mutex managed by threads.c. The lock is
stored in shared memory with the name "/FTL-lock", and any clients
connecting to the shared memory are expected to use the lock when
accessing memory.
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-10-05 01:18:40 -04:00
DL6ER
5c38d32c60
Merge branch 'development' into ftldns/remove_old_debug_options
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
Conflicts:
args.c
2018-05-12 16:49:06 +02:00
DL6ER
d2c14b0a71
Remove unneeded variable sockID
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-05-12 13:12:26 +02:00
DL6ER
c606ad75ab
Remove undocumented, old, and unused debug commands
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-05-10 19:24:02 +02:00
DL6ER
ea3309e7b1
Initial commit for FTLDNS
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-02-22 20:21:06 +01:00
DL6ER
e75bd26994
Improve overall memory handling by checking for failed memory allocation events at the places we need the allocated space
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-02-07 13:23:54 +01:00
Mcat12
590f1f97f7
Merge remote-tracking branch 'origin/development' into new/API
...
# Conflicts:
# FTL.h
# socket.c
2018-01-21 09:48:41 -05:00
DL6ER
d12726a01b
Only listen on IPv4 and IPv6 telnet sockets if we successfully bound to the corresponding port
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-21 14:01:22 +01:00
DL6ER
df3b049ede
Remove clientips[]
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-20 21:41:12 +01:00
DL6ER
0aee819dc2
Implement some of the review comments
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-20 21:38:24 +01:00
Mcat12
232507a51e
Merge remote-tracking branch 'origin/development' into new/API
2018-01-20 11:21:36 -05:00
Mcat12
1fd7ade5fe
Add back detailed ssend error message
...
Might have been lost in a merge.
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-20 11:19:09 -05:00
DL6ER
084186af79
Add free() on an allocated buffer where I forgot it
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-16 18:32:19 +01:00
Mcat12
d3d70983ad
Merge remote-tracking branch 'origin/development' into new/API
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
# Conflicts:
# main.c
# request.c
# routines.h
# socket.c
2018-01-14 17:48:37 -05:00
DL6ER
8f38a22d8f
Merge pull request #202 from pi-hole/tweak/socket_creation
...
Create sockets in order
2018-01-14 23:14:24 +01:00
DL6ER
f709729277
Don't skip Unix socket when IPv6 is not available
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-14 20:06:43 +01:00
DL6ER
3bdf7c9844
Make sure sockets are created and bound to before continuing to launch other threads in main()
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-14 20:00:24 +01:00
Mcat12
31c422eae6
Fix checkClientLimit
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-12 17:37:44 -05:00
Mcat12
0013edb1c6
Merge remote-tracking branch 'origin/development' into new/API
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
# Conflicts:
# main.c
# request.c
# routines.h
# socket.c
2018-01-12 17:12:08 -05:00
DL6ER
d53371082f
Replace sprintf() + swrite() by the new ssend() routine. This enhancement removes the fixed buffer we used before and allows for responses having arbitraty lengths
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
Conflicts:
request.c
routines.h
2018-01-12 22:40:53 +01:00
DL6ER
5df4ea3cdd
Remove obsolete comment
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-11 23:19:02 +01:00
DL6ER
51b645a01a
Incorporate review comments
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-11 21:01:40 +01:00
DL6ER
c6b23ffa15
Complete re-write of this feature. We create now two sockets (one for IPv4-only and one for IPv6-only) to be able to bind to the corresponding loopback interfaces. We listen independently, but handle incoming requests using the same code.
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-10 18:02:45 +01:00
Mcat12
4ed20a4e8a
Don't show a warning if write() returns 0 (this isn't an error)
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-09 16:07:58 -05:00
DL6ER
1eebc23c7c
Disable debug statement
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-09 21:34:24 +01:00
DL6ER
a95f683711
Detect if the current machine has IPv6 capable interfaces and behave accordingly (don't try to bind to a dual-stack port if the machine isn't capable to handling IPv6, e.g. in docker)
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-09 21:30:10 +01:00
DL6ER
1254b74c93
dualstack will always bee boolean
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-09 19:59:10 +01:00
DL6ER
13b2fb3c35
Merge branch 'development' into new/IPv6support
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
Conflicts:
socket.c
2018-01-09 19:44:28 +01:00
DL6ER
203cc946bd
Add istelnet array
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-04 19:31:23 +01:00
Mcat12
616b10a599
Add swrite function
...
It will print a warning if an error happens, like the other s* functions
in socket.c
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-04 12:28:40 -05:00
Mcat12
e527985371
Implement getStats using MessagePack
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-04 12:04:04 -05:00
Mcat12
97f6ac534a
Remove extra parameter from bind_to_telnet_port
...
Since it has been specialized, it is only called to create the telnet
port.
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-03 20:44:18 -05:00
Mcat12
595ab259ca
Remove HTTP API specific code so it can be replaced with a new protocol
...
Adjusted tests to fit the current lack of output on the unix socket.
Added TELNET enum and used it in place of the old SOCKET to better fit
with the rest of the code base.
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-03 20:16:50 -05:00
Mcat12
8adb3d335e
Merge remote-tracking branch 'origin/development' into new/API
...
Signed-off-by: Mcat12 <newtoncat12@yahoo.com >
2018-01-03 14:35:42 -05:00
DL6ER
7638d8cdb1
Improve socket client example + work on review comments
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 21:33:39 +01:00
DL6ER
8a720b6f19
Fix spelling
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 17:24:54 +01:00
DL6ER
e67e5e45de
Suppress connection interrupted messages for Telnet and Unix Socket
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 14:28:29 +01:00
DL6ER
54487db5cf
Close unix socket and unlink file handle on exit of FTL
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 11:59:43 +01:00
DL6ER
7ad0c66b68
Remove debug output
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 11:32:31 +01:00
DL6ER
1f7dbaa403
:codacy:
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2018-01-01 00:56:39 +01:00
DL6ER
0387304b4c
Answer Unix socket requests the exact same way we do already for the telnet interface
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2017-12-31 22:49:14 +01:00
DL6ER
3c39cb1fd2
Added Unix socket - it is listening!
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2017-12-31 22:44:08 +01:00
DL6ER
e4cbe417a1
Rename existing telnet socket functions to contain "telnet" in their names to avoid confusion when adding Unix sockets
...
Signed-off-by: DL6ER <dl6er@dl6er.de >
2017-12-31 22:25:27 +01:00