Mercurial > prosody-hg
comparison core/s2smanager.lua @ 2420:6ccd36a95a81
s2smanager, hostmanager: Make dialback secrets per-host
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 03 Jan 2010 18:55:42 +0000 |
| parents | 00d985639a06 |
| children | 83773aed9437 |
comparison
equal
deleted
inserted
replaced
| 2419:00d985639a06 | 2420:6ccd36a95a81 |
|---|---|
| 39 local adns, dns = require "net.adns", require "net.dns"; | 39 local adns, dns = require "net.adns", require "net.dns"; |
| 40 local config = require "core.configmanager"; | 40 local config = require "core.configmanager"; |
| 41 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; | 41 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; |
| 42 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; | 42 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; |
| 43 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; | 43 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; |
| 44 local dialback_secret = config.get("*", "core", "dialback_secret") or uuid_gen(); | |
| 45 | 44 |
| 46 incoming_s2s = {}; | 45 incoming_s2s = {}; |
| 47 _G.prosody.incoming_s2s = incoming_s2s; | 46 _G.prosody.incoming_s2s = incoming_s2s; |
| 48 local incoming_s2s = incoming_s2s; | 47 local incoming_s2s = incoming_s2s; |
| 49 | 48 |
| 429 session.sends2s(format("<db:result from='%s' to='%s'>%s</db:result>", session.from_host, session.to_host, session.dialback_key)); | 428 session.sends2s(format("<db:result from='%s' to='%s'>%s</db:result>", session.from_host, session.to_host, session.dialback_key)); |
| 430 session.log("info", "sent dialback key on outgoing s2s stream"); | 429 session.log("info", "sent dialback key on outgoing s2s stream"); |
| 431 end | 430 end |
| 432 | 431 |
| 433 function generate_dialback(id, to, from) | 432 function generate_dialback(id, to, from) |
| 434 return sha256_hash(id..to..from..dialback_secret, true); | 433 return sha256_hash(id..to..from..hosts[from].dialback_secret, true); |
| 435 end | 434 end |
| 436 | 435 |
| 437 function verify_dialback(id, to, from, key) | 436 function verify_dialback(id, to, from, key) |
| 438 return key == generate_dialback(id, to, from); | 437 return key == generate_dialback(id, to, from); |
| 439 end | 438 end |
