Commit Graph

28 Commits

Author SHA1 Message Date
DL6ER 10962a07a6 Improve memory handling in api.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2018-02-07 12:29:21 +01:00
Mcat12 5341b18ecf Handle possible pack_fixstr or pack_str32 error
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 15:40:58 -05:00
Mcat12 9bc056248f Use a static buffer for getallqueries string arguments
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 15:02:41 -05:00
Mcat12 42bf9a4c6f Fix status output in getStats
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 11:37:37 -05:00
Mcat12 9007af7dbb Fix under-allocation in getVersion
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:54:59 -05:00
Mcat12 be5815fbda Use float instead of double in getQueryTypesOverTime
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:54:21 -05:00
Mcat12 4e8027b74d Use float instead of double in getForwardDestinationsOverTime
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:53:29 -05:00
Mcat12 ad99f975fe Fix under-allocation in getTopDomains
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:43:03 -05:00
Mcat12 76aff45eb5 Clarify getOverTime comment
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:41:23 -05:00
Mcat12 173efff918 Don't use buffers in getStats
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-21 10:38:34 -05:00
Mcat12 cf0cdfed7d Reword api.c license header description
Removed reference to the HTTP API.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-20 11:11:52 -05: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
Mcat12 c88af99ebd Add *. to domains in getTopDomains if it's for audit and a wildcard
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-14 17:30:55 -05:00
Mcat12 9b8b232a02 Fix incorrect merging
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-12 17:44:48 -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
Mcat12 1983d3d116 Rename api_stats.c to api.c
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-12 14:55:58 -05:00
Mcat12 071f924f70 Remove the rest of the DNS commands and unused helpers
They now live in the API

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2018-01-12 14:55:24 -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 6050aa5ad7 Add IP address into the authentication check
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-12-25 23:56:56 -05:00
Mcat12 ae81270817 Fix invalid for loop error
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-12-24 17:04:55 -05:00
Mcat12 5005f285ec Implement simple password-protection to the HTTP API
Currently has the hardcoded password of "password". You gain a session
by sending JSON to the API with the key of `password` and the value
set to the password you are trying to use. Then it will return a success
response with the session and will add a Set-Cookie header to set the
FTL_SESSION cookie to the session number.

The summary, queries graph, and status are accessible without
authentication.

The internal data structure used to store the sessions is valid for up
to 24 minutes after the last query. If it becomes invalid then it is
eligible to be reused for a new session. The garbage collection can be
optimized further, but it is not a problem at the moment.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-12-24 16:11:46 -05:00
Mcat12 3331c42971 Move getPayload to api.c
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-11-26 22:59:24 -05:00
Mcat12 4842c16e34 Fix broken domain verification if the domain includes numbers
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-09-04 16:16:07 -04:00
Mcat12 a743931d15 Improve API response method to use enums 2017-08-10 22:00:13 -04:00
Mcat12 3a5752d908 Actually add the domain to the list
This requires the `pihole` user to have sudo access to the `pihole`
command (will require a core update). Many future API commands will have
this requirement, as they too will be using the `pihole` command.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-08-09 22:40:33 -04:00
Mcat12 2f8e5409eb Check if domain is invalid
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-08-09 22:05:51 -04:00
Mcat12 9ec7bd8722 Implement simple JSON parsing for addList
Uses cJSON to parse, but output will still be handled directly.
I implemented different API response methods to allow for different HTTP
response codes to be sent.
The addList code is still dumb and doesn't do anything, but it's getting
there.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-08-09 21:28:38 -04:00
Mcat12 4762b8a55c Reorganize to split up API functions
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2017-08-06 19:06:12 -04:00