diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-03-08 14:09:26 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-03-08 14:09:26 +0100 |
commit | aae28614e07cd3c079227b27c4a51f7620b7bd6c (patch) | |
tree | 8e3d29e4f7edb06e0359516743b5746c24745d2c /src | |
parent | delo (diff) | |
download | travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar.gz travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar.bz2 travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar.lz travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar.xz travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.tar.zst travnik-aae28614e07cd3c079227b27c4a51f7620b7bd6c.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/tcp.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,3 +1,4 @@ +#include <sys/utsname.h> void disconnection (struct torrent * t) { fprintf(stderr, "disconnecting from peer "); peer_print(stderr, t->dl); @@ -22,7 +23,26 @@ void disconnection (struct torrent * t) { if (!inet_ntop(t->dl->addr.sin6_family, t->dl->addr.sin6_addr.s6_addr, remote, INET6_ADDRSTRLEN+7)) snprintf(remote, sizeof remote, "(inet_ntop: %s)", strerror(errno)); sprintf(remote+strlen(remote), "/%d", ntohs(t->dl->addr.sin6_port)); - fprintf(f, "d10:created by58:http://ni.šijanec.eu/sijanec/travnik mailto:tk@sijanec.eu13:creation datei%lde8:encoding5:UTF-84:info", time(NULL)); + char createdby[1024]; + char unam[512]; + char * machinetext = unam; + struct utsname utsname; + if (uname(&utsname) == -1) + snprintf(unam, 512, "uname(&utsname) == -1, errno == %d (%s)", errno, strerror(errno)); + else + snprintf(unam, 512, "%s %s %s %s %s" +#ifdef _GNU_SOURCE + " %s" +#endif + , utsname.sysname, utsname.nodename, utsname.release, utsname.version, utsname.machine +#ifdef _GNU_SOURCE + , utsname.domainname +#endif + ); + if (getenv("CREATED_BY")) + machinetext = getenv("CREATED_BY"); + snprintf(createdby, 1024, "http://ni.šijanec.eu/sijanec/travnik mailto:tk@sijanec.eu %s", machinetext); + fprintf(f, "d10:created by%zu:%s13:creation datei%lde8:encoding5:UTF-84:info", strlen(createdby), createdby, time(NULL)); fwrite(t->metadata, 1, t->size, f); // i don't expect any errors here fprintf(f, "6:sourced2:ip%zu:%s", strlen(remote), remote); if (t->software) |