diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2022-03-11 16:54:12 +0100 |
---|---|---|
committer | Dimitri Staessens <dimitri@ouroboros.rocks> | 2022-03-11 16:54:12 +0100 |
commit | 114e3952a51ed51126207e77ac305e4f5665e9eb (patch) | |
tree | a0353f7fc03d5422abb8be97b198513256dd8148 /ouroboros | |
parent | 5974215c9864ca72945b553f5374dbc8ba9a191d (diff) | |
download | pyouroboros-114e3952a51ed51126207e77ac305e4f5665e9eb.tar.gz pyouroboros-114e3952a51ed51126207e77ac305e4f5665e9eb.zip |
Diffstat (limited to 'ouroboros')
-rw-r--r-- | ouroboros/dev.py | 13 | ||||
-rw-r--r-- | ouroboros/qos.py | 11 |
2 files changed, 14 insertions, 10 deletions
diff --git a/ouroboros/dev.py b/ouroboros/dev.py index 7d29624..e0b1488 100644 --- a/ouroboros/dev.py +++ b/ouroboros/dev.py @@ -19,15 +19,16 @@ # Foundation, Inc., http://www.fsf.org/about/contact/. # -from _ouroboros_cffi import ffi, lib import errno from enum import IntFlag + +from _ouroboros_cffi import ffi, lib from ouroboros.qos import * from ouroboros.qos import _qos_to_qosspec, _fl_to_timespec, _qosspec_to_qos, _timespec_to_fl # Some constants -MILLION = 1000 * 1000 -BILLION = 1000 * 1000 * 1000 +MILLION = 1000_1000 +BILLION = 1000_1000_1000 # ouroboros exceptions @@ -196,8 +197,8 @@ class Flow: if count is None: return lib.flow_write(self.__fd, ffi.from_buffer(buf), len(buf)) - else: - return lib.flow_write(self.__fd, ffi.from_buffer(buf), count) + + return lib.flow_write(self.__fd, ffi.from_buffer(buf), count) def writeline(self, ln: str) -> int: @@ -394,5 +395,3 @@ def flow_join(dst: str, f = Flow() f.join(dst, qos, timeo) return f - - diff --git a/ouroboros/qos.py b/ouroboros/qos.py index f437ee2..ccf2c7a 100644 --- a/ouroboros/qos.py +++ b/ouroboros/qos.py @@ -38,6 +38,7 @@ class QoSSpec: in_order: In-order delivery, enables FRCT, default 0 max_gap: Maximum interruption in ms, default MILLION cypher_s: Requested encryption strength in bits + timeout: Peer timeout (ms), default 120000 (2 minutes) """ def __init__(self, @@ -48,7 +49,8 @@ class QoSSpec: ber: int = MILLION, in_order: int = 0, max_gap: int = MILLION, - cypher_s: int = 0): + cypher_s: int = 0, + timeout: int = 120000): self.delay = delay self.bandwidth = bandwidth self.availability = availability @@ -57,6 +59,7 @@ class QoSSpec: self.in_order = in_order self.max_gap = max_gap self.cypher_s = cypher_s + self.timeout = timeout def _fl_to_timespec(timeo: float): @@ -93,7 +96,8 @@ def _qos_to_qosspec(qos: QoSSpec): qos.ber, qos.in_order, qos.max_gap, - qos.cypher_s]) + qos.cypher_s, + qos.timeout]) def _qosspec_to_qos(_qos) -> Optional[QoSSpec]: @@ -107,4 +111,5 @@ def _qosspec_to_qos(_qos) -> Optional[QoSSpec]: ber=_qos.ber, in_order=_qos.in_order, max_gap=_qos.max_gap, - cypher_s=_qos.cypher_s) + cypher_s=_qos.cypher_s, + timeout=_qos.timeout) |