gortc / stun

Fast RFC 5389 STUN implementation in go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can not get LocalAddr in stun package

lluck42 opened this issue · comments

// Client simulates "connection" to STUN server.
type Client struct {
	rto         int64 // time.Duration
	a           ClientAgent
	c           Connection
	close       chan struct{}
	rtoRate     time.Duration
	maxAttempts int32
	closed      bool
	closeConn   bool // should call c.Close() while closing
	wg          sync.WaitGroup
	clock       Clock
	handler     Handler
	collector   Collector
	t           map[transactionID]*clientTransaction
	// mux guards closed and t
	mux sync.RWMutex
}

there the “c” is a small letter
and find not a func to get “conn“

Hi, thank you for reporting the issue.

Please use the NewClient function to pass your own connection instead, you'll have more control on it in that case.

I can add the Connection and LocalAddr helpers for client so this is not needed, but seems like it won't help in common use case. Please share how you want to use the obtained local address value so I can understand the context better.

Please take a look at cmd/stun-traversal example, that should help.

Also you can take a look at pion/webrtc project, it can handle NAT traversal automatically.