xmpp-fingerprint.lua

Mon, 04 Oct 2010 02:43:59 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 04 Oct 2010 02:43:59 +0100
changeset 13
9331253c2f83
parent 11
c77c5ac57156
child 15
1b59ba3e9508
permissions
-rwxr-xr-x

xmpp-fingerprint.lua: Whitespace fix

0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env lua
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
2
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
3 function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
4 return nil, lib; end end
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
5
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
6 -- Required to be able to find packages installed with luarocks
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
7 if not softreq "luarocks.loader" then -- LuaRocks 2.x
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
8 softreq "luarocks.require"; -- LuaRocks <1.x
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
9 end
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
10
1eabe33d7af7 Support for LuaRocks (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
11 local socket = softreq "socket";
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 -- Defaults --
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 default_port = 5222;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 default_namespace = "jabber:client";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 default_timeout = 1.5;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 -- Print debug output --
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 function debug() end -- Keep debug output quiet by default
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 -- Command-line flag handlers --
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 local flags = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 function flags.d() -- Show debug
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 debug = print;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 function flags.s() -- Use s2s
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 -- Use s2s
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 default_port = 5269;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 default_namespace = "jabber:server";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 function flags.t(arg)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 default_timeout = tonumber(arg[1] or 1);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 return 1;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37
3
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
38 function flags.help()
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
39 print("XMPP Server Fingerprinter");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
40 print("(C) 2010 Matthew Wild. Licensed under the MIT/X11 License");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
41 print("");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
42 print("Syntax: "..arg[0].." [OPTIONS] ADDRESS [PORT]");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
43 print("");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
44 print("ADDRESS must be the network address or IP to connect to, SRV lookup");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
45 print("is not supported.");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
46 print("");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
47 print("PORT is the port number to connect to. Defaults to 5222, or 5269 for");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
48 print("server-to-server testing.");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
49 print("");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
50 print("Options:");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
51 print(" -s:", "Server-to-server port testing (less reliable)");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
52 print("-t NUM:", "Set timeout to NUM seconds");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
53 print(" -d:", "Enable debug output (useful for adding new fingerprints)");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
54 print("");
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
55 end
fb9987d6df5d Add -help flag for information on usage and options
Matthew Wild <mwild1@gmail.com>
parents: 2
diff changeset
56
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 -- Process flags --
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 local function process_args(arg)
4
0677d0506878 Support --style options too
Matthew Wild <mwild1@gmail.com>
parents: 3
diff changeset
59 local f = arg[1] and arg[1]:match("^%-%-?(%S+)");
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 if f then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 table.remove(arg, 1);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 if flags[f] then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 local used = flags[f](arg);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 if used then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 for i=1,used do
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 table.remove(arg, 1);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 return process_args(arg);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 end
5
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
73 if #arg > 0 then
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
74 process_args(arg);
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
75 else
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
76 flags.help();
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
77 os.exit(1);
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
78 end
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
79
6
69af027ed4b8 Correct test for missing required arguments (ie. the server address) - thanks albert!
Matthew Wild <mwild1@gmail.com>
parents: 5
diff changeset
80 if #arg < 1 then
5
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
81 io.stderr:write("ERROR: No server address specified.\n");
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
82 os.exit(1);
05ee9f5fcefc Show help automatically when no arguments presented, show error when no server address is given.
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
83 end
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 local received_cache = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 local function _test(server, port, question, answer)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 local received = received_cache[question];
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 if not received then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 debug("||", "Connecting to "..server..":"..port.."...");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 local conn = assert(socket.connect(server, port), "Failed to connect to "..arg[1]);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 conn:send(question);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 debug(">>", tostring(question));
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 conn:settimeout(default_timeout);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 local data, err, partial = conn:receive("*a");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 received = data or partial or "";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 conn:close();
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 received_cache[question] = received;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 debug("<<", #received ~= "" and tostring(received) or nil);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 return received ~= "" and received:match(answer);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 function test(question, answer)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 return _test(arg[1], tonumber(arg[2]) or default_port, question, answer);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 function server_comment(comment)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 table.insert(getfenv(2).server_comments, comment);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 function literal(s)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 return s:gsub("%p", "%%%1");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 -----
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 q_invalid_xml = "abc\n";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 q_empty_message_tag = "<message/>";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 q_invalid_host = "<stream:stream xmlns='"..default_namespace.."' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='abc' to='0.0.0.0'>";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 -----
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 testers = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 dofile "servers/ejabberd.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 dofile "servers/google_talk.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 dofile "servers/isode_mlink.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 dofile "servers/jabberd14.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 dofile "servers/jabberd2.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 dofile "servers/prosody.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 dofile "servers/tigase.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 dofile "servers/djabberd.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 dofile "servers/openfire.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 dofile "servers/jabber_xcp.lua"
7
015150645930 Add definition for Coversant Soapbox
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
133 dofile "servers/soapbox.lua"
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 function test_fingerprint(server)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 local tester = testers[server];
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 local env = setmetatable({server_comments = {}}, { __index = _G });
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 setfenv(tester, env);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 local ok, err = pcall(tester);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 if not ok then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 print("Error while testing for "..server..": "..err);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 return env;
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 ------------------------------------------------------------------
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 local results = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 for server in pairs(testers) do
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 local res = test_fingerprint(server);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 if res.server_name then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 table.insert(results, res);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 if #results > 1 then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 print("Note... multiple matches, could be any:");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 for _, result in ipairs(results) do
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 io.write(result.server_name);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 if result.server_min_version then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 io.write(", version "..result.server_min_version.." or later");
11
c77c5ac57156 xmpp-fingerprint.lua: Support for 'server_version' in addition to 'server_min_version'
Matthew Wild <mwild1@gmail.com>
parents: 7
diff changeset
164 elseif result.server_version then
13
9331253c2f83 xmpp-fingerprint.lua: Whitespace fix
Matthew Wild <mwild1@gmail.com>
parents: 11
diff changeset
165 io.write(", version "..result.server_version);
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 io.write("\n");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 if #result.server_comments > 0 then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 print(" Notes:\n", table.concat(result.server_comments, "\n "));
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 end

mercurial