Skip to main content

A network protocol dependancy. Objects & Procedures.

Project description

Client - Vault - Guard: Core

This is the core tooling for a network/data sharing protocol.
Main functionality is for wrapping a socket.


  • It can encrypt a socket connection with ECDH-SECP521R1 -> AES256.

    • If the server has encryption enabled but the client doesn't it will-
      Force the client to enable encryption before continuing the connection.

    • If the server has encryption disabled and the client does it will-
      Force the client to disable encryption before continuing the connection
      I'm probably not going to leave this as a 'feature' for obvious reasons


How do you use it?

Here are some brief examples on establishing a connection using cvg-core.

from time import sleep
from threading import Thread

from socket import socket, AF_INET, SOCK_STREAM

from cvg_core.proper_procedures import SendReceiveProcedures
from cvg_core.procedures.establish_connection import establish_connection

from cvg_core.objects.network_object.packet_object import PacketType, PacketObject
from cvg_core.objects.network_object.connection_object import ConnectionType, ConnectionObject

# [Shared]
password = None # or b"bytes"

# [Client Implementation]
def client_example():
    client_connection = ConnectionObject(
        address=("127.0.0.1", 5000),
        socket=socket(AF_INET, SOCK_STREAM),
        type=ConnectionType.CLIENT_TO_SERVER,
        encryption_enabled=True
    )

    client_connection.socket.connect(
        client_connection.address
    )

    establish_connection(client_connection, password)

    client_procedures = SendReceiveProcedures(client_connection)

    # At this point it's up to on what you want to do.
    command_result_a = client_procedures.send_and_receive(
        PacketObject(b"hello", PacketType.COMMAND, id=b"\x03"),
        PacketType.RESPONSE
    )

    command_result_b = client_procedures.send_and_receive(
        PacketObject(b"hello", PacketType.COMMAND, id=b"\x03"),
        PacketType.RESPONSE
    )

    sleep(0.1) # sometimes the prints stack on each other.

    print("[client] command result a:", command_result_a)
    print("[client] command result b:", command_result_b)


# [Server Implementation]
def server_example():
    server_socket = socket(AF_INET, SOCK_STREAM)
    server_socket.bind(("127.0.0.1", 5000))
    server_socket.listen(1)

    client_connection = ConnectionObject(
        *server_socket.accept(), 
        type=ConnectionType.SERVER_TO_CLIENT,
        encryption_enabled=True
    ) 
        
    establish_connection(client_connection, password)

    client_procedures = SendReceiveProcedures(client_connection)

    # At this point it's up to on what you want to do.

    # Function wrapping on receive.
    @client_procedures.receive_into_and_send(PacketType.COMMAND)
    def command(packet: PacketObject):
        print("[server] client command received", packet)
        
        if packet.payload.startswith(b"hello"):
            return PacketObject(b"world_a", PacketType.RESPONSE, packet.id)

    # Or send a premade packet upon receive.
    command_packet = client_procedures.receive_and_send(
        PacketObject(b"world_b", PacketType.RESPONSE),
        PacketType.COMMAND
    )
    
    print("[server] client command received", command_packet)


Thread(target=server_example).start()
sleep(1)
client_example()

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

cvg_core-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

cvg_core-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file cvg_core-0.1.0.tar.gz.

File metadata

  • Download URL: cvg_core-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for cvg_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 325c291f804034527099833b09331a4a3c57e04b3a25c3feb113f8f4efac4b7f
MD5 98d8222b106cff27f6a3852a0a7f5529
BLAKE2b-256 114988201745eea57a47385f5f62a6e7557ae78eddffed76c32ad6ce27fcb360

See more details on using hashes here.

File details

Details for the file cvg_core-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cvg_core-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for cvg_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a00fc570999b0b7ca10b5499c0de2d52c1bfbc453d70916fc2f471c68f1309b5
MD5 357ecbdcb625605fd5b84167f541a5a6
BLAKE2b-256 daa0d08fba090fdc6b0ce64864e0d85dc951e8810a311ba325f013bb3f4b41c4

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