stun

package
v0.19.13 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPort = 3478
View Source
var ErrStun = errors.New("lal.stun: fxxk")

Functions

func PackBindingRequest

func PackBindingRequest() ([]byte, error)

func PackBindingResponse

func PackBindingResponse(ip []byte, port int) ([]byte, error)

func PackHeaderTo

func PackHeaderTo(out []byte, typ int, length int) error

func UnpackResponseMessage

func UnpackResponseMessage(b []byte) (ip string, port int, err error)

Types

type Client

type Client struct {
}

func (*Client) Query

func (c *Client) Query(addr string, timeoutMS int) (ip string, port int, err error)

addr 填入server地址,如果不包含端口,则使用默认端口3478

type Header struct {
	Typ           int
	Length        int
	MagicCookie   int
	TransactionID []byte
}

func UnpackHeader

func UnpackHeader(b []byte) (h Header, err error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string) (*Server, error)

func (*Server) Dispose

func (s *Server) Dispose() error

func (*Server) RunLoop

func (s *Server) RunLoop() (err error)

Jump to

Keyboard shortcuts

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