wgortc

package module
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: GPL-3.0 Imports: 9 Imported by: 1

README

wgortc (Wireguard Over Webrtc)

How to Use

replace conn.Bind with this. more details see example/main.go

	// local signaler hub
	hub := local.NewHub()
	// client signaler, you can impl a custom signaler by youself
	signaler := local.NewServer()
	hub.Register("client", signaler)
	bind := wgortc.NewBind(signaler)
	dev = device.NewDevice(tun, bind, device.NewLogger(loglevel, "client"))

Custom Signaler Server

implement the signaler.Channel interface

package signaler

import "github.com/pion/webrtc/v3"

type SDP = webrtc.SessionDescription

type Channel interface {
	Handshake(endpoint string, offer SDP) (answer *SDP, err error)
	Accept() (offerCh <-chan Session, err error)

	Close() error
}

type Session interface {
	Description() (offer SDP)
	Resolve(answer *SDP) (err error)
	Reject(err error)
}

如何建立连接

sequenceDiagram
    participant client
    participant server
    par first message packet
        client->>server: webrtc session description
    and
        client->>server: wireguard initiator message
    end
    Note over server,client: server wireguard check initiator
    critical check failed
        server--)client: close connection
    option check ok
        server->>client: webrtc session description
        server->>client: wiregaurd response initiator
    		server->>client: webrtc pair connect
    end
    Note over server,client: webrtc connected
    loop webrtc datachannel open
        server->client: wireguard exchange data
    end

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndpointImpl = errors.New("endpoint is not wgortc.Endpoint")

Functions

This section is empty.

Types

type Bind

type Bind struct {
	NewSettingEngine func() webrtc.SettingEngine

	signaler.Channel

	ICEServers []webrtc.ICEServer
	// contains filtered or unexported fields
}

func NewBind

func NewBind(signaler signaler.Channel) *Bind

func (*Bind) BatchSize

func (b *Bind) BatchSize() int

func (*Bind) Close

func (b *Bind) Close() (ierr error)

func (*Bind) NewPeerConnection

func (b *Bind) NewPeerConnection() (*webrtc.PeerConnection, error)

func (*Bind) Open

func (b *Bind) Open(port uint16) (fns []conn.ReceiveFunc, actualPort uint16, ierr error)

func (*Bind) ParseEndpoint

func (b *Bind) ParseEndpoint(s string) (ep conn.Endpoint, err error)

func (*Bind) Send

func (b *Bind) Send(bufs [][]byte, ep conn.Endpoint) (err error)

func (*Bind) SetMark

func (b *Bind) SetMark(mark uint32) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL