__init__.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. # -*- coding: utf-8 -*-
  2. """
  3. Trixy Netzwerk-Protokoll und Kommunikation.
  4. Bietet:
  5. - Protocol: Binärprotokoll für Trixy-Kommunikation
  6. - Encryption: AES-256-GCM Verschlüsselung
  7. - Security: Whitelist/Blacklist, Rate-Limiting, DDoS-Schutz
  8. - TLS: Zertifikatsverwaltung und sichere Verbindungen
  9. - Pool: Connection-Pooling für effiziente Verbindungen
  10. - Retry: Robuste Retry-Strategien mit Backoff
  11. - KeepAlive: Verbindungsüberwachung mit Ping/Pong
  12. - Compression: Datenkomprimierung für Übertragung
  13. - RPC: Request-Response Korrelation
  14. - Service: TCP-Server für Server-seitige Kommunikation
  15. - ClientConnection: Client-seitige Verbindung zum Server
  16. - MessageHandler: Nachrichtenverarbeitung und Event-Bridge
  17. """
  18. # Core Protocol
  19. from trixy_core.network.protocol import TrixyProtocol, ProtocolFlags, ProtocolMessage
  20. from trixy_core.network.encryption import TrixyEncryption
  21. # Transport Layer
  22. from trixy_core.network.service import NetworkService, ClientHandler, AudioStreamHandler
  23. from trixy_core.network.client_connection import ClientConnection, ConnectionConfig, get_mac_address
  24. from trixy_core.network.message_handler import (
  25. MessageHandler,
  26. EventBridge,
  27. setup_default_event_bridge,
  28. DEFAULT_EVENT_MAPPINGS,
  29. )
  30. # Retry
  31. from trixy_core.network.retry import (
  32. NetworkRetry,
  33. RetryConfig,
  34. RetryStrategy,
  35. RetryStats,
  36. RetryContext,
  37. RetryPolicy,
  38. RetryableError,
  39. NonRetryableError,
  40. with_retry,
  41. AGGRESSIVE_RETRY,
  42. CONSERVATIVE_RETRY,
  43. FAST_FAIL_RETRY,
  44. )
  45. # KeepAlive
  46. from trixy_core.network.keepalive import (
  47. KeepAliveManager,
  48. KeepAliveSession,
  49. KeepAliveConfig,
  50. ConnectionStats as KeepAliveStats,
  51. ConnectionState as KeepAliveState,
  52. )
  53. # Compression
  54. from trixy_core.network.compression import (
  55. Compressor,
  56. CompressionLevel,
  57. CompressionStats,
  58. ZlibCompressor,
  59. CompressionRegistry,
  60. get_default_registry as get_compression_registry,
  61. get_compressor,
  62. )
  63. # RPC
  64. from trixy_core.network.rpc import (
  65. CorrelationManager,
  66. CorrelationConfig,
  67. PendingRequest,
  68. RequestState,
  69. )
  70. # Security
  71. from trixy_core.network.security import (
  72. # Access Control
  73. AccessController,
  74. AccessRule,
  75. AccessDecision,
  76. IPMatcher,
  77. CIDRMatcher,
  78. MACMatcher,
  79. # Rate Limiting
  80. ConnectionRateLimiter,
  81. RateLimitConfig,
  82. RateLimitResult,
  83. IPRateLimiter,
  84. GlobalRateLimiter,
  85. # DDoS Protection
  86. DDoSProtection,
  87. DDoSConfig,
  88. ThreatLevel,
  89. ConnectionTracker,
  90. SuspiciousActivityDetector,
  91. )
  92. # TLS
  93. from trixy_core.network.tls import (
  94. TLSConfig,
  95. TLSVersion,
  96. CipherSuite,
  97. TLSManager,
  98. CertificateInfo,
  99. CertificateGenerator,
  100. CertificateRequest,
  101. KeyType,
  102. )
  103. # Connection Pool
  104. from trixy_core.network.pool import (
  105. Connection,
  106. ConnectionState,
  107. ConnectionInfo,
  108. ConnectionPool,
  109. PoolConfig,
  110. PoolStatistics,
  111. HealthChecker,
  112. HealthCheckConfig,
  113. HealthStatus,
  114. )
  115. __all__ = [
  116. # Core Protocol
  117. "TrixyProtocol",
  118. "ProtocolFlags",
  119. "ProtocolMessage",
  120. "TrixyEncryption",
  121. # Transport Layer
  122. "NetworkService",
  123. "ClientHandler",
  124. "AudioStreamHandler",
  125. "ClientConnection",
  126. "ConnectionConfig",
  127. "get_mac_address",
  128. "MessageHandler",
  129. "EventBridge",
  130. "setup_default_event_bridge",
  131. "DEFAULT_EVENT_MAPPINGS",
  132. # Security - Access Control
  133. "AccessController",
  134. "AccessRule",
  135. "AccessDecision",
  136. "IPMatcher",
  137. "CIDRMatcher",
  138. "MACMatcher",
  139. # Security - Rate Limiting
  140. "ConnectionRateLimiter",
  141. "RateLimitConfig",
  142. "RateLimitResult",
  143. "IPRateLimiter",
  144. "GlobalRateLimiter",
  145. # Security - DDoS Protection
  146. "DDoSProtection",
  147. "DDoSConfig",
  148. "ThreatLevel",
  149. "ConnectionTracker",
  150. "SuspiciousActivityDetector",
  151. # TLS
  152. "TLSConfig",
  153. "TLSVersion",
  154. "CipherSuite",
  155. "TLSManager",
  156. "CertificateInfo",
  157. "CertificateGenerator",
  158. "CertificateRequest",
  159. "KeyType",
  160. # Connection Pool
  161. "Connection",
  162. "ConnectionState",
  163. "ConnectionInfo",
  164. "ConnectionPool",
  165. "PoolConfig",
  166. "PoolStatistics",
  167. "HealthChecker",
  168. "HealthCheckConfig",
  169. "HealthStatus",
  170. # Retry
  171. "NetworkRetry",
  172. "RetryConfig",
  173. "RetryStrategy",
  174. "RetryStats",
  175. "RetryContext",
  176. "RetryPolicy",
  177. "RetryableError",
  178. "NonRetryableError",
  179. "with_retry",
  180. "AGGRESSIVE_RETRY",
  181. "CONSERVATIVE_RETRY",
  182. "FAST_FAIL_RETRY",
  183. # KeepAlive
  184. "KeepAliveManager",
  185. "KeepAliveSession",
  186. "KeepAliveConfig",
  187. "KeepAliveStats",
  188. "KeepAliveState",
  189. # Compression
  190. "Compressor",
  191. "CompressionLevel",
  192. "CompressionStats",
  193. "ZlibCompressor",
  194. "CompressionRegistry",
  195. "get_compression_registry",
  196. "get_compressor",
  197. # RPC
  198. "CorrelationManager",
  199. "CorrelationConfig",
  200. "PendingRequest",
  201. "RequestState",
  202. ]