mirror of
https://github.com/Monibuca/plugin-webrtc.git
synced 2025-10-05 06:46:57 +08:00
👌 IMPROVE:增加对端口监听的判断
This commit is contained in:
11
main.go
11
main.go
@@ -2,12 +2,14 @@ package webrtc
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"m7s.live/engine/v4"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"m7s.live/engine/v4"
|
||||
|
||||
"github.com/pion/interceptor"
|
||||
|
||||
. "github.com/pion/webrtc/v3"
|
||||
@@ -77,11 +79,14 @@ func (conf *WebRTCConfig) OnEvent(event any) {
|
||||
// 是否多路复用UDP端口
|
||||
if conf.InvitePortFixed {
|
||||
// 创建共享WEBRTC端口 默认9000
|
||||
udpListener, _ := net.ListenUDP("udp", &net.UDPAddr{
|
||||
udpListener, err := net.ListenUDP("udp", &net.UDPAddr{
|
||||
IP: net.IP{0, 0, 0, 0},
|
||||
Port: conf.IceUdpMux,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
plugin.Fatal("webrtc listener udp", zap.Error(err))
|
||||
}
|
||||
plugin.Info("webrtc start listen", zap.Int("port", conf.IceUdpMux))
|
||||
conf.s.SetICEUDPMux(NewICEUDPMux(nil, udpListener))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user