This NetStructer provides classes for implementing secure communication between client and server applications over TCP/IP using encryption. It includes the Bridge class, which represents the communication bridge between client and server, as well as utility classes for encryption, error handling, and session management.
Project description
First, i made this module to earn some money to change my 4Gram Pc so if you can support us on https://www.buymeacoffee.com/Arcade.m7 , if you can't np enjoy.
The module facilitates secure communication between client and server applications over TCP/IP by providing classes and utilities for encryption, data transmission, error handling, and session management.
The central component of the module is the Bridge class, which acts as a communication bridge between the client and server. It handles encryption and decryption of data sent over the network to ensure secure transmission. The Bridge class also provides methods for sending and receiving data buffers between client and server.
Encryption is handled by the _encryption class, which uses the Fernet encryption scheme from the cryptography library. It provides methods for encrypting and decrypting data using a specified encryption key.
Error handling is implemented through the Error class, which defines custom error types for handling server initialization errors and buffer data errors.
The module also includes a Server class for creating and managing server instances. The Server class initializes a socket server, listens for incoming connections, and handles communication sessions with client applications.
Additionally, the Container class offers a convenient interface for managing session data. It provides methods for storing, retrieving, and clearing session data associated with client connections.
Overall, this module offers a comprehensive solution for implementing secure client-server communication over TCP/IP, with features for encryption, error handling, and session management.
here a simple code of NetStructer
Client Side
from NetStructer import Bridge
addr = ('192.168.1.5',5000) # addr of the server thats you want to connect
bridge = Bridge.Link(addr)
bridge.SendBuffer(['hi im haytam',128,{b'gg':'gg'},{1,2,6,4},(False,True)])
Server Side
from NetStrcuter impor Server
addr = ('192.168.1.5',5000) # address
server = Server(addr)
server.init()
with server.listen() as container:
#container.count() return len of sessions
#container.all() return all of the sessions
#container.get(parm) return parm value from the container | Note parm var must be the ip of the session thats you want to get
#container.pop(parm) return the value of parm and remove the session from container
#contaienr.clear() close the sessions
session = container.get('192.168.1.4') #the ip of the session
buff = sessioin.RecvBuffer(size=1024*100,buffer_size=100000)# size like socket.recv(1024) default is 1024 | buffer_size it mean how mush well recv if the data biger then buffer_size well raise a Error.BufferDataError
print(buff) #['hi im haytam',128,{b'gg':'gg'},{1,2,6,4},(False,True)]
i well give you a ather example Server class
from NetStructer import Server , Bridge
addr = ('192.168.1.5',5000) # address
server = Server(addr)
server.init()
def func(socket,cont):
while True: # note cont object is a dict
try:
soc,addr = socket.accept()
cont[addr[0]] = Bridge(soc)
except:
pass
anther example
container = server.listen_on(func)# it well return a Container() object
sessions = []
def func(socket,_):
while True:
try:
soc , addr = socket.accept()
sessions.append(soc)
except : pass
server.listen_on(func)
print(sessions)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for NetStructer-1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d38980e4501d1de8a9c7397d7fee073f26ea0f6edaabe05edc31ed87920e42b |
|
MD5 | 71e079c1523ad0c8d5f30a07e8a023f7 |
|
BLAKE2b-256 | 416ced408d221ed89942f6baf88a688801ae459605212edb26ebff4cce92d8a4 |