mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 07:20:18 +00:00
Added link accept option to API
This commit is contained in:
parent
2685e043ea
commit
3c81f93d4a
@ -118,6 +118,8 @@ class Destination:
|
|||||||
if "." in app_name: raise ValueError("Dots can't be used in app names")
|
if "." in app_name: raise ValueError("Dots can't be used in app names")
|
||||||
if not type in Destination.types: raise ValueError("Unknown destination type")
|
if not type in Destination.types: raise ValueError("Unknown destination type")
|
||||||
if not direction in Destination.directions: raise ValueError("Unknown destination direction")
|
if not direction in Destination.directions: raise ValueError("Unknown destination direction")
|
||||||
|
|
||||||
|
self.accept_link_requests = True
|
||||||
self.callbacks = Callbacks()
|
self.callbacks = Callbacks()
|
||||||
self.request_handlers = {}
|
self.request_handlers = {}
|
||||||
self.type = type
|
self.type = type
|
||||||
@ -197,6 +199,20 @@ class Destination:
|
|||||||
|
|
||||||
RNS.Packet(self, announce_data, RNS.Packet.ANNOUNCE, context = announce_context).send()
|
RNS.Packet(self, announce_data, RNS.Packet.ANNOUNCE, context = announce_context).send()
|
||||||
|
|
||||||
|
def accepts_links(self, accepts = None):
|
||||||
|
"""
|
||||||
|
Set or query whether the destination accepts incoming link requests.
|
||||||
|
|
||||||
|
:param accepts: If ``True`` or ``False``, this method sets whether the destination accepts incoming link requests. If not provided or ``None``, the method returns whether the destination currently accepts link requests.
|
||||||
|
:returns: ``True`` or ``False`` depending on whether the destination accepts incoming link requests, if the *accepts* parameter is not provided or ``None``.
|
||||||
|
"""
|
||||||
|
if accepts == None:
|
||||||
|
return self.accept_link_requests
|
||||||
|
|
||||||
|
if accepts:
|
||||||
|
self.accept_link_requests = True
|
||||||
|
else:
|
||||||
|
self.accept_link_requests = False
|
||||||
|
|
||||||
def set_link_established_callback(self, callback):
|
def set_link_established_callback(self, callback):
|
||||||
"""
|
"""
|
||||||
@ -292,6 +308,7 @@ class Destination:
|
|||||||
|
|
||||||
|
|
||||||
def incoming_link_request(self, data, packet):
|
def incoming_link_request(self, data, packet):
|
||||||
|
if self.accept_link_requests:
|
||||||
link = RNS.Link.validate_request(self, data, packet)
|
link = RNS.Link.validate_request(self, data, packet)
|
||||||
if link != None:
|
if link != None:
|
||||||
self.links.append(link)
|
self.links.append(link)
|
||||||
|
Loading…
Reference in New Issue
Block a user