/*
- * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "ntlmauth/support_bits.cci"
#include <cctype>
+#include <chrono>
#include <cstring>
#if HAVE_CRYPT_H
#include <crypt.h>
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
+#include <thread>
/* A couple of harmless helper macros */
#define SEND(X) {debug("sending '%s' to squid\n",X); printf(X "\n");}
const char *authenticate_ntlm_domain = "WORKGROUP";
int strip_domain_enabled = 0;
int NTLM_packet_debug_enabled = 0;
+unsigned int response_delay = 0;
/*
* options:
usage(void)
{
fprintf(stderr,
- "Usage: %s [-d] [-v] [-h]\n"
+ "Usage: %s [-d] [-t N] [-v] [-h]\n"
" -d enable debugging.\n"
" -S strip domain from username.\n"
+ " -t timeout to delay responses (milliseconds).\n"
" -v enable verbose NTLM packet debugging.\n"
" -h this message\n\n",
my_program_name);
int opt, had_error = 0;
opterr = 0;
- while (-1 != (opt = getopt(argc, argv, "hdvS"))) {
+ while (-1 != (opt = getopt(argc, argv, "hdvSt:"))) {
switch (opt) {
case 'd':
debug_enabled = 1;
case 'S':
strip_domain_enabled = 1;
break;
+ case 't':
+ if (!xstrtoui(optarg, nullptr, &response_delay, 0, 86400)) {
+ fprintf(stderr, "ERROR: invalid parameter value for -t '%s'", optarg);
+ usage();
+ had_error = 1;
+ }
+ break;
case 'h':
usage();
exit(EXIT_SUCCESS);
} else
debug("Got '%s' from Squid\n", buf);
+ if (response_delay > 0) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(response_delay));
+ }
+
if (strncmp(buf, "YR", 2) == 0) {
char nonce[NTLM_NONCE_LEN];
ntlm_challenge chal;