Skip to main content

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)])
bridge.SendBuffer('support us on https://www.buymeacoffee.com/Arcade.m7')

Server Side

from NetStrcuter impor Server

addr = ('192.168.1.5',5000) # address

server = Server(addr)
server.init()
server.listen()

#server.count()  return len of sessions
#server.all()  return all of the sessions
#server.get(parm) return parm value from the container | Note parm var must be the ip of the session thats you want to get
#server.pop(parm) return the value of parm and remove the session from container
#server.clear()  close the sessions

session = server.get('192.168.1.4') #the ip of the session
buff = session.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)]
string = session.RecvBuffer()
print(string) #'support us on https://www.buymeacoffee.com/Arcade.m7'

i well give you an other example of 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
			
server.listen_on(func)

Server.listen_on function

sessions = []

def func(socket,_):
	while True:
			try:
				soc , addr = socket.accept()
				sessions.append(soc)
			except : pass
		
server.listen_on(func)

print(sessions)

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

NetStructer-2.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

NetStructer-2.4-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file NetStructer-2.4.tar.gz.

File metadata

  • Download URL: NetStructer-2.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for NetStructer-2.4.tar.gz
Algorithm Hash digest
SHA256 0234446c5b2b3a3f99e6677e6d2b998e09d549d23e6be1e57d0e1ec66bee3d33
MD5 4e6f6e82849310ec8d72e9fdb33bfa1d
BLAKE2b-256 4f3a04f47d0b0114f1aa8e91fcd729e831f9efb4b2348c3e3ff50821f686ca45

See more details on using hashes here.

File details

Details for the file NetStructer-2.4-py3-none-any.whl.

File metadata

  • Download URL: NetStructer-2.4-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for NetStructer-2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d54c1161e8acbdc4d2395aaefbb981f0664014c60744ab8684070709652a11f6
MD5 90757ae9f29f1f820442a1b16821cbcd
BLAKE2b-256 db5231ef188e0759a92b7b49056dc59af0d2495df77cb6fce88b09a33788eaaa

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