diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 34 | ||||
-rw-r--r-- | udp514-journal.c | 17 |
3 files changed, 39 insertions, 14 deletions
@@ -14,7 +14,7 @@ LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie # this is just a fallback in case you do not use git but downloaded # a release tarball... -VERSION := 0.2.0 +VERSION := 0.2.1 all: udp514-journal README.html @@ -1,26 +1,34 @@ udp514-journal ============== +[](https://github.com/eworm-de/udp514-journal/stargazers) +[](https://github.com/eworm-de/udp514-journal/network) +[](https://github.com/eworm-de/udp514-journal/watchers) + forward syslog from network (udp/514) to systemd-journald +*Use at your own risk*, pay attention to +[license and warranty](#license-and-warranty), and +[disclaimer on external links](#disclaimer-on-external-links)! + Requirements ------------ To compile and run `udp514-journal` you need: -* [systemd](https://www.github.com/systemd/systemd) -* [markdown](https://daringfireball.net/projects/markdown/) (HTML documentation) +* [systemd ↗️](https://www.github.com/systemd/systemd) +* [markdown ↗️](https://daringfireball.net/projects/markdown/) (HTML documentation) Build and install ----------------- Building and installing is very easy. Just run: -> make + make followed by: -> make install + make install This will place an executable at `/usr/bin/udp514-journal`, documentation can be found in `/usr/share/doc/udp514-journal/`. @@ -69,6 +77,21 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU General Public License](COPYING.md) for more details. +Disclaimer on external links +---------------------------- + +Our website contains links to the websites of third parties ("external +links"). As the content of these websites is not under our control, we +cannot assume any liability for such external content. In all cases, the +provider of information of the linked websites is liable for the content +and accuracy of the information provided. At the point in time when the +links were placed, no infringements of the law were recognisable to us. +As soon as an infringement of the law becomes known to us, we will +immediately remove the link in question. + +> 💡️ **Hint**: All external links are marked with an arrow pointing +> diagonally in an up-right (or north-east) direction (↗️). + ### Upstream URL: @@ -77,3 +100,6 @@ URL: Mirror: [eworm.de](https://git.eworm.de/cgit.cgi/udp514-journal/) [GitLab.com](https://gitlab.com/eworm-de/udp514-journal#udp514-journal) + +--- +[⬆️ Go back to top](#top) diff --git a/udp514-journal.c b/udp514-journal.c index a518ca3..402785c 100644 --- a/udp514-journal.c +++ b/udp514-journal.c @@ -100,12 +100,16 @@ int main(int argc, char **argv) { /* get client's ip address */ switch (addr_client->sa_family) { case AF_INET6: - address = inet_ntop(AF_INET6, &addr_client_in6->sin6_addr, - addr_buf, INET6_ADDRSTRLEN); + const struct in6_addr *in6_addr = &addr_client_in6->sin6_addr; + address = inet_ntop(AF_INET6, in6_addr, addr_buf, INET6_ADDRSTRLEN); + /* strip prefix (::ffff:) from mapped ipv4 addresses */ + if (address && IN6_IS_ADDR_V4MAPPED(in6_addr)) { + address += 7; + } break; case AF_INET: - address = inet_ntop(AF_INET, &addr_client_in->sin_addr, - addr_buf, INET6_ADDRSTRLEN); + const struct in_addr *in_addr = &addr_client_in->sin_addr; + address = inet_ntop(AF_INET, in_addr, addr_buf, INET6_ADDRSTRLEN); break; default: fputs("unhadled address family", stderr); @@ -116,11 +120,6 @@ int main(int argc, char **argv) { continue; } - /* strip prefix from mapped ipv4 addresses */ - if (strncmp(address, "::ffff:", 7) == 0) { - address += 7; - } - /* send to systemd-journald */ sd_journal_send("MESSAGE=%s", msg_buf, "SYSLOG_IDENTIFIER=%s", address, |