From 3955fefec09494a402a6dabce87eae358db2ee01 Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 20 Feb 2012 19:03:25 +1100 Subject: [PATCH 1/9] --api-allow special case 0/0 means all --- api.c | 59 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/api.c b/api.c index 1373425b..1b064a74 100644 --- a/api.c +++ b/api.c @@ -1234,7 +1234,10 @@ static void tidyup() /* * Interpret IP[/Prefix][,IP2[/Prefix2][,...]] --api-allow option - * + * special case of 0/0 allows /0 (means all IP addresses) + */ +#define ALLIP4 "0/0" +/* * N.B. IP4 addresses are by Definition 32bit big endian on all platforms */ static void setup_ipaccess() @@ -1274,38 +1277,42 @@ static void setup_ipaccess() if (comma) *(comma++) = '\0'; - slash = strchr(ptr, '/'); - if (!slash) - ipaccess[ips].mask = 0xffffffff; + if (strcmp(ptr, ALLIP4) == 0) + ipaccess[ips].ip = ipaccess[ips].mask = 0; else { - *(slash++) = '\0'; - mask = atoi(slash); - if (mask < 1 || mask > 32) - goto popipo; // skip invalid/zero - - ipaccess[ips].mask = 0; - while (mask-- >= 0) { - octet = 1 << (mask % 8); - ipaccess[ips].mask |= (octet << (8 * (mask >> 3))); + slash = strchr(ptr, '/'); + if (!slash) + ipaccess[ips].mask = 0xffffffff; + else { + *(slash++) = '\0'; + mask = atoi(slash); + if (mask < 1 || mask > 32) + goto popipo; // skip invalid/zero + + ipaccess[ips].mask = 0; + while (mask-- >= 0) { + octet = 1 << (mask % 8); + ipaccess[ips].mask |= (octet << (8 * (mask >> 3))); + } } - } - ipaccess[ips].ip = 0; // missing default to '.0' - for (i = 0; ptr && (i < 4); i++) { - dot = strchr(ptr, '.'); - if (dot) - *(dot++) = '\0'; + ipaccess[ips].ip = 0; // missing default to '.0' + for (i = 0; ptr && (i < 4); i++) { + dot = strchr(ptr, '.'); + if (dot) + *(dot++) = '\0'; - octet = atoi(ptr); - if (octet < 0 || octet > 0xff) - goto popipo; // skip invalid + octet = atoi(ptr); + if (octet < 0 || octet > 0xff) + goto popipo; // skip invalid - ipaccess[ips].ip |= (octet << (i * 8)); + ipaccess[ips].ip |= (octet << (i * 8)); - ptr = dot; - } + ptr = dot; + } - ipaccess[ips].ip &= ipaccess[ips].mask; + ipaccess[ips].ip &= ipaccess[ips].mask; + } ips++; popipo: From 3bd16acf1207f2c44b9def70b4d7ac940d204ab3 Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 20 Feb 2012 19:12:46 +1100 Subject: [PATCH 2/9] API add --log Interval to 'config' reply --- api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.c b/api.c index 1b064a74..89c60fa9 100644 --- a/api.c +++ b/api.c @@ -496,9 +496,9 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, strcpy(io_buffer, message(MSG_MINECON, 0, NULL, isjson)); if (isjson) - sprintf(buf, "," JSON_MINECON "{\"GPU Count\":%d,\"CPU Count\":%d,\"Pool Count\":%d,\"ADL\":\"%s\",\"ADL in use\":\"%s\",\"Strategy\":\"%s\"}" JSON_CLOSE, nDevs, cpucount, total_pools, adl, adlinuse, strategies[pool_strategy].s); + sprintf(buf, "," JSON_MINECON "{\"GPU Count\":%d,\"CPU Count\":%d,\"Pool Count\":%d,\"ADL\":\"%s\",\"ADL in use\":\"%s\",\"Strategy\":\"%s\",\"Log Interval\":\"%d\"}" JSON_CLOSE, nDevs, cpucount, total_pools, adl, adlinuse, strategies[pool_strategy].s, opt_log_interval); else - sprintf(buf, _MINECON ",GPU Count=%d,CPU Count=%d,Pool Count=%d,ADL=%s,ADL in use=%s,Strategy=%s%c", nDevs, cpucount, total_pools, adl, adlinuse, strategies[pool_strategy].s, SEPARATOR); + sprintf(buf, _MINECON ",GPU Count=%d,CPU Count=%d,Pool Count=%d,ADL=%s,ADL in use=%s,Strategy=%s,Log Interval=%d%c", nDevs, cpucount, total_pools, adl, adlinuse, strategies[pool_strategy].s, opt_log_interval, SEPARATOR); strcat(io_buffer, buf); } From c25aead886b30f04ac8022c7f1effa51b20456e8 Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 20 Feb 2012 19:15:22 +1100 Subject: [PATCH 3/9] Update API version to 1.2 for new 'Log Interval' --- api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.c b/api.c index 89c60fa9..59db9d49 100644 --- a/api.c +++ b/api.c @@ -151,7 +151,7 @@ static const char *COMMA = ","; static const char SEPARATOR = '|'; static const char GPUSEP = ','; -static const char *APIVERSION = "1.1"; +static const char *APIVERSION = "1.2"; static const char *DEAD = "Dead"; static const char *SICK = "Sick"; static const char *NOSTART = "NoStart"; From 60b7c01e7a7b3c312a2775832c147d2695da1873 Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 20 Feb 2012 20:10:21 +1100 Subject: [PATCH 4/9] API restrict access to all non display commands by default --- api.c | 82 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/api.c b/api.c index 59db9d49..f6af9461 100644 --- a/api.c +++ b/api.c @@ -11,6 +11,7 @@ #include "config.h" #include +#include #include #include #include @@ -256,6 +257,7 @@ static const char *JSON_PARAMETER = "parameter"; #define MSG_MISFN 42 #define MSG_BADFN 43 #define MSG_SAVED 44 +#define MSG_ACCDENY 45 enum code_severity { SEVERITY_ERR, @@ -341,6 +343,7 @@ struct CODES { { SEVERITY_ERR, MSG_MISFN, PARAM_NONE, "Missing save filename parameter" }, { SEVERITY_ERR, MSG_BADFN, PARAM_STR, "Can't open or create save file '%s'" }, { SEVERITY_ERR, MSG_SAVED, PARAM_STR, "Configuration saved to file '%s'" }, + { SEVERITY_ERR, MSG_ACCDENY, PARAM_STR, "Access denied to '%s' command" }, { SEVERITY_FAIL, 0, 0, NULL } }; @@ -350,6 +353,7 @@ static bool ping = true; struct IP4ACCESS { in_addr_t ip; in_addr_t mask; + bool writemode; }; static struct IP4ACCESS *ipaccess = NULL; @@ -1156,30 +1160,31 @@ void dosave(__maybe_unused SOCKETTYPE c, char *param, bool isjson) struct CMDS { char *name; void (*func)(SOCKETTYPE, char *, bool); + bool requires_writemode; } cmds[] = { - { "version", apiversion }, - { "config", minerconfig }, - { "devs", devstatus }, - { "pools", poolstatus }, - { "summary", summary }, - { "gpuenable", gpuenable }, - { "gpudisable", gpudisable }, - { "gpurestart", gpurestart }, - { "gpu", gpudev }, + { "version", apiversion, false }, + { "config", minerconfig, false }, + { "devs", devstatus, false }, + { "pools", poolstatus, false }, + { "summary", summary, false }, + { "gpuenable", gpuenable, true }, + { "gpudisable", gpudisable, true }, + { "gpurestart", gpurestart, true }, + { "gpu", gpudev, false }, #ifdef WANT_CPUMINE - { "cpu", cpudev }, + { "cpu", cpudev, false }, #endif - { "gpucount", gpucount }, - { "cpucount", cpucount }, - { "switchpool", switchpool }, - { "gpuintensity", gpuintensity }, - { "gpumem", gpumem}, - { "gpuengine", gpuengine}, - { "gpufan", gpufan}, - { "gpuvddc", gpuvddc}, - { "save", dosave }, - { "quit", doquit }, - { NULL, NULL } + { "gpucount", gpucount, false }, + { "cpucount", cpucount, false }, + { "switchpool", switchpool, true }, + { "gpuintensity", gpuintensity, true }, + { "gpumem", gpumem, true }, + { "gpuengine", gpuengine, true }, + { "gpufan", gpufan, true }, + { "gpuvddc", gpuvddc, true }, + { "save", dosave, true }, + { "quit", doquit, true }, + { NULL, NULL, false } }; static void send_result(SOCKETTYPE c, bool isjson) @@ -1233,7 +1238,7 @@ static void tidyup() } /* - * Interpret IP[/Prefix][,IP2[/Prefix2][,...]] --api-allow option + * Interpret [R|W:]IP[/Prefix][,[R|W:]IP2[/Prefix2][,...]] --api-allow option * special case of 0/0 allows /0 (means all IP addresses) */ #define ALLIP4 "0/0" @@ -1244,6 +1249,7 @@ static void setup_ipaccess() { char *buf, *ptr, *comma, *slash, *dot; int ipcount, mask, octet, i; + bool writemode; buf = malloc(strlen(opt_api_allow) + 1); if (unlikely(!buf)) @@ -1277,6 +1283,17 @@ static void setup_ipaccess() if (comma) *(comma++) = '\0'; + writemode = false; + + if (isalpha(*ptr) && *(ptr+1) == ':') { + if (tolower(*ptr) == 'w') + writemode = true; + + ptr += 2; + } + + ipaccess[ips].writemode = writemode; + if (strcmp(ptr, ALLIP4) == 0) ipaccess[ips].ip = ipaccess[ips].mask = 0; else { @@ -1339,6 +1356,7 @@ void api(void) char *cmd; char *param; bool addrok; + bool writemode; json_error_t json_err; json_t *json_config; json_t *json_val; @@ -1430,27 +1448,27 @@ void api(void) goto die; } + connectaddr = inet_ntoa(cli.sin_addr); + addrok = false; + writemode = false; if (opt_api_allow) { for (i = 0; i < ips; i++) { if ((cli.sin_addr.s_addr & ipaccess[i].mask) == ipaccess[i].ip) { addrok = true; + writemode = ipaccess[i].writemode; break; } } } else { if (opt_api_network) addrok = true; - else { - connectaddr = inet_ntoa(cli.sin_addr); + else addrok = (strcmp(connectaddr, localaddr) == 0); - } } - if (opt_debug) { - connectaddr = inet_ntoa(cli.sin_addr); + if (opt_debug) applog(LOG_DEBUG, "DBG: connection from %s - %s", connectaddr, addrok ? "Accepted" : "Ignored"); - } if (addrok) { n = recv(c, &buf[0], BUFSIZ-1, 0); @@ -1529,7 +1547,13 @@ void api(void) if (!did) for (i = 0; cmds[i].name != NULL; i++) { if (strcmp(cmd, cmds[i].name) == 0) { - (cmds[i].func)(c, param, isjson); + if (cmds[i].requires_writemode && !writemode) { + strcpy(io_buffer, message(MSG_ACCDENY, 0, cmds[i].name, isjson)); + applog(LOG_DEBUG, "DBG: access denied to '%s' for '%s' command", connectaddr, cmds[i].name); + } + else + (cmds[i].func)(c, param, isjson); + send_result(c, isjson); did = true; break; From 9b83c126bed124eac658b68dd64e0b08207277ca Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 20 Feb 2012 21:24:00 +1100 Subject: [PATCH 5/9] Update documentation for API changes --- README | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/README b/README index 16603f59..26121baf 100644 --- a/README +++ b/README @@ -119,10 +119,13 @@ Usage instructions: Run "cgminer --help" to see options: Usage: . [-atDdGCgIKklmpPQqrRsTouvwOchnV] Options for both config file and command line: ---api-allow Allow API access (if enabled) only to the given list of IP[/Prefix] address[/subnets] +--api-allow Allow API access (if enabled) only to the given list of [W:]IP[/Prefix] address[/subnets] This overrides --api-network and you must specify 127.0.0.1 if it is required + W: in front of the IP address gives that address privileged access to all api commands --api-description Description placed in the API status header (default: cgminer version) --api-listen Listen for API requests (default: disabled) + By default any command that does not just display data returns access denied + See --api-allow to overcome this --api-network Allow API (if enabled) to listen on/for any address (default: only 127.0.0.1) --api-port Port number of miner API (default: 4028) --auto-fan Automatically adjust all GPU fan speeds to maintain a target temperature @@ -537,11 +540,22 @@ running cgminer and reply with a string and then close the socket each time If you add the "--api-network" option, it will accept API requests from any network attached computer. +You can only access the comands that reply with data in this mode. +By default, you cannot access any privileged command that affects the miner - +you will receive an access denied status message see --api-access below. + You can specify IP addresses/prefixes that are only allowed to access the API -with the "--api-access" option e.g. --api-access 192.168.0.1,10.0.0/24 +with the "--api-access" option e.g. --api-access W:192.168.0.1,10.0.0/24 will allow 192.168.0.1 or any address matching 10.0.0.*, but nothing else IP addresses are automatically padded with extra '.0's as needed Without a /prefix is the same as specifying /32 +0/0 means all IP addresses. +The 'W:' on the front gives that address/subnet privileged access to commands +that modify cgminer. +Without it those commands return an access denied status. +Privileged access is checked in the order the IP addresses were supplied to +"--api-access" +The first match determines the privilege level. Using the "--api-access" option overides the "--api-network" option if they are both specified With "--api-access", 127.0.0.1 is not by default given access unless specified @@ -584,7 +598,7 @@ The STATUS section is: This defaults to the cgminer version but is the value of --api-description if it was specified at runtime. -The list of requests and replies are: +The list of requests - a (*) means it requires privileged access - and replies are: Request Reply Section Details ------- ------------- ------- @@ -597,7 +611,8 @@ The list of requests and replies are: Pool Count=N, <- the number of Pools ADL=X, <- Y or N if ADL is compiled in the code ADL in use=X, <- Y or N if any GPU has ADL - Strategy=Name| <- the current pool strategy + Strategy=Name, <- the current pool strategy + Log Interval=N| <- log interval (--log N) summary SUMMARY The status summary of the miner e.g. Elapsed=NNN,Found Blocks=N,Getworks=N,...| @@ -625,40 +640,50 @@ The list of requests and replies are: cpucount CPUS Count=N| <- the number of CPUs Always returns 0 if CPU mining is disabled - switchpool|N none There is no reply section just the STATUS section + switchpool|N (*) + none There is no reply section just the STATUS section stating the results of switching pool N to the highest priority (the pool is also enabled) The Msg includes the pool URL - gpuenable|N none There is no reply section just the STATUS section + gpuenable|N (*) + none There is no reply section just the STATUS section stating the results of the enable request - gpudisable|N none There is no reply section just the STATUS section + gpudisable|N (*) + none There is no reply section just the STATUS section stating the results of the disable request - gpurestart|N none There is no reply section just the STATUS section + gpurestart|N (*) + none There is no reply section just the STATUS section stating the results of the restart request - gpuintensity|N,I none There is no reply section just the STATUS section + gpuintensity|N,I (*) + none There is no reply section just the STATUS section stating the results of setting GPU N intensity to I - gpumem|N,V none There is no reply section just the STATUS section + gpumem|N,V (*) + none There is no reply section just the STATUS section stating the results of setting GPU N memoryclock to V MHz - gpuengine|N,V none There is no reply section just the STATUS section + gpuengine|N,V (*) + none There is no reply section just the STATUS section stating the results of setting GPU N clock to V MHz - gpufan|N,V none There is no reply section just the STATUS section + gpufan|N,V (*) + none There is no reply section just the STATUS section stating the results of setting GPU N fan speed to V% - gpuvddc|N,V none There is no reply section just the STATUS section + gpuvddc|N,V (*) + none There is no reply section just the STATUS section stating the results of setting GPU N vddc to V - save|filename none There is no reply section just the STATUS section + save|filename (*) + none There is no reply section just the STATUS section stating success or failure saving the cgminer config to filename - quit none There is no status section but just a single "BYE|" + quit (*) none There is no status section but just a single "BYE|" reply before cgminer quits When you enable, disable or restart a GPU, you will also get Thread messages in @@ -694,8 +719,7 @@ api-example.c - a 'C' program to access the API (with source code) api-example summary 127.0.0.1 4028 miner.php - an example web page to access the API - This includes buttons to enable, disable and restart the GPUs and also to - quit cgminer + This includes buttons and inputs to attempt access to the privileged commands You must modify the 2 lines near the top to change where it looks for cgminer $miner = '127.0.0.1'; # hostname or IP address $port = 4028; From dd233ec244efc929f871550f789ab232e4dff483 Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 21 Feb 2012 11:08:29 +1100 Subject: [PATCH 6/9] API add 'privileged' command so can verify access level --- api.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api.c b/api.c index f6af9461..0e0db5b9 100644 --- a/api.c +++ b/api.c @@ -258,6 +258,7 @@ static const char *JSON_PARAMETER = "parameter"; #define MSG_BADFN 43 #define MSG_SAVED 44 #define MSG_ACCDENY 45 +#define MSG_ACCOK 46 enum code_severity { SEVERITY_ERR, @@ -344,6 +345,7 @@ struct CODES { { SEVERITY_ERR, MSG_BADFN, PARAM_STR, "Can't open or create save file '%s'" }, { SEVERITY_ERR, MSG_SAVED, PARAM_STR, "Configuration saved to file '%s'" }, { SEVERITY_ERR, MSG_ACCDENY, PARAM_STR, "Access denied to '%s' command" }, + { SEVERITY_SUCC, MSG_ACCOK, PARAM_NONE, "Privileged access OK" }, { SEVERITY_FAIL, 0, 0, NULL } }; @@ -1136,6 +1138,11 @@ void doquit(SOCKETTYPE c, __maybe_unused char *param, bool isjson) kill_work(); } +void privileged(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) +{ + strcpy(io_buffer, message(MSG_ACCOK, 0, NULL, isjson)); +} + void dosave(__maybe_unused SOCKETTYPE c, char *param, bool isjson) { FILE *fcfg; @@ -1184,6 +1191,7 @@ struct CMDS { { "gpuvddc", gpuvddc, true }, { "save", dosave, true }, { "quit", doquit, true }, + { "privileged", privileged, true }, { NULL, NULL, false } }; From a455ac7b5ce79849b91ab69323bafdbbf858bd26 Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 21 Feb 2012 11:16:57 +1100 Subject: [PATCH 7/9] README document API 'privileged' command --- README | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README b/README index 26121baf..05b27ae5 100644 --- a/README +++ b/README @@ -598,6 +598,8 @@ The STATUS section is: This defaults to the cgminer version but is the value of --api-description if it was specified at runtime. +For API version 1.2: + The list of requests - a (*) means it requires privileged access - and replies are: Request Reply Section Details @@ -659,7 +661,7 @@ The list of requests - a (*) means it requires privileged access - and replies a stating the results of the restart request gpuintensity|N,I (*) - none There is no reply section just the STATUS section + none There is no reply section just the STATUS section stating the results of setting GPU N intensity to I gpumem|N,V (*) @@ -686,6 +688,12 @@ The list of requests - a (*) means it requires privileged access - and replies a quit (*) none There is no status section but just a single "BYE|" reply before cgminer quits + privileged (*) + none There is no reply section just the STATUS section + stating an error if you do not have privileged access + to the API and success if you do have privilege + The command doesn't change anything in cgminer + When you enable, disable or restart a GPU, you will also get Thread messages in the cgminer status window From e3281c2643d0c5f7f3df7c2bc049443555a6b607 Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 21 Feb 2012 20:03:13 +1100 Subject: [PATCH 8/9] When API shuts down cgminer don't kill itself --- api.c | 8 +++++++- cgminer.c | 2 +- miner.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api.c b/api.c index 0e0db5b9..40c93534 100644 --- a/api.c +++ b/api.c @@ -349,6 +349,7 @@ struct CODES { { SEVERITY_FAIL, 0, 0, NULL } }; +static int my_thr_id = 0; static int bye = 0; static bool ping = true; @@ -1135,6 +1136,9 @@ void doquit(SOCKETTYPE c, __maybe_unused char *param, bool isjson) send_result(c, isjson); *io_buffer = '\0'; bye = 1; + + PTH(&thr_info[my_thr_id]) = 0L; + kill_work(); } @@ -1347,7 +1351,7 @@ popipo: free(buf); } -void api(void) +void api(int api_thr_id) { char buf[BUFSIZ]; char param_buf[BUFSIZ]; @@ -1372,6 +1376,8 @@ void api(void) bool did; int i; + my_thr_id = api_thr_id; + /* This should be done first to ensure curl has already called WSAStartup() in windows */ sleep(opt_log_interval); diff --git a/cgminer.c b/cgminer.c index 0e2d4496..38e42399 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2802,7 +2802,7 @@ static void *api_thread(void *userdata) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - api(); + api(api_thr_id); PTH(mythr) = 0L; diff --git a/miner.h b/miner.h index c383f918..c2b0acee 100644 --- a/miner.h +++ b/miner.h @@ -449,7 +449,7 @@ extern int set_engineclock(int gpu, int iEngineClock); extern int set_memoryclock(int gpu, int iMemoryClock); #endif -extern void api(void); +extern void api(int thr_id); #define MAX_GPUDEVICES 16 #define MAX_DEVICES 32 From de40e6df4f591d3996e884e0cacd062f7945735f Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 21 Feb 2012 20:04:00 +1100 Subject: [PATCH 9/9] Modify API debug messages to say API instead of DBG --- api.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api.c b/api.c index 40c93534..97db93ce 100644 --- a/api.c +++ b/api.c @@ -1209,16 +1209,16 @@ static void send_result(SOCKETTYPE c, bool isjson) len = strlen(io_buffer); - applog(LOG_DEBUG, "DBG: send reply: (%d) '%.10s%s'", len+1, io_buffer, len > 10 ? "..." : ""); + applog(LOG_DEBUG, "API: send reply: (%d) '%.10s%s'", len+1, io_buffer, len > 10 ? "..." : ""); // ignore failure - it's closed immediately anyway n = send(c, io_buffer, len+1, 0); if (opt_debug) { if (SOCKETFAIL(n)) - applog(LOG_DEBUG, "DBG: send failed: %s", SOCKERRMSG); + applog(LOG_DEBUG, "API: send failed: %s", SOCKERRMSG); else - applog(LOG_DEBUG, "DBG: sent %d", n); + applog(LOG_DEBUG, "API: sent %d", n); } } @@ -1482,7 +1482,7 @@ void api(int api_thr_id) } if (opt_debug) - applog(LOG_DEBUG, "DBG: connection from %s - %s", connectaddr, addrok ? "Accepted" : "Ignored"); + applog(LOG_DEBUG, "API: connection from %s - %s", connectaddr, addrok ? "Accepted" : "Ignored"); if (addrok) { n = recv(c, &buf[0], BUFSIZ-1, 0); @@ -1493,9 +1493,9 @@ void api(int api_thr_id) if (opt_debug) { if (SOCKETFAIL(n)) - applog(LOG_DEBUG, "DBG: recv failed: %s", SOCKERRMSG); + applog(LOG_DEBUG, "API: recv failed: %s", SOCKERRMSG); else - applog(LOG_DEBUG, "DBG: recv command: (%d) '%s'", n, buf); + applog(LOG_DEBUG, "API: recv command: (%d) '%s'", n, buf); } if (!SOCKETFAIL(n)) { @@ -1563,7 +1563,7 @@ void api(int api_thr_id) if (strcmp(cmd, cmds[i].name) == 0) { if (cmds[i].requires_writemode && !writemode) { strcpy(io_buffer, message(MSG_ACCDENY, 0, cmds[i].name, isjson)); - applog(LOG_DEBUG, "DBG: access denied to '%s' for '%s' command", connectaddr, cmds[i].name); + applog(LOG_DEBUG, "API: access denied to '%s' for '%s' command", connectaddr, cmds[i].name); } else (cmds[i].func)(c, param, isjson);