summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tcp.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/tcp.c b/src/tcp.c
index bfd49bc..dc73d55 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -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)