aboutsummaryrefslogtreecommitdiff
path: root/src/test/proxy-override.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/proxy-override.c')
-rw-r--r--src/test/proxy-override.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/proxy-override.c b/src/test/proxy-override.c
new file mode 100644
index 0000000..39abdc6
--- /dev/null
+++ b/src/test/proxy-override.c
@@ -0,0 +1,32 @@
+/* This test is called in lieu of tlsdate by tlsdated
+ * and it returns a timestamp that matches the proxy
+ * ordering - global, dynamic, etc.
+ * For use, see tlsdated-unittests.c
+ */
+#include "config.h"
+
+#include <string.h>
+#include <stdio.h>
+
+int main (int argc, char *argv[])
+{
+ /* Unsigned int to match what tlsdate -Vraw returns, not time_t */
+ /* TODO(wad) move tlsdated -Vraw to emitting time_t */
+ unsigned int t = RECENT_COMPILE_DATE + 1;
+ int saw_good_proxy = 0;
+ while (argc--)
+ {
+ if (!strcmp (argv[0], "socks5://good.proxy"))
+ saw_good_proxy = 1;
+ if (!strcmp (argv[0], "socks5://bad.proxy"))
+ {
+ t = RECENT_COMPILE_DATE + 3;
+ break;
+ }
+ argv++;
+ }
+ if (saw_good_proxy)
+ t = RECENT_COMPILE_DATE + 2;
+ fwrite (&t, sizeof (t), 1, stdout);
+ return 0;
+}