mirror of
https://github.com/netbirdio/ice-old.git
synced 2026-05-22 17:08:24 -07:00
Fix UDPMux logger
If no logger is passed in, it will be created. Error running webrtc/examples/ice-single-port : invalid memory address or nil pointer dereference
This commit is contained in:
@@ -64,6 +64,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
||||
* [Will Forcey](https://github.com/wawesomeNOGUI)
|
||||
* [David Zhao](https://github.com/davidzhao)
|
||||
* [Juliusz Chroboczek](https://github.com/jech)
|
||||
* [Jin Gong](https://github.com/cgojin)
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
||||
|
||||
@@ -47,6 +47,10 @@ type UDPMuxParams struct {
|
||||
|
||||
// NewUDPMuxDefault creates an implementation of UDPMux
|
||||
func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault {
|
||||
if params.Logger == nil {
|
||||
params.Logger = logging.NewDefaultLoggerFactory().NewLogger("ice")
|
||||
}
|
||||
|
||||
m := &UDPMuxDefault{
|
||||
addressMap: map[string]*udpMuxedConn{},
|
||||
params: params,
|
||||
|
||||
+1
-3
@@ -12,7 +12,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/logging"
|
||||
"github.com/pion/stun"
|
||||
"github.com/pion/transport/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -28,9 +27,8 @@ func TestUDPMux(t *testing.T) {
|
||||
conn, err := net.ListenUDP(udp, &net.UDPAddr{})
|
||||
require.NoError(t, err)
|
||||
|
||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||
udpMux := NewUDPMuxDefault(UDPMuxParams{
|
||||
Logger: loggerFactory.NewLogger("ice"),
|
||||
Logger: nil,
|
||||
UDPConn: conn,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user