Skip to content
Snippets Groups Projects
Commit 1eeccee1 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

More beautification of trash can entries and details (for log messages)

parent 0db27c20
No related branches found
No related tags found
No related merge requests found
Pipeline #5008 failed
...@@ -63,8 +63,11 @@ char* trash_details(const struct trash* trash, char* str, size_t max) ...@@ -63,8 +63,11 @@ char* trash_details(const struct trash* trash, char* str, size_t max)
char tmp[64]; char tmp[64];
char since[128] = ""; char since[128] = "";
*str = '\0'; *str = '\0';
if(trash->added) if(trash->added) {
snprintf(since, sizeof since, "since %.24s", ctime_r(&trash->added, tmp)); char* p = ctime_r(&trash->added, tmp);
if(p != NULL)
snprintf(since, sizeof since, "since %.20s", p + 4);
}
snprintf(str, max, "%s%s%s%s%s" snprintf(str, max, "%s%s%s%s%s"
,since ,since
,trash->reason[0] ? " for " : "", trash->reason ,trash->reason[0] ? " for " : "", trash->reason
...@@ -153,17 +156,19 @@ BOOL filter_ip(scfg_t* cfg, const char* prot, const char* reason, const char* ho ...@@ -153,17 +156,19 @@ BOOL filter_ip(scfg_t* cfg, const char* prot, const char* reason, const char* ho
if((fp = fnopen(NULL, fname, O_CREAT|O_APPEND|O_WRONLY)) == NULL) if((fp = fnopen(NULL, fname, O_CREAT|O_APPEND|O_WRONLY)) == NULL)
return(FALSE); return(FALSE);
fprintf(fp,"%s\tt=%s\tp=%s\tr=%s" fprintf(fp,"%s\tt=%s"
,ip_addr ,ip_addr
,time_to_isoDateTimeStr(now, xpTimeZone_local(), tstr, sizeof tstr) ,time_to_isoDateTimeStr(now, xpTimeZone_local(), tstr, sizeof tstr));
,prot if(prot != NULL && *prot != '\0')
,reason); fprintf(fp, "\tp=%s", prot);
if(duration) if(reason != NULL && *reason != '\0')
fprintf(fp, "\tr=%s", reason);
if(duration > 0)
fprintf(fp,"\te=%s", time_to_isoDateTimeStr(time(NULL) + duration, xpTimeZone_local(), tstr, sizeof tstr)); fprintf(fp,"\te=%s", time_to_isoDateTimeStr(time(NULL) + duration, xpTimeZone_local(), tstr, sizeof tstr));
if(host!=NULL && strcmp(host, STR_NO_HOSTNAME) != 0) if(username != NULL && *username != '\0')
fprintf(fp,"\th=%s", host);
if(username!=NULL)
fprintf(fp,"\tu=%s", username); fprintf(fp,"\tu=%s", username);
if(host != NULL && *host != '\0' && strcmp(host, STR_NO_HOSTNAME) != 0)
fprintf(fp,"\th=%s", host);
fputc('\n', fp); fputc('\n', fp);
fclose(fp); fclose(fp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment