xmpp-fingerprint.lua

Fri, 10 Aug 2012 13:03:06 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 10 Aug 2012 13:03:06 +0100
changeset 16
872dc69f6039
parent 15
1b59ba3e9508
permissions
-rwxr-xr-x

Add Facebook fingerprints (and move test for FBv1 from the ejabberd fingerprint)

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;
15
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
98 if received ~= "" then
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
99 debug("<<", received);
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
100 else
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
101 debug("!!", tostring(err));
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
102 end
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 end
15
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
104 if received == "" then
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
105 return answer == false
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
106 elseif answer then
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
107 return received:match(answer);
1b59ba3e9508 Better handling of timeouts (or other errors), and allow matching errors with false
Matthew Wild <mwild1@gmail.com>
parents: 13
diff changeset
108 end
0
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 test(question, answer)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 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
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 function server_comment(comment)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 table.insert(getfenv(2).server_comments, comment);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 function literal(s)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 return s:gsub("%p", "%%%1");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 end
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 -----
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 q_invalid_xml = "abc\n";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 q_empty_message_tag = "<message/>";
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 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
127 -----
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 testers = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 dofile "servers/ejabberd.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 dofile "servers/google_talk.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 dofile "servers/isode_mlink.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 dofile "servers/jabberd14.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 dofile "servers/jabberd2.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 dofile "servers/prosody.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 dofile "servers/tigase.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 dofile "servers/djabberd.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 dofile "servers/openfire.lua"
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 dofile "servers/jabber_xcp.lua"
7
015150645930 Add definition for Coversant Soapbox
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
141 dofile "servers/soapbox.lua"
16
872dc69f6039 Add Facebook fingerprints (and move test for FBv1 from the ejabberd fingerprint)
Matthew Wild <mwild1@gmail.com>
parents: 15
diff changeset
142 dofile "servers/facebook.lua"
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 function test_fingerprint(server)
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 local tester = testers[server];
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 local env = setmetatable({server_comments = {}}, { __index = _G });
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 setfenv(tester, env);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 local ok, err = pcall(tester);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 if not ok then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 print("Error while testing for "..server..": "..err);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 return env;
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
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
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 local results = {};
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 for server in pairs(testers) do
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 local res = test_fingerprint(server);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 if res.server_name then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 table.insert(results, res);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 if #results > 1 then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 print("Note... multiple matches, could be any:");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 for _, result in ipairs(results) do
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 io.write(result.server_name);
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 if result.server_min_version then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 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
173 elseif result.server_version then
13
9331253c2f83 xmpp-fingerprint.lua: Whitespace fix
Matthew Wild <mwild1@gmail.com>
parents: 11
diff changeset
174 io.write(", version "..result.server_version);
0
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 io.write("\n");
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 if #result.server_comments > 0 then
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 print(" Notes:\n", table.concat(result.server_comments, "\n "));
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 end
ba1cc6ad649d Initial commit (dedicated to darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 end

mercurial