dimples 0.5.2__tar.gz → 0.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dimples-0.5.2 → dimples-0.5.5}/PKG-INFO +1 -1
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/network/session.py +2 -2
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/terminal.py +8 -4
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/messenger.py +5 -5
- {dimples-0.5.2 → dimples-0.5.5}/dimples/edge/octopus.py +3 -3
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/emitter.py +3 -2
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/dispatcher.py +2 -4
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/packer.py +21 -15
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/processor.py +0 -4
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/push.py +4 -5
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/__init__.py +2 -2
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/cache.py +4 -3
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/PKG-INFO +1 -1
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/requires.txt +3 -3
- {dimples-0.5.2 → dimples-0.5.5}/setup.py +4 -4
- {dimples-0.5.2 → dimples-0.5.5}/README.md +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/archivist.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/checkpoint.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/commands.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/creator.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/group.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_invite.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_query.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_quit.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_reset.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/grp_resign.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/cpu/handshake.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/facebook.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/messenger.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/network/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/network/state.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/network/transition.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/packer.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/client/processor.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/anonymous.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/ans.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/archivist.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/btc.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/compatible.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/entity.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/meta.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/compat/network.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/dbi/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/dbi/account.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/dbi/message.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/dbi/session.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/facebook.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/packer.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/processer.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/ans.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/block.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/handshake.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/login.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/mute.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/protocol/report.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/register.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/common/session.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/gate.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/gatekeeper.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/mars.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/mtp.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/protocol/mars.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/protocol/ws.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/queue.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/seeker.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/session.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/conn/ws.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/account.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/base.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/document.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/group.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/group_history.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/group_keys.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/login.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/meta.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/private.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/station.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/dos/user.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/message.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/session.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_cipherkey.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_document.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_group.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_group_history.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_group_keys.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_login.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_message.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_meta.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_private.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_station.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/database/t_user.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/edge/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/edge/shared.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/edge/start.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/admin.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/builder.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/delegate.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/helper.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/manager.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/group/packer.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/register/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/register/base.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/register/ext.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/register/run.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/register/shared.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/archivist.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/ans.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/document.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/handshake.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/login.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/cpu/report.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/messenger.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/session.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/session_center.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/server/trace.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/station/__init__.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/station/handler.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/station/shared.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/station/start.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/config.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/dos.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/log.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples/utils/singleton.py +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/SOURCES.txt +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/entry_points.txt +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/dimples.egg-info/top_level.txt +0 -0
- {dimples-0.5.2 → dimples-0.5.5}/setup.cfg +0 -0
|
@@ -40,11 +40,11 @@ from typing import Optional, List
|
|
|
40
40
|
|
|
41
41
|
from dimsdk import Station
|
|
42
42
|
|
|
43
|
-
from startrek.fsm import Daemon
|
|
44
43
|
from startrek.fsm import Delegate as StateDelegate
|
|
45
44
|
from startrek import Docker, DockerStatus
|
|
46
45
|
from startrek import Arrival
|
|
47
46
|
|
|
47
|
+
from ...utils import Daemon
|
|
48
48
|
from ...common import SessionDBI
|
|
49
49
|
from ...conn import BaseSession
|
|
50
50
|
from ...conn import MTPStreamArrival
|
|
@@ -84,7 +84,7 @@ class ClientSession(BaseSession):
|
|
|
84
84
|
# state machine
|
|
85
85
|
self.__fsm = StateMachine(session=self)
|
|
86
86
|
# background thread to drive gate & hub processing
|
|
87
|
-
self.__daemon = Daemon(target=self
|
|
87
|
+
self.__daemon = Daemon(target=self)
|
|
88
88
|
|
|
89
89
|
@property
|
|
90
90
|
def station(self) -> Station:
|
|
@@ -30,12 +30,11 @@
|
|
|
30
30
|
Client
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
|
-
import threading
|
|
34
33
|
import time
|
|
35
34
|
|
|
36
35
|
from dimples import EntityType
|
|
37
36
|
|
|
38
|
-
from ..utils import Runner, Logging
|
|
37
|
+
from ..utils import Runner, Daemon, Logging
|
|
39
38
|
from ..utils import StateDelegate
|
|
40
39
|
|
|
41
40
|
from .network import ClientSession
|
|
@@ -59,6 +58,7 @@ class Terminal(Runner, DeviceMixin, Logging, StateDelegate):
|
|
|
59
58
|
self.__messenger = messenger
|
|
60
59
|
# default online time
|
|
61
60
|
self.__last_time = time.time()
|
|
61
|
+
self.__daemon = Daemon(target=self)
|
|
62
62
|
|
|
63
63
|
@property
|
|
64
64
|
def messenger(self) -> ClientMessenger:
|
|
@@ -74,8 +74,12 @@ class Terminal(Runner, DeviceMixin, Logging, StateDelegate):
|
|
|
74
74
|
return self.session.running
|
|
75
75
|
|
|
76
76
|
def start(self):
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
self.__daemon.start()
|
|
78
|
+
|
|
79
|
+
# Override
|
|
80
|
+
def stop(self):
|
|
81
|
+
self.__daemon.stop()
|
|
82
|
+
super().stop()
|
|
79
83
|
|
|
80
84
|
# Override
|
|
81
85
|
def setup(self):
|
|
@@ -41,7 +41,7 @@ from typing import Optional, Union, Tuple
|
|
|
41
41
|
from dimsdk import SymmetricKey
|
|
42
42
|
from dimsdk import ID
|
|
43
43
|
from dimsdk import Content, Envelope
|
|
44
|
-
from dimsdk import Command
|
|
44
|
+
from dimsdk import Command, DocumentCommand
|
|
45
45
|
from dimsdk import InstantMessage, SecureMessage, ReliableMessage
|
|
46
46
|
from dimsdk import EntityDelegate, CipherKeyDelegate
|
|
47
47
|
from dimsdk import Messenger, Packer, Processor
|
|
@@ -170,9 +170,9 @@ class CommonMessenger(Messenger, Transmitter, Logging, ABC):
|
|
|
170
170
|
|
|
171
171
|
# private
|
|
172
172
|
def _attach_visa_time(self, sender: ID, msg: InstantMessage) -> bool:
|
|
173
|
-
if isinstance(msg.content,
|
|
173
|
+
if isinstance(msg.content, DocumentCommand):
|
|
174
174
|
# no need to attach times for command
|
|
175
|
-
return
|
|
175
|
+
return True
|
|
176
176
|
doc = self.facebook.visa(identifier=sender)
|
|
177
177
|
if doc is None:
|
|
178
178
|
self.error(msg='failed to get visa document for sender: %s' % sender)
|
|
@@ -200,8 +200,8 @@ class CommonMessenger(Messenger, Transmitter, Logging, ABC):
|
|
|
200
200
|
# attach sender's document times
|
|
201
201
|
# for the receiver to check whether user info synchronized
|
|
202
202
|
ok = self._attach_visa_time(sender=sender, msg=msg)
|
|
203
|
-
|
|
204
|
-
'failed to attach document time: %s => %s' % (sender, msg.content)
|
|
203
|
+
if not ok:
|
|
204
|
+
self.warning(msg='failed to attach document time: %s => %s' % (sender, msg.content))
|
|
205
205
|
#
|
|
206
206
|
# 1. encrypt message
|
|
207
207
|
#
|
|
@@ -41,7 +41,7 @@ from dimsdk import ReliableMessage
|
|
|
41
41
|
from dimsdk import Station
|
|
42
42
|
|
|
43
43
|
from ..utils import Log, Logging
|
|
44
|
-
from ..utils import Runner
|
|
44
|
+
from ..utils import Runner, Daemon
|
|
45
45
|
from ..utils import get_msg_sig
|
|
46
46
|
from ..common import ProviderInfo
|
|
47
47
|
from ..common import MessageDBI, SessionDBI
|
|
@@ -67,6 +67,7 @@ class Octopus(Runner, Logging):
|
|
|
67
67
|
self.__outers: Set[Terminal] = set()
|
|
68
68
|
self.__outer_map = weakref.WeakValueDictionary()
|
|
69
69
|
self.__outer_lock = threading.Lock()
|
|
70
|
+
self.__daemon = Daemon(target=self, daemonic=False)
|
|
70
71
|
|
|
71
72
|
@property
|
|
72
73
|
def shared(self) -> GlobalVariable:
|
|
@@ -129,8 +130,7 @@ class Octopus(Runner, Logging):
|
|
|
129
130
|
return terminal
|
|
130
131
|
|
|
131
132
|
def start(self):
|
|
132
|
-
|
|
133
|
-
thread.start()
|
|
133
|
+
self.__daemon.start()
|
|
134
134
|
|
|
135
135
|
# Override
|
|
136
136
|
def stop(self):
|
|
@@ -97,7 +97,7 @@ class GroupEmitter(Logging):
|
|
|
97
97
|
def _attach_group_times(self, group: ID, msg: InstantMessage) -> bool:
|
|
98
98
|
if isinstance(msg.content, GroupCommand):
|
|
99
99
|
# no need to attach times for group command
|
|
100
|
-
return
|
|
100
|
+
return True
|
|
101
101
|
facebook = self.facebook
|
|
102
102
|
doc = facebook.bulletin(identifier=group)
|
|
103
103
|
if doc is None:
|
|
@@ -130,7 +130,8 @@ class GroupEmitter(Logging):
|
|
|
130
130
|
# attach group document & history times
|
|
131
131
|
# for the receiver to check whether group info synchronized
|
|
132
132
|
ok = self._attach_group_times(group=group, msg=msg)
|
|
133
|
-
|
|
133
|
+
if not ok:
|
|
134
|
+
self.warning(msg='failed to attach group times: %s => %s' % (group, content))
|
|
134
135
|
# TODO: if it's a file message
|
|
135
136
|
# please upload the file data first
|
|
136
137
|
# before calling this
|
|
@@ -34,13 +34,11 @@ import threading
|
|
|
34
34
|
from abc import ABC, abstractmethod
|
|
35
35
|
from typing import Optional, List
|
|
36
36
|
|
|
37
|
-
from startrek.fsm import Daemon
|
|
38
|
-
|
|
39
37
|
from dimsdk import EntityType, ID
|
|
40
38
|
from dimsdk import Content, ReceiptCommand
|
|
41
39
|
from dimsdk import ReliableMessage
|
|
42
40
|
|
|
43
|
-
from ..utils import Singleton, Logging, Runner
|
|
41
|
+
from ..utils import Singleton, Logging, Runner, Daemon
|
|
44
42
|
from ..common import CommonFacebook
|
|
45
43
|
from ..common import MessageDBI, SessionDBI
|
|
46
44
|
from ..common import ReliableMessageDBI
|
|
@@ -211,7 +209,7 @@ class Roamer(Runner, Logging):
|
|
|
211
209
|
# roaming (user id => station id)
|
|
212
210
|
self.__queue: List[RoamingInfo] = []
|
|
213
211
|
self.__lock = threading.Lock()
|
|
214
|
-
self.__daemon = Daemon(target=self
|
|
212
|
+
self.__daemon = Daemon(target=self)
|
|
215
213
|
|
|
216
214
|
@property
|
|
217
215
|
def database(self) -> Optional[MessageDBI]:
|
|
@@ -76,23 +76,29 @@ class ServerMessagePacker(CommonMessagePacker):
|
|
|
76
76
|
# TODO: trusted station list
|
|
77
77
|
return True
|
|
78
78
|
|
|
79
|
+
# Override
|
|
80
|
+
def deserialize_message(self, data: bytes) -> Optional[ReliableMessage]:
|
|
81
|
+
msg = super().deserialize_message(data=data)
|
|
82
|
+
if msg is not None:
|
|
83
|
+
sender = msg.sender
|
|
84
|
+
receiver = msg.receiver
|
|
85
|
+
# check duplicated
|
|
86
|
+
if self.__is_traced(msg=msg):
|
|
87
|
+
# cycled message
|
|
88
|
+
if sender.type == EntityType.STATION or receiver.type == EntityType.STATION:
|
|
89
|
+
# ignore cycled station message
|
|
90
|
+
self.warning(msg='drop cycled station message: %s -> %s' % (sender, receiver))
|
|
91
|
+
return None
|
|
92
|
+
elif receiver.is_broadcast:
|
|
93
|
+
# ignore cycled broadcast message
|
|
94
|
+
self.warning(msg='drop cycled broadcast message: %s -> %s' % (sender, receiver))
|
|
95
|
+
return None
|
|
96
|
+
self.warning(msg='cycled message: %s -> %s' % (sender, receiver))
|
|
97
|
+
return msg
|
|
98
|
+
|
|
79
99
|
# Override
|
|
80
100
|
def verify_message(self, msg: ReliableMessage) -> Optional[SecureMessage]:
|
|
81
|
-
|
|
82
|
-
receiver = msg.receiver
|
|
83
|
-
# check duplicated
|
|
84
|
-
if self.__is_traced(msg=msg):
|
|
85
|
-
# cycled message
|
|
86
|
-
if sender.type == EntityType.STATION or receiver.type == EntityType.STATION:
|
|
87
|
-
# ignore cycled station message
|
|
88
|
-
self.warning(msg='cycled station message: %s -> %s' % (sender, receiver))
|
|
89
|
-
return None
|
|
90
|
-
elif receiver.is_broadcast:
|
|
91
|
-
# ignore cycled broadcast message
|
|
92
|
-
self.warning(msg='cycled broadcast message: %s -> %s' % (sender, receiver))
|
|
93
|
-
return None
|
|
94
|
-
self.warning(msg='cycled message: %s -> %s' % (sender, receiver))
|
|
95
|
-
# check session
|
|
101
|
+
# check session ready
|
|
96
102
|
if self.__is_trusted(sender=msg.sender):
|
|
97
103
|
# no need to verify message from this sender
|
|
98
104
|
self.debug(msg='trusted sender: %s' % msg.sender)
|
|
@@ -41,7 +41,6 @@ from dimsdk import ContentProcessor, ContentProcessorCreator
|
|
|
41
41
|
|
|
42
42
|
from dimsdk.cpu import BaseContentProcessor, BaseContentProcessorCreator
|
|
43
43
|
|
|
44
|
-
from ..utils import get_msg_info
|
|
45
44
|
from ..common import HandshakeCommand, LoginCommand
|
|
46
45
|
from ..common import ReportCommand, AnsCommand
|
|
47
46
|
from ..common import CommonFacebook, CommonMessenger
|
|
@@ -165,9 +164,6 @@ class ServerMessageProcessor(CommonMessageProcessor):
|
|
|
165
164
|
# TODO: override to deliver to the receiver when catch exception "receiver error ..."
|
|
166
165
|
|
|
167
166
|
def _force_handshake(self, msg: ReliableMessage) -> List[ReliableMessage]:
|
|
168
|
-
if self.messenger.verify_message(msg=msg) is None:
|
|
169
|
-
assert False, 'failed to verify message: %s' % get_msg_info(msg=msg)
|
|
170
|
-
# return []
|
|
171
167
|
session = self.messenger.session
|
|
172
168
|
sess_id = session.identifier
|
|
173
169
|
current = self.facebook.current_user
|
|
@@ -36,10 +36,10 @@ import time
|
|
|
36
36
|
from abc import ABC, abstractmethod
|
|
37
37
|
from typing import Optional, List, Dict
|
|
38
38
|
|
|
39
|
-
from startrek.fsm import Daemon
|
|
40
39
|
from dimsdk import ID, ReliableMessage
|
|
41
40
|
|
|
42
|
-
from ..utils import
|
|
41
|
+
from ..utils import Runner, Daemon
|
|
42
|
+
from ..utils import Singleton, Logging
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
class MessageQueue(Logging):
|
|
@@ -125,9 +125,8 @@ class PushCenter(Runner, Logging):
|
|
|
125
125
|
self.__keeper = BadgeKeeper()
|
|
126
126
|
self.__service: Optional[PushService] = None
|
|
127
127
|
# background thread
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
self.__daemon = daemon
|
|
128
|
+
self.__daemon = Daemon(target=self)
|
|
129
|
+
self.__daemon.start()
|
|
131
130
|
|
|
132
131
|
@property
|
|
133
132
|
def service(self) -> Optional[PushService]:
|
|
@@ -50,7 +50,7 @@ from dimsdk import DocumentHelper
|
|
|
50
50
|
|
|
51
51
|
from dimplugins.crypto.aes import random_bytes
|
|
52
52
|
|
|
53
|
-
from startrek.fsm import Runnable, Runner
|
|
53
|
+
from startrek.fsm import Runnable, Runner, Daemon
|
|
54
54
|
from startrek.fsm import Delegate as StateDelegate
|
|
55
55
|
from startrek.net.channel import get_remote_address, get_local_address
|
|
56
56
|
|
|
@@ -122,7 +122,7 @@ __all__ = [
|
|
|
122
122
|
|
|
123
123
|
'Converter',
|
|
124
124
|
|
|
125
|
-
'Runnable', 'Runner',
|
|
125
|
+
'Runnable', 'Runner', 'Daemon',
|
|
126
126
|
'StateDelegate',
|
|
127
127
|
|
|
128
128
|
'get_remote_address', 'get_local_address',
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
import time
|
|
33
33
|
from typing import TypeVar, Generic, Optional, Dict, Set, Tuple
|
|
34
34
|
|
|
35
|
-
from startrek.fsm import Daemon
|
|
35
|
+
from startrek.fsm import Daemon, Runnable
|
|
36
36
|
from dimsdk import DateTime
|
|
37
37
|
|
|
38
38
|
from .singleton import Singleton
|
|
@@ -135,12 +135,12 @@ class CachePool(Generic[K, V]):
|
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
@Singleton
|
|
138
|
-
class CacheManager:
|
|
138
|
+
class CacheManager(Runnable):
|
|
139
139
|
|
|
140
140
|
def __init__(self):
|
|
141
141
|
self.__pools: Dict[str, CachePool] = {} # name -> pool
|
|
142
142
|
# thread for cleaning caches
|
|
143
|
-
self.__daemon = Daemon(target=self
|
|
143
|
+
self.__daemon = Daemon(target=self)
|
|
144
144
|
self.__running = False
|
|
145
145
|
|
|
146
146
|
@property
|
|
@@ -154,6 +154,7 @@ class CacheManager:
|
|
|
154
154
|
def stop(self):
|
|
155
155
|
self.__daemon.stop()
|
|
156
156
|
|
|
157
|
+
# Override
|
|
157
158
|
def run(self):
|
|
158
159
|
next_time = 0
|
|
159
160
|
while self.running:
|
|
@@ -14,7 +14,7 @@ import io
|
|
|
14
14
|
|
|
15
15
|
from setuptools import setup, find_packages
|
|
16
16
|
|
|
17
|
-
__version__ = '0.5.
|
|
17
|
+
__version__ = '0.5.5'
|
|
18
18
|
__author__ = 'Albert Moky'
|
|
19
19
|
__contact__ = 'albert.moky@gmail.com'
|
|
20
20
|
|
|
@@ -58,8 +58,8 @@ setup(
|
|
|
58
58
|
'dkd>=1.0.2',
|
|
59
59
|
'mkm>=1.0.2',
|
|
60
60
|
|
|
61
|
-
'startrek>=1.
|
|
62
|
-
'tcp>=1.
|
|
63
|
-
'udp>=1.
|
|
61
|
+
'startrek>=1.2.0',
|
|
62
|
+
'tcp>=1.2.0',
|
|
63
|
+
'udp>=1.2.0',
|
|
64
64
|
]
|
|
65
65
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|