mirror of https://github.com/arendst/Tasmota.git
Fix syslog server warning
Fix syslog server warning caused by lack of <PRI> field and hostname starting with 'z' (#14689)
This commit is contained in:
parent
04a8414217
commit
a445c7f23a
|
@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Matter Contact sensor was not triggering any update (#20232)
|
||||
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability (#12221)
|
||||
- ESP32 piezo ceramic buzzer doesn't buzz (#20118)
|
||||
- Syslog server warning caused by lack of <PRI> field and hostname starting with 'z' (#14689)
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||
|
||||
### Fixed
|
||||
- CVE-2021-36603 Cross Site Scripting (XSS) vulnerability [#12221](https://github.com/arendst/Tasmota/issues/12221)
|
||||
- Syslog server warning caused by lack of <PRI> field and hostname starting with 'z' [#14689](https://github.com/arendst/Tasmota/issues/14689)
|
||||
- ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118)
|
||||
- Matter Contact sensor was not triggering any update [#20232](https://github.com/arendst/Tasmota/issues/20232)
|
||||
|
||||
|
|
|
@ -2297,8 +2297,9 @@ void SyslogAsync(bool refresh) {
|
|||
char* line;
|
||||
size_t len;
|
||||
while (GetLog(TasmotaGlobal.syslog_level, &index, &line, &len)) {
|
||||
// 00:00:02.096 HTP: Web server active on wemos5 with IP address 192.168.2.172
|
||||
// HTP: Web server active on wemos5 with IP address 192.168.2.172
|
||||
// <--- mxtime ---> TAG MSG
|
||||
// 00:00:02.096-029 HTP: Web server active on wemos5 with IP address 192.168.2.172
|
||||
// HTP: Web server active on wemos5 with IP address 192.168.2.172
|
||||
uint32_t mxtime = strchr(line, ' ') - line +1; // Remove mxtime
|
||||
if (mxtime > 0) {
|
||||
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
|
||||
|
@ -2321,7 +2322,14 @@ void SyslogAsync(bool refresh) {
|
|||
}
|
||||
|
||||
char header[64];
|
||||
snprintf_P(header, sizeof(header), PSTR("%s ESP-"), NetworkHostname());
|
||||
// RFC3164 - BSD syslog protocol - <PRI>TIMESTAMP HOSTNAME TAG MSG
|
||||
// <PRI> = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134>
|
||||
// TIMESTAMP = Mmm dd hh:mm:ss
|
||||
// <134>Jan 1 00:00:02 wemos5 ESP-HTP: server active on wemos5 with IP address 192.168.2.172
|
||||
snprintf_P(header, sizeof(header), PSTR("<134>%s %s ESP-"), GetSyslogDate(line).c_str(), NetworkHostname());
|
||||
// Legacy format
|
||||
// snprintf_P(header, sizeof(header), PSTR("%s ESP-"), NetworkHostname());
|
||||
|
||||
char* line_start = line +mxtime;
|
||||
#ifdef ESP8266
|
||||
// Packets over 1460 bytes are not send
|
||||
|
|
|
@ -109,6 +109,18 @@ String GetBuildDateAndTime(void) {
|
|||
return String(bdt); // 2017-03-07T11:08:02
|
||||
}
|
||||
|
||||
String GetSyslogDate(char* mxtime) {
|
||||
// Mmm dd hh:mm:ss
|
||||
// Jan 3 09:23:45
|
||||
// Assuming the day hasn't changed yet ;-)
|
||||
uint32_t month_idx = (RtcTime.month -1) * 3;
|
||||
char month[4] = { 0 };
|
||||
strncpy_P(month, kMonthNamesEnglish + month_idx, 3);
|
||||
char dt[16];
|
||||
snprintf_P(dt, sizeof(dt), PSTR("%s %2d %s"), month, RtcTime.day_of_month, mxtime);
|
||||
return String(dt);
|
||||
}
|
||||
|
||||
String GetMinuteTime(uint32_t minutes) {
|
||||
char tm[6];
|
||||
snprintf_P(tm, sizeof(tm), PSTR("%02d:%02d"), minutes / 60, minutes % 60);
|
||||
|
|
Loading…
Reference in New Issue