UDP Transport: compress, encrypt and send any data reliably over unreliable UDP connections



UDP Transport

Go Report Card godoc License: MIT

Compresses, encrypts and transfers data between a sender and receiver using UDP protocol.

Features and Design Aims:

  • Avoid the overhead of establishing a TCP or TCP+TLS handshake.
  • Reliable transfer of data using an unreliable UDP connection.
  • Uses AES-256 symmetric cipher for encryption.
  • Uses zlib library for data compression.
  • No third-party dependencies. Only uses the standard library.
  • Readable, understandable code with explanatory comments.


    go get github.com/balacode/udpt

Hello World:

This demo runs a receiver using RunReceiver() which listens for incoming data, then sends a "Hello World" to the receiver using Sender.SendString().

package main

import (


func main() {
    // the encryption key shared by the sender and receiver
    var cryptoKey = []byte("aA2Xh41FiC4Wtj3e5b2LbytMdn6on7P0")
    // enable verbose logging (only done for demos/debugging)
    cfg := udpt.NewDebugConfig()
    // set-up and run the receiver
    const tag = "-------------> DEMO"
    fmt.Println(tag, "Running the receiver")
    var received string
    receiver := udpt.Receiver{
        Port:      1234,
        CryptoKey: cryptoKey,
        Config:    cfg,
        // receives fully-transferred data items sent to the receiver
        ReceiveData: func(name string, data []byte) error {
            received = string(data)
            div := strings.Repeat("##", 40)
            fmt.Println(tag, div)
            fmt.Println(tag, "You should see a 'Hello World!' message below:")
            fmt.Println(tag, div)
            fmt.Println(tag, "Receiver's ReceiveData received",
                "name:", name, "data:", received)
            fmt.Println(tag, div)
            return nil
        // provides existing data items for hashing by the Receiver. Only the
        // hash will be sent back to the sender, to confirm the transfer.
        ProvideData: func(name string) ([]byte, error) {
            fmt.Println(tag, "Receiver's ProvideData()")
            return []byte(received), nil
    go func() { _ = receiver.Run() }()
    // send a message to the receiver
    time.Sleep(1 * time.Second)
    fmt.Println(tag, "Sending a message")
    sender := udpt.Sender{
        Address: "", Port: 1234, CryptoKey: cryptoKey, Config: cfg,
    err := sender.SendString("demo_data", "Hello World!")
    if err != nil {
        fmt.Println(tag, "failed sending:", err)
    wait := 2 * time.Second
    fmt.Println(tag, "Waiting", wait, "before exiting")
} //                                                                        main

Security Notice:

This is a new project and its use of cryptography has not been reviewed by experts. While I make use of established crypto algorithms available in the standard Go library and would not "roll my own" encryption, there may be weaknesses in my application of the algorithms. Please use caution and do your own security asessment of the code. At present, this library uses AES-256 in Galois Counter Mode to encrypt each packet of data, including its headers, and SHA-256 for hashing binary resources that are being transferred.

Version History:

This project is in its DRAFT stage: very unstable. At this point it works, but the API may change rapidly.


  • Write unit tests
  • Create a drop-in replacement for TCP and TLS connections
  • Implement some form of transfer control
  • Improve performance
  • Allow multiple Senders and Receivers that use different Address and Port values.
Ali Bala
Ali Bala
Send network packets over a TCP or UDP connection.

Packet is the main class representing a single network message. It has a byte code indicating the type of the message and a []byte type payload.

Aero 69 May 22, 2022
a go mini version TCP top on UDP for game connections or others.

sanhua sanhua(三花猫) is kind of cat with black, red and white color. This is a mini version TCP top on UDP, but with out resend lost packet. As we know.

Arion 1 May 31, 2022
Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp conne

许嘉华 3 May 27, 2021
Maidenhead - This golang library compress and decompress latitude and longitude coordinates into Maidenhead locator

The Maidenhead Locator System (a.k.a. QTH Locator and IARU Locator) is a geocode system used by amateur radio operators to succinctly describe their geographic coordinates.

Alessandro Lucaferro 2 Jan 30, 2022
Golang pow implementation client <-> server over UDP and TCP protocols

Client <-> server over UDP and TCP pow protocol Denial-of-Service-attacks are a typical situation when providing services over a network. A method for

Nikita Kryuchkov 0 Jan 13, 2022
Automatically compress podcasts to tiny file sizes for bandwidth constrained devices like cellular.

tinycast Automatically compress podcasts to tiny file sizes for bandwidth constrained connections like cellular or satellite.

Stephen Holiday 4 Jan 15, 2022
ScriptTiger 14 Jun 26, 2022
Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH.

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network.

Jaime Pillora 7.4k Jun 29, 2022
Transport to allow go-libp2p applications to natively use i2p for communication

I2P Transport for go-libp2p This library can be used to build go-libp2p applications using the i2p network. Look at transport_test.go for example usag

null 2 Jun 15, 2022
meek is a blocking-resistant pluggable transport for Tor.

meek is a blocking-resistant pluggable transport for Tor. It encodes a data stream as a sequence of HTTPS requests and responses. Requests are reflect

Clair de Lune 1 Nov 9, 2021
TCP output for beats to send events over TCP socket.

beats-tcp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

ichx 1 May 20, 2022
The devs are over here at devzat, chat over SSH!

Devzat Where are the devs at? Devzat! Devzat is chat over SSH Try it out: ssh sshchat.hackclub.com Add this to ~/.ssh/config: Host chat HostName s

Ishan Goel 1.3k Jun 27, 2022
Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

_______ _____ _____ _______ _____ __ _ ______ _______ ______ |______ | __| | | |______ | | \ | | \ |______ |_____/

RE43P3R 2 Mar 22, 2022
gproxy is a tiny service/library for creating lets-encrypt/acme secured gRPC and http reverse proxies

gproxy is a reverse proxy service AND library for creating flexible, expression-based, lets-encrypt/acme secured gRPC/http reverse proxies GProxy as a

null 15 Mar 25, 2022
A little library for turning TCP connections into go channels.

netutils By Tim Henderson ([email protected]) This is a little library that was part of a larger project that I decided to pull out and make public.

Tim Henderson 11 Aug 13, 2020
handling 1M websockets connections in Go

Going Infinite, handling 1M websockets connections in Go This repository holds the complete implementation of the examples seen in Gophercon Israel ta

Eran Yanay 5.1k Jun 19, 2022
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.

rconn (r[everse] conn[ection]) is a multiplatform program for creating reverse connections. It lets you consume services that are behind NAT and/or fi

Hikmat Jafarli 230 Jun 20, 2022