mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Listeners must unwrap requests for the Santiago service.
- Contextualized a few error messages.
This commit is contained in:
parent
10e13aab56
commit
d9d0ef69ff
@ -1,8 +1,14 @@
|
|||||||
class SignatureError(Exception):
|
class SignatureError(Exception):
|
||||||
|
"""Base class for signature-related errors."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class InvalidSignatureError(SignatureError):
|
class InvalidSignatureError(SignatureError):
|
||||||
|
"""The signature in this message is cryptographically invalid."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UnwillingHostError(SignatureError):
|
class UnwillingHostError(SignatureError):
|
||||||
|
"""The current process isn't willing to host a service for the client."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -31,7 +31,10 @@ class Listener(SantiagoListener):
|
|||||||
def index(self, **kwargs):
|
def index(self, **kwargs):
|
||||||
"""Receive an incoming Santiago request from another Santiago client."""
|
"""Receive an incoming Santiago request from another Santiago client."""
|
||||||
|
|
||||||
self.incoming_request(**kwargs)
|
try:
|
||||||
|
self.incoming_request(kwargs["request"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def query(self, host, service):
|
def query(self, host, service):
|
||||||
|
|||||||
@ -256,7 +256,7 @@ class SimpleSantiago(object):
|
|||||||
protocol = destination.split(":")[0]
|
protocol = destination.split(":")[0]
|
||||||
self.senders[protocol].outgoing_request(request, destination)
|
self.senders[protocol].outgoing_request(request, destination)
|
||||||
|
|
||||||
def incoming_request(self, **kwargs):
|
def incoming_request(self, request):
|
||||||
"""Provide a service to a client.
|
"""Provide a service to a client.
|
||||||
|
|
||||||
This tag doesn't do any real processing, it just catches and hides
|
This tag doesn't do any real processing, it just catches and hides
|
||||||
@ -274,33 +274,33 @@ class SimpleSantiago(object):
|
|||||||
attacker knows that the last request brought down a system.
|
attacker knows that the last request brought down a system.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
logging.debug("Incoming request: ", str(kwargs))
|
logging.debug("Incoming request: ", str(request))
|
||||||
|
|
||||||
# no matter what happens, the sender will never hear about it.
|
# no matter what happens, the sender will never hear about it.
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
request = self.unpack_request(kwargs)
|
unpacked = self.unpack_request(request)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not request:
|
if not unpacked:
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.debug("Unpacked request: ", str(request))
|
logging.debug("Unpacked request: ", str(unpacked))
|
||||||
|
|
||||||
if request["locations"]:
|
if unpacked["locations"]:
|
||||||
self.handle_reply(request["from"], request["to"],
|
self.handle_reply(unpacked["from"], unpacked["to"],
|
||||||
request["host"], request["client"],
|
unpacked["host"], unpacked["client"],
|
||||||
request["service"], request["locations"],
|
unpacked["service"], unpacked["locations"],
|
||||||
request["reply_to"])
|
unpacked["reply_to"])
|
||||||
else:
|
else:
|
||||||
self.handle_request(request["from"], request["to"],
|
self.handle_request(unpacked["from"], unpacked["to"],
|
||||||
request["host"], request["client"],
|
unpacked["host"], unpacked["client"],
|
||||||
request["service"], request["reply_to"])
|
unpacked["service"], unpacked["reply_to"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception("Error: ", str(e))
|
logging.exception("Error: ", str(e))
|
||||||
|
|
||||||
def unpack_request(self, kwargs):
|
def unpack_request(self, request):
|
||||||
"""Decrypt and verify the request.
|
"""Decrypt and verify the request.
|
||||||
|
|
||||||
Raise an (unhandled?) error if there're any inconsistencies in the
|
Raise an (unhandled?) error if there're any inconsistencies in the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user