Skip to main content

Secure Reliable UDP

Project description

Secure Reliable UDP

This repository provides Secure Reliable Data Stream that works like TCP.
My purpose is enable users create P2P connection between clients in closed NAT.

Features

  • Pure Python
  • Usage like normal socket object
  • Protocol similar to RUDP
  • UDP hole punching
  • high performance (8Mbps/s Up&Down)
  • ipv4/ipv6

Requirement

Installation

pip3 install --user srudp

Demo

Prepare two independent PCs.

from srudp import SecureReliableSocket
from time import sleep, time
 
sock = SecureReliableSocket()
sock.connect(("<remote host 1>", 12345))
 
while not sock.is_closed:
    sock.sendall(b'hello ' + str(time()).encode())
    sleep(3)
print("closed", sock)

A side, send message hello once in a 3 sec.

from srudp import SecureReliableSocket
from time import time
 
sock = SecureReliableSocket()
sock.connect(("<remote host 2>", 12345))
 
while not sock.is_closed:
    data = sock.recv(1024)
    if not data:
        break
    print(time(), data)
print("closed", sock)

Another side, receive the message and show immediately.

Note: Why make this?

These days, PC is located in a local environment protected by NAT. It is difficult to transfer data between two outsides. In order to solve this problem, connection is realized by UDP hole punching without using UPnP.

UDP is a socket protocol with minimum functions for connecting applications. Therefore, there is no connection state, data may not be reachable, spoofing the source is easy. This is why, you cannot substitute it as TCP.

With this program, you can treat it just like TCP without worrying about the above problems. In other words, it has a connection state, guarantees data reachability, and is difficult to forge.

Links

Author

@namuyan

Licence

MIT

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

srudp-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file srudp-0.1.1.tar.gz.

File metadata

  • Download URL: srudp-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

File hashes

Hashes for srudp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68b37979ee8353423c03d2c487e024ea968886777c79bfa7509b4cbdfa3fe364
MD5 48229b7d665cfb22628d02a8e61ff811
BLAKE2b-256 7dec958389e07b9d7e738d4d7663fa6c0ddfee902ec029706b179be9bca1fc6e

See more details on using hashes here.

Supported by

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