fix(xo-server-transport-nagios): don\'t fail on message with line break
Fixes zammad#9800
This commit is contained in:
parent
424322f7b7
commit
c964a1471a
@ -23,4 +23,6 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- xo-server-transport-nagios patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
@ -28,6 +28,7 @@
|
||||
"node": ">=6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@xen-orchestra/log": "^0.3.0",
|
||||
"buffer-crc32": "^0.2.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,9 @@
|
||||
import crc32 from 'buffer-crc32'
|
||||
import net from 'net'
|
||||
import { Buffer } from 'buffer'
|
||||
import { createLogger } from '@xen-orchestra/log'
|
||||
|
||||
const { debug, warn } = createLogger('xo:server:transport:nagios')
|
||||
|
||||
// ===================================================================
|
||||
|
||||
@ -109,13 +112,21 @@ class XoServerNagios {
|
||||
_sendPassiveCheck({ message, status }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (/\r|\n/.test(message)) {
|
||||
throw new Error('the message must not contain a line break')
|
||||
warn('the message must not contain a line break', { message })
|
||||
for (let i = 0, n = message.length; i < n; ++i) {
|
||||
const c = message[i]
|
||||
if (c === '\n') {
|
||||
message[i] = '\\n'
|
||||
} else if (c === '\r') {
|
||||
message[i] = '\\r'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const client = new net.Socket()
|
||||
|
||||
client.connect(this._conf.port, this._conf.server, () => {
|
||||
console.log('Successful connection')
|
||||
debug('Successful connection')
|
||||
})
|
||||
|
||||
client.on('data', data => {
|
||||
|
Loading…
Reference in New Issue
Block a user