Skip to main content

Librería Python para servidores y clientes TCP/UDP con cifrado híbrido, chunks y transferencia de archivos.

Project description

FastSocket

FastSocket es una librería Python para construir servidores y clientes TCP y UDP con manejo de múltiples conexiones, cifrado opcional, transferencia por chunks y soporte de archivos. La API está pensada para ser mínima y rápida de usar.

Features

  • API simple para servidores y clientes TCP y UDP
  • Comunicación segura con cifrado RSA
  • Modo TLS Hybrid: intercambio de clave RSA-4096 + cifrado AES-256-GCM + autenticación HMAC
  • ChunkManager para dividir y reensamblar payloads grandes
  • FileTransfer con verificación de integridad (SHA-256)
  • Soporte UDP unicast y broadcast
  • Ejemplos, benchmarks y stress tests incluidos

Roadmap

  • Implementación con asyncio
  • Gestión automática de chunks en el protocolo base
  • Reconexión automática en clientes
  • Keep-alive configurable
  • Políticas de rate limiting
  • Serialización de mensajes (JSON, MessagePack)
  • Compresión de payloads (zlib / lz4)

Instalación

pip install FastSocket

Quickstart

Servidor TCP:

from FastSocket import FastSocketServer, SocketConfig, Queue

def handle_messages(messages: Queue):
    while not messages.empty():
        msg, addr = messages.get()
        print(f"[{addr}] {msg}")
        server.send_msg_stream(f"Echo: {msg}")

config = SocketConfig(host="localhost", port=8080)
server = FastSocketServer(config)
server.on_new_message(handle_messages)
server.start()

Cliente TCP:

from FastSocket import FastSocketClient, SocketConfig

def on_message(msg: str):
    print("Servidor:", msg)

client = FastSocketClient(SocketConfig(host="localhost", port=8080))
client.on_new_message(on_message)
client.start()
client.send_to_server("hola")

Modo TLS Hybrid

from FastSocket import TLSSocketServer, TLSSocketClient, SocketConfig

# Servidor
server = TLSSocketServer(SocketConfig(host="localhost", port=9443), shared_secret="secreto-fuerte")
server.on_new_message(lambda q: print(q.get()))
server.start()

# Cliente
client = TLSSocketClient(SocketConfig(host="localhost", port=9443), shared_secret="secreto-fuerte")
client.on_new_message(lambda msg: print(msg))
client.start()

UDP

from FastSocket import FastSocketUDPServer, SocketConfig
import socket

config = SocketConfig(host="0.0.0.0", port=9000, type=socket.SOCK_DGRAM)
server = FastSocketUDPServer(config, enable_broadcast=True)
server.start()

Documentación

Documentación completa en giulicrenna.github.io/FastSocket

Contribuir

Los pull requests son bienvenidos. Antes de enviar, asegurate de que los tests pasen y de seguir el estilo PEP 8.

Contacto

Autor: Giuliano Crenna
Email: giulicrenna@gmail.com

Licencia

Este proyecto está licenciado bajo GNU Affero General Public License v3.0 (AGPL-3.0). Ver el archivo LICENSE para más detalles.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastsocket-2.0.0.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastsocket-2.0.0-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file fastsocket-2.0.0.tar.gz.

File metadata

  • Download URL: fastsocket-2.0.0.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for fastsocket-2.0.0.tar.gz
Algorithm Hash digest
SHA256 efe5f5a1202c966dff369148f6142cf2fb0a77092bbecff94465cb4b3931ca87
MD5 4dbdcff491180f50093fbf8a654c26a9
BLAKE2b-256 71e1aa19cff8fd225979eadf2c447cdf987909a123eb1c18be6f51aaab3a71fe

See more details on using hashes here.

File details

Details for the file fastsocket-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: fastsocket-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for fastsocket-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2be9dd40d14ed9eba81f9daae64b72a6598b8af7ce7f8370e94265fca18833fb
MD5 0d3ee233ad966fd5c9ef83f67cc37416
BLAKE2b-256 0314cd9e5024064444f5f5126d742f8a824fe92973b55924e2f0958c27ee2f54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page