Categorygithub.com/optman/rndz-go
repositorypackage
0.0.0-20240901065432-32470e316896
Repository: https://github.com/optman/rndz-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

rndz-go

A simple rendezvous protocol implementation to help NAT traversal or hole punching.

Golang implementation for rndz.

Table of Contents

Features

  • Simple and lightweight implementation
  • Supports both TCP and UDP protocols
  • Easy to integrate with existing Go projects

Installation

To install rndz-go, use go get:

go get github.com/optman/rndz-go

Usage

Here's how you can use rndz-go to perform NAT traversal or hole punching.

TCP

Client 1

import (
	"context"
	"net/netip"

	"github.com/optman/rndz-go/client/tcp"
)

func main() {
	rndzServer := "your-rendezvous-server"
	c := tcp.NewClient(rndzServer, "c1", netip.AddrPort{})
	defer c.Close()
	l, _ := c.Listen(context.Background())
	defer l.Close()
	for {
		conn, _ := l.Accept()
		defer conn.Close()
		// Handle connection
	}
}

Client 2

import (
	"context"
	"net/netip"

	"github.com/optman/rndz-go/client/tcp"
)

func main() {
	rndzServer := "your-rendezvous-server"
	c := tcp.NewClient(rndzServer, "c2", netip.AddrPort{})
	defer c.Close()
	conn, _ := c.Connect(context.Background(), "c1")
	defer conn.Close()
	// Use connection
}

UDP

import (
	"net/netip"

	"github.com/optman/rndz-go/client/udp"
)

func main() {
	rndzServer := "your-rendezvous-server"
	id := "your-client-id"
	c := udp.NewClient(rndzServer, id, netip.AddrPort{})
	// Use client
}

License

This project is licensed under the MIT License - see the LICENSE file for details.