Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package smtpping for openSUSE:Factory checked in at 2021-11-18 10:33:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/smtpping (Old) and /work/SRC/openSUSE:Factory/.smtpping.new.1895 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "smtpping" Thu Nov 18 10:33:40 2021 rev:2 rq:931969 version:1.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/smtpping/smtpping.changes 2017-11-16 14:02:02.567389398 +0100 +++ /work/SRC/openSUSE:Factory/.smtpping.new.1895/smtpping.changes 2021-11-18 10:33:55.243912267 +0100 @@ -1,0 +2,13 @@ +Thu Nov 4 19:42:26 UTC 2021 - Martin Hauke <mar...@gmx.de> + +- Update to version 1.1.4 + * Added --version + * Skip /s in rate output + * Fix help + * Added support for CHUNKING + * Handle all 2yz codes as positive + * Do not try to DNS resolve @ip destinations + * Added -b (--bind) option to bind to a source IP + * Allow -r to be used with -P1 + +------------------------------------------------------------------- Old: ---- smtpping-1.1.3.tar.gz New: ---- smtpping-1.1.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ smtpping.spec ++++++ --- /var/tmp/diff_new_pack.9S5ti8/_old 2021-11-18 10:33:55.591912591 +0100 +++ /var/tmp/diff_new_pack.9S5ti8/_new 2021-11-18 10:33:55.595912595 +0100 @@ -1,7 +1,8 @@ # # spec file for package smtpping # -# Copyright (c) 2017, Martin Hauke <mar...@gmx.de> +# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2017-2021, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,15 +13,15 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: smtpping -Version: 1.1.3 +Version: 1.1.4 Release: 0 Summary: A tool for measuring SMTP server delay, delay variation and throughput -License: GPL-2.0 +License: GPL-2.0-only Group: Productivity/Networking/Other URL: https://github.com/halon/smtpping #Git-Clone: https://github.com/halon/smtpping.git @@ -42,8 +43,9 @@ %cmake_install %files -%doc LICENSE README.md +%license LICENSE +%doc README.md %{_bindir}/smtpping -%{_mandir}/man1/smtpping.1%{ext_man} +%{_mandir}/man1/smtpping.1%{?ext_man} %changelog ++++++ smtpping-1.1.3.tar.gz -> smtpping-1.1.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smtpping-1.1.3/CMakeLists.txt new/smtpping-1.1.4/CMakeLists.txt --- old/smtpping-1.1.3/CMakeLists.txt 2016-05-16 09:16:04.000000000 +0200 +++ new/smtpping-1.1.4/CMakeLists.txt 2021-11-03 01:06:35.000000000 +0100 @@ -13,10 +13,15 @@ ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} - resolv pthread ) +IF (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +TARGET_LINK_LIBRARIES(${TARGET_NAME} + resolv +) +ENDIF() + IF (NOT DEFINED BIN_INSTALL_DIR) SET(BIN_INSTALL_DIR "bin") ENDIF(NOT DEFINED BIN_INSTALL_DIR) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smtpping-1.1.3/smtpping.1 new/smtpping-1.1.4/smtpping.1 --- old/smtpping-1.1.3/smtpping.1 2016-05-16 09:16:04.000000000 +0200 +++ new/smtpping-1.1.4/smtpping.1 2021-11-03 01:06:35.000000000 +0100 @@ -22,11 +22,11 @@ .Nd SMTP benchmarking and measurement tool .Sh SYNOPSIS .Nm -.Op Fl dqrJ46 +.Op Fl dqrJ46C .Op Fl p Ar port .Op Fl w Ar wait .Op Fl c Ar count -.Op Fl P Ar parallell +.Op Fl P Ar parallel .Op Fl s Ar size .Op Fl f Ar file .Op Fl H Ar hello @@ -60,7 +60,7 @@ .It Fl c Ar count Number of pings to send (default: unlimited). .It Fl P Ar processes -Number of parallell worker processes (default: 1). To measure throughput, +Number of parallel worker processes (default: 1). To measure throughput, it's recommended to use .Fl r and @@ -80,6 +80,8 @@ HELO name (default: localhost.localdomain). .It Fl S Ar sender Sender address (default: <>). +.It Fl C +Use CHUNKING (BDAT) .It Fl r Display rate instead of transaction delays. To measure throughput, it's recommended to use diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/smtpping-1.1.3/smtpping.cpp new/smtpping-1.1.4/smtpping.cpp --- old/smtpping-1.1.3/smtpping.cpp 2016-05-16 09:16:04.000000000 +0200 +++ new/smtpping-1.1.4/smtpping.cpp 2021-11-03 01:06:35.000000000 +0100 @@ -39,6 +39,7 @@ #include <winbase.h> #else #include <sys/socket.h> +#include <arpa/inet.h> #include <netdb.h> #include <sys/wait.h> #include <errno.h> @@ -57,7 +58,7 @@ */ bool debug = false; -#define APP_VERSION "1.1.3" +#define APP_VERSION "1.1.4" #define APP_NAME "smtpping" /* @@ -74,7 +75,7 @@ * SMTPReadLine: read a smtp line and return status code * return false on disconnect */ -bool SMTPReadLine(int s, std::string& ret) +bool SMTPReadLine(int s, size_t& ret) { #ifdef __WIN32__ #define MSG_NOSIGNAL 0 @@ -92,7 +93,7 @@ /* support multi-line responses */ if (cmd.size() > 4 && cmd[3] == ' ') { - ret = cmd.substr(0, 3); + ret = strtoul(cmd.substr(0, 3).c_str(), NULL, 10); return true; } else cmd.clear(); @@ -149,15 +150,17 @@ */ void usage(const char* name, FILE* fp, int status) { - fprintf(fp, + fprintf(fp, "Usage: " APP_NAME " [ARGS] x@y.z [@server]\n" "Where: x@y.z is the address that will receive e-mail\n" " server is the address to connect to (optional)\n" " ARGS is one or many of: (optional)\n" " -h, --help\tShow this help message\n" + " -v, --version\tShow version\n" " -d, --debug\tShow more debugging\n" " -4\t\tUse IPv4\n" " -6\t\tUse IPv6\n" + " -b, --bind\tBind source address\n" " -p, --port\tWhich TCP port to use [default: 25]\n" " -w, --wait\tTime to wait between PINGs [default: 1000]" " (ms)\n" @@ -168,6 +171,7 @@ " -f, --file\tSend message file (RFC 822)\n" " -H, --helo\tHELO domain [default: localhost.localdomain]\n" " -S, --sender\tSender address [default: empty]\n" + " -C, --chunking\tUse CHUNKING (BDAT)\n" " -r, --rate\tShow message rate per second\n" " -q, --quiet\tShow less output\n" " -J\t\tRun in jailed mode (forbid --file)\n" @@ -176,7 +180,7 @@ "the recipient domain's\n MX record, falling back on A/AAAA " "records.\n" "\n" - " " APP_NAME " " APP_VERSION " built on " __DATE__ + " " APP_NAME " " APP_VERSION " built on " __DATE__ " (c) Halon Security <supp...@halon.se>\n" ); exit(status); @@ -194,6 +198,7 @@ #endif /* default pareamters */ + const char *smtp_bind = NULL; const char *smtp_helo = "localhost.localdomain"; const char *smtp_from = ""; const char *smtp_port = "25"; @@ -207,14 +212,16 @@ bool quiet = false; bool safe_mode = false; unsigned int proto = 0; + bool chunking = false; /* no arguments: show help */ if (argc < 2) usage(argv[0], stderr, 2); /* getopts/longopts */ - static struct option longopts[] = { + static struct option longopts[] = { { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'v' }, { "helo", required_argument, NULL, 'H' }, { "sender", required_argument, NULL, 'S' }, { "count", required_argument, NULL, 'c' }, @@ -223,14 +230,16 @@ { "size", required_argument, NULL, 's' }, { "port", required_argument, NULL, 'p' }, { "file", required_argument, NULL, 'f' }, - { "rate", required_argument, NULL, 'r' }, - { "quiet", required_argument, NULL, 'q' }, + { "rate", no_argument, NULL, 'r' }, + { "quiet", no_argument, NULL, 'q' }, + { "bind", required_argument, NULL, 'b' }, + { "chunking", no_argument, NULL, 'C' }, { NULL, 0, NULL, 0 } - }; + }; opterr = 0; optind = 0; int ch; - while ((ch = getopt_long(argc, argv, "H:S:s:hw:c:P:p:df:rqJ46", longopts, NULL)) != -1) + while ((ch = getopt_long(argc, argv, "H:S:s:hw:c:P:p:df:rqJ46b:Cv", longopts, NULL)) != -1) { switch(ch) { @@ -280,6 +289,16 @@ case '6': proto = AF_INET6; break; + case 'b': + smtp_bind = optarg; + break; + case 'C': + chunking = true; + break; + case 'v': + printf("%s\n", APP_VERSION); + exit(0); + break; default: usage(argv[0], stderr, 2); break; @@ -306,9 +325,9 @@ fprintf(stderr, "warning: file %s could not be opened\n" , smtp_file); else - data.append(std::istreambuf_iterator<char>(ifs.rdbuf()), + data.append(std::istreambuf_iterator<char>(ifs.rdbuf()), std::istreambuf_iterator<char>()); - data += ".\r\n"; + if (!chunking) data += ".\r\n"; } else { /* generate message with approximatly size */ data += "Subject: SMTP Ping\r\n"; @@ -319,8 +338,9 @@ while (data.size() / 1024 < smtp_data_size) data += "AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ" "00112233445566778899\r\n"; - data += "\r\n.\r\n"; + if (!chunking) data += "\r\n.\r\n"; } + if (chunking) data = "BDAT " + std::to_string(data.size()) + " LAST\r\n" + data; Resolver resolv; vector<string> address; @@ -334,17 +354,22 @@ /* jmp past '@' */ const char* domain = argv[1] + 1; - /* resolve as A/AAAA */ - if (!resolv.Lookup(domain, Resolver::RR_A, address)) - if (debug) fprintf(stderr, "warning: failed to resolve " - "A for %s\n", domain); - if (!resolv.Lookup(domain, Resolver::RR_AAAA, address)) - if (debug) fprintf(stderr, "warning: failed to resolve " - "AAAA for %s\n", domain); - - /* could not resolve, try to use address */ - if (address.empty()) + char buf[sizeof(struct in6_addr)]; + if (inet_pton(AF_INET, domain, &buf) == 1 || inet_pton(AF_INET6, domain, &buf) == 1) address.push_back(domain); + else + { + /* resolve as A/AAAA */ + if (!resolv.Lookup(domain, Resolver::RR_A, address)) + if (debug) fprintf(stderr, "warning: failed to resolve " + "A for %s\n", domain); + if (!resolv.Lookup(domain, Resolver::RR_AAAA, address)) + if (debug) fprintf(stderr, "warning: failed to resolve " + "AAAA for %s\n", domain); + /* could not resolve, try to use address */ + if (address.empty()) + address.push_back(domain); + } } else { /* use mailaddress as mx */ @@ -385,7 +410,7 @@ } else { /* resolve all mx */ - for(vector<string>::const_iterator i = mx.begin(); + for(vector<string>::const_iterator i = mx.begin(); i != mx.end(); ++i) { bool ok = false; @@ -403,7 +428,7 @@ else ok = true; } - /* could not reslove as either A or AAAA: + /* could not reslove as either A or AAAA: maybe it's an IP */ if (!ok) address.push_back(*i); @@ -426,7 +451,7 @@ #endif unsigned int child = 1; - if (forks > 1) { + if (forks > 0) { #ifdef __WIN32__ fprintf(stderr, "-P is not supported on this platform\n"); return 1; @@ -440,7 +465,7 @@ #ifdef SUPPORT_RATE while (show_rate && !abort_ping) { sem_wait(sem); - printf("%zu/s\n", *counter); + printf("%zu\n", *counter); *counter = 0; sem_post(sem); sleep(1); @@ -454,7 +479,7 @@ return 0; #endif } else if (show_rate) { - fprintf(stderr, "-r only works with -P2 or greater\n"); + fprintf(stderr, "-r only works with -P1 or greater\n"); return 1; } spawn: @@ -488,6 +513,21 @@ #define STATS_SESSION_TIME(name) \ (smtp_##name - smtp_connect) + struct addrinfo *bindIP = NULL, bindIPTmp; + if (smtp_bind) + { + memset(&bindIPTmp, 0, sizeof bindIPTmp); + bindIPTmp.ai_family = AF_UNSPEC; + bindIPTmp.ai_socktype = SOCK_STREAM; + int r = getaddrinfo(smtp_bind, 0, &bindIPTmp, &bindIP); + if (r != 0) + { + fprintf(stderr, "getaddrinfo() failed %s: %s\n", + smtp_bind, gai_strerror(r)); + return 1; + } + } + /* connect to the first working address */ unsigned int smtp_seq = 0; vector<string>::const_iterator i; @@ -509,10 +549,13 @@ if (proto && res->ai_family != proto) continue; + if (bindIP && bindIP->ai_family != res->ai_family) + continue; + /* print header */ if (!quiet) - printf("PING %s ([%s]:%s): %d bytes (SMTP DATA)\n", - smtp_rcpt, i->c_str(), smtp_port, + printf("PING %s ([%s]:%s): %d bytes (SMTP DATA)\n", + smtp_rcpt, i->c_str(), smtp_port, (unsigned int)data.size()); reconnect: @@ -540,7 +583,19 @@ res->ai_protocol); if (s == -1) { - fprintf(stderr, "seq=%u: socket() failed\n", + fprintf(stderr, "seq=%u: socket() failed\n", + smtp_seq); + if (smtp_seq == 0) { + freeaddrinfo(res); + continue; + } else { + goto reconnect; + } + } + + if (bindIP && bind(s, bindIP->ai_addr, bindIP->ai_addrlen) != 0) + { + fprintf(stderr, "seq=%u: bind() failed\n", smtp_seq); if (smtp_seq == 0) { freeaddrinfo(res); @@ -567,7 +622,7 @@ continue; } else { close(s); - goto reconnect; + goto reconnect; } } STATS(connect, init); @@ -579,13 +634,14 @@ /* * < SMTP Banner */ - string ret, cmd; - if (!SMTPReadLine(s, ret) || ret != "220") + string cmd; + size_t ret; + if (!SMTPReadLine(s, ret) || ret / 100 != 2) { - fprintf(stderr, "seq=%u: recv: BANNER failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: BANNER failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(banner, connect); @@ -598,14 +654,14 @@ { fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); close(s); - goto reconnect; + goto reconnect; } - if (!SMTPReadLine(s, ret) || ret != "250") + if (!SMTPReadLine(s, ret) || ret / 100 != 2) { - fprintf(stderr, "seq=%u: recv: HELO failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: HELO failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(helo, connect); @@ -618,14 +674,14 @@ { fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); close(s); - goto reconnect; + goto reconnect; } - if (!SMTPReadLine(s, ret) || ret != "250") + if (!SMTPReadLine(s, ret) || ret / 100 != 2) { - fprintf(stderr, "seq=%u: recv: MAIL FROM failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: MAIL FROM failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(mailfrom, connect); @@ -638,34 +694,37 @@ { fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); close(s); - goto reconnect; + goto reconnect; } - if (!SMTPReadLine(s, ret) || ret != "250") + if (!SMTPReadLine(s, ret) || ret / 100 != 2) { - fprintf(stderr, "seq=%u: recv: RCPT TO failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: RCPT TO failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(rcptto, connect); - /* - * > DATA - * < 354 Feed me - */ - cmd = string("DATA\r\n"); - if (send(s, cmd.c_str(), cmd.size(), 0) != (int)cmd.size()) + if (!chunking) { - fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); - close(s); - goto reconnect; - } - if (!SMTPReadLine(s, ret) || ret != "354") - { - fprintf(stderr, "seq=%u: recv: DATA failed (%s)\n", - smtp_seq, ret.c_str()); - close(s); - goto reconnect; + /* + * > DATA + * < 354 Feed me + */ + cmd = string("DATA\r\n"); + if (send(s, cmd.c_str(), cmd.size(), 0) != (int)cmd.size()) + { + fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); + close(s); + goto reconnect; + } + if (!SMTPReadLine(s, ret) || ret / 100 != 3) + { + fprintf(stderr, "seq=%u: recv: DATA failed (%zu)\n", + smtp_seq, ret); + close(s); + goto reconnect; + } } STATS(data, connect); @@ -677,14 +736,14 @@ { fprintf(stderr, "seq=%u: send: failed\n", smtp_seq); close(s); - goto reconnect; + goto reconnect; } if (!SMTPReadLine(s, ret)) { - fprintf(stderr, "seq=%u: recv: EOM failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: EOM failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(datasent, connect); @@ -698,14 +757,14 @@ fprintf(stderr, "seq=%u: send: QUIT failed\n", smtp_seq); close(s); - goto reconnect; + goto reconnect; } if (!SMTPReadLine(s, ret)) { - fprintf(stderr, "seq=%u: recv: QUIT failed (%s)\n", - smtp_seq, ret.c_str()); + fprintf(stderr, "seq=%u: recv: QUIT failed (%zu)\n", + smtp_seq, ret); close(s); - goto reconnect; + goto reconnect; } STATS(quit, connect); @@ -713,7 +772,7 @@ close(s); #ifdef SUPPORT_RATE - if (forks > 1) { + if (show_rate) { sem_wait(sem); (*counter)++; sem_post(sem); @@ -761,7 +820,7 @@ SHOWSTAT(quit); } else { - printf("\n--- no pings were sent ---\n"); + printf("\n--- no pings were sent ---\n"); } #ifdef __WIN32__