mirror of
https://github.com/Monibuca/plugin-webrtc.git
synced 2025-10-05 23:06:55 +08:00
增加端口范围配置
This commit is contained in:
9
main.go
9
main.go
@@ -21,6 +21,8 @@ import (
|
|||||||
var config struct {
|
var config struct {
|
||||||
ICEServers []string
|
ICEServers []string
|
||||||
PublicIP []string
|
PublicIP []string
|
||||||
|
PortMin uint16
|
||||||
|
PortMax uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
// }{[]string{
|
// }{[]string{
|
||||||
@@ -176,6 +178,9 @@ func (rtc *WebRTC) Publish(streamPath string) bool {
|
|||||||
if !strings.HasPrefix(rtc.RemoteAddr, "127.0.0.1") && !strings.HasPrefix(rtc.RemoteAddr, "[::1]") {
|
if !strings.HasPrefix(rtc.RemoteAddr, "127.0.0.1") && !strings.HasPrefix(rtc.RemoteAddr, "[::1]") {
|
||||||
rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
|
rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
|
||||||
}
|
}
|
||||||
|
if config.PortMin > 0 && config.PortMax > 0 {
|
||||||
|
rtc.s.SetEphemeralUDPPortRange(config.PortMin, config.PortMax)
|
||||||
|
}
|
||||||
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
|
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
|
||||||
peerConnection, err := rtc.api.NewPeerConnection(Configuration{
|
peerConnection, err := rtc.api.NewPeerConnection(Configuration{
|
||||||
ICEServers: []ICEServer{
|
ICEServers: []ICEServer{
|
||||||
@@ -271,6 +276,7 @@ func run() {
|
|||||||
streamPath := r.URL.Query().Get("streamPath")
|
streamPath := r.URL.Query().Get("streamPath")
|
||||||
var offer SessionDescription
|
var offer SessionDescription
|
||||||
var rtc WebRTC
|
var rtc WebRTC
|
||||||
|
|
||||||
bytes, err := ioutil.ReadAll(r.Body)
|
bytes, err := ioutil.ReadAll(r.Body)
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -305,6 +311,9 @@ func run() {
|
|||||||
if !strings.HasPrefix(r.RemoteAddr, "127.0.0.1") && !strings.HasPrefix(r.RemoteAddr, "[::1]") {
|
if !strings.HasPrefix(r.RemoteAddr, "127.0.0.1") && !strings.HasPrefix(r.RemoteAddr, "[::1]") {
|
||||||
rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
|
rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
|
||||||
}
|
}
|
||||||
|
if config.PortMin > 0 && config.PortMax > 0 {
|
||||||
|
rtc.s.SetEphemeralUDPPortRange(config.PortMin, config.PortMax)
|
||||||
|
}
|
||||||
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
|
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
|
||||||
peerConnection, err := rtc.api.NewPeerConnection(Configuration{
|
peerConnection, err := rtc.api.NewPeerConnection(Configuration{
|
||||||
// ICEServers: []ICEServer{
|
// ICEServers: []ICEServer{
|
||||||
|
Reference in New Issue
Block a user