@@ -110,6 +110,7 @@ class SocketListener
|
|||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
$line = rtrim($line, "\r\n");
|
$line = rtrim($line, "\r\n");
|
||||||
if ($line !== '') {
|
if ($line !== '') {
|
||||||
|
$line = preg_replace('/^\<\d+\>/', '', $line);
|
||||||
($this->onLine)($line, $id);
|
($this->onLine)($line, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,15 +127,22 @@ class SocketListener
|
|||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fprintf(STDERR, "UDP recv %d bytes from %s:%d\n", strlen($buf), $from, $port);
|
||||||
$lines = explode("\n", rtrim($buf, "\r\n"));
|
$lines = explode("\n", rtrim($buf, "\r\n"));
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
$line = rtrim($line, "\r\n");
|
$line = rtrim($line, "\r\n");
|
||||||
if ($line !== '') {
|
if ($line !== '') {
|
||||||
($this->onLine)($line, $id);
|
$this->handleLineWithSyslog($line, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function handleLineWithSyslog(string $line, int $sourceId): void
|
||||||
|
{
|
||||||
|
$line = preg_replace('/^\<\d+\>/', '', $line);
|
||||||
|
($this->onLine)($line, $sourceId);
|
||||||
|
}
|
||||||
|
|
||||||
public function stop(): void
|
public function stop(): void
|
||||||
{
|
{
|
||||||
foreach ($this->tcpClients as $id => $clients) {
|
foreach ($this->tcpClients as $id => $clients) {
|
||||||
|
|||||||
Reference in New Issue
Block a user