mirror of
https://github.com/jech/galene.git
synced 2024-11-23 00:55:58 +01:00
Passive ICE TCP.
This commit is contained in:
parent
1b492114ad
commit
48e6af87ec
4 changed files with 41 additions and 2 deletions
14
galene.go
14
galene.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -23,6 +24,7 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
var cpuprofile, memprofile, mutexprofile, httpAddr string
|
var cpuprofile, memprofile, mutexprofile, httpAddr string
|
||||||
var udpRange string
|
var udpRange string
|
||||||
|
var tcpPort int
|
||||||
|
|
||||||
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
|
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
|
||||||
flag.StringVar(&webserver.StaticRoot, "static", "./static/",
|
flag.StringVar(&webserver.StaticRoot, "static", "./static/",
|
||||||
|
@ -43,6 +45,9 @@ func main() {
|
||||||
"store mutex profile in `file`")
|
"store mutex profile in `file`")
|
||||||
flag.StringVar(&udpRange, "udp-range", "",
|
flag.StringVar(&udpRange, "udp-range", "",
|
||||||
"UDP port `range`")
|
"UDP port `range`")
|
||||||
|
flag.IntVar(&tcpPort, "tcp-port", -1,
|
||||||
|
"TCP listener `port`. If 0, an ephemeral port is used.\n"+
|
||||||
|
"If -1, the TCP listerer is disabled")
|
||||||
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
|
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
|
||||||
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
|
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
|
||||||
"require use of TURN relays for all media traffic")
|
"require use of TURN relays for all media traffic")
|
||||||
|
@ -115,6 +120,15 @@ func main() {
|
||||||
// make sure the list of public groups is updated early
|
// make sure the list of public groups is updated early
|
||||||
go group.Update()
|
go group.Update()
|
||||||
|
|
||||||
|
if tcpPort >= 0 {
|
||||||
|
err := group.StartTCPListener(&net.TCPAddr{
|
||||||
|
Port: tcpPort,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Couldn't start ICE TCP: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// causes the built-in server to start if required
|
// causes the built-in server to start if required
|
||||||
ice.Update()
|
ice.Update()
|
||||||
defer turnserver.Stop()
|
defer turnserver.Stop()
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ require (
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/jech/cert v0.0.0-20210819231831-aca735647728
|
github.com/jech/cert v0.0.0-20210819231831-aca735647728
|
||||||
github.com/jech/samplebuilder v0.0.0-20220125212352-4553ed6f9a6c
|
github.com/jech/samplebuilder v0.0.0-20220125212352-4553ed6f9a6c
|
||||||
github.com/pion/ice/v2 v2.1.20
|
github.com/pion/ice/v2 v2.2.1-0.20220221210118-fca128a058ec
|
||||||
github.com/pion/rtcp v1.2.9
|
github.com/pion/rtcp v1.2.9
|
||||||
github.com/pion/rtp v1.7.4
|
github.com/pion/rtp v1.7.4
|
||||||
github.com/pion/sdp/v3 v3.0.4
|
github.com/pion/sdp/v3 v3.0.4
|
||||||
|
|
3
go.sum
3
go.sum
|
@ -55,8 +55,9 @@ github.com/pion/dtls/v2 v2.1.1/go.mod h1:qG3gA7ZPZemBqpEFqRKyURYdKEwFZQCGb7gv9T3
|
||||||
github.com/pion/dtls/v2 v2.1.2 h1:22Q1Jk9L++Yo7BIf9130MonNPfPVb+YgdYLeyQotuAA=
|
github.com/pion/dtls/v2 v2.1.2 h1:22Q1Jk9L++Yo7BIf9130MonNPfPVb+YgdYLeyQotuAA=
|
||||||
github.com/pion/dtls/v2 v2.1.2/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
|
github.com/pion/dtls/v2 v2.1.2/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus=
|
||||||
github.com/pion/ice/v2 v2.1.12/go.mod h1:ovgYHUmwYLlRvcCLI67PnQ5YGe+upXZbGgllBDG/ktU=
|
github.com/pion/ice/v2 v2.1.12/go.mod h1:ovgYHUmwYLlRvcCLI67PnQ5YGe+upXZbGgllBDG/ktU=
|
||||||
github.com/pion/ice/v2 v2.1.20 h1:xpxXyX5b4WjCh/D905gzBeW/hbJxMEPx2ptVfrhVE6M=
|
|
||||||
github.com/pion/ice/v2 v2.1.20/go.mod h1:hEAldRzBhTtAfvlU1V/2/nLCMvveQWFKPNCop+63/Iw=
|
github.com/pion/ice/v2 v2.1.20/go.mod h1:hEAldRzBhTtAfvlU1V/2/nLCMvveQWFKPNCop+63/Iw=
|
||||||
|
github.com/pion/ice/v2 v2.2.1-0.20220221210118-fca128a058ec h1:dN7oetSQnnfGeJaBWZyLpnM825etYPasGKCIY88QBpU=
|
||||||
|
github.com/pion/ice/v2 v2.2.1-0.20220221210118-fca128a058ec/go.mod h1:Op8jlPtjeiycsXh93Cs4jK82C9j/kh7vef6ztIOvtIQ=
|
||||||
github.com/pion/interceptor v0.1.0/go.mod h1:j5NIl3tJJPB3u8+Z2Xz8MZs/VV6rc+If9mXEKNuFmEM=
|
github.com/pion/interceptor v0.1.0/go.mod h1:j5NIl3tJJPB3u8+Z2Xz8MZs/VV6rc+If9mXEKNuFmEM=
|
||||||
github.com/pion/interceptor v0.1.7 h1:HThW0tIIKT9RRoDWGURe8rlZVOx0fJHxBHpA0ej0+bo=
|
github.com/pion/interceptor v0.1.7 h1:HThW0tIIKT9RRoDWGURe8rlZVOx0fJHxBHpA0ej0+bo=
|
||||||
github.com/pion/interceptor v0.1.7/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
github.com/pion/interceptor v0.1.7/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -171,6 +172,18 @@ func (g *Group) API() (*webrtc.API, error) {
|
||||||
return APIFromNames(codecs)
|
return APIFromNames(codecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tcpListener net.Listener
|
||||||
|
|
||||||
|
func StartTCPListener(addr *net.TCPAddr) error {
|
||||||
|
if tcpListener != nil {
|
||||||
|
tcpListener.Close()
|
||||||
|
tcpListener = nil
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
tcpListener, err = net.ListenTCP("tcp", addr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func fmtpValue(fmtp, key string) string {
|
func fmtpValue(fmtp, key string) string {
|
||||||
fields := strings.Split(fmtp, ";")
|
fields := strings.Split(fmtp, ";")
|
||||||
for _, f := range fields {
|
for _, f := range fields {
|
||||||
|
@ -338,6 +351,17 @@ func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error) {
|
||||||
if !UseMDNS {
|
if !UseMDNS {
|
||||||
s.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
|
s.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
|
||||||
}
|
}
|
||||||
|
if tcpListener != nil {
|
||||||
|
mux := webrtc.NewICETCPMux(nil, tcpListener, 8)
|
||||||
|
s.SetICETCPMux(mux)
|
||||||
|
s.SetNetworkTypes([]webrtc.NetworkType{
|
||||||
|
webrtc.NetworkTypeUDP4,
|
||||||
|
webrtc.NetworkTypeUDP6,
|
||||||
|
webrtc.NetworkTypeTCP4,
|
||||||
|
webrtc.NetworkTypeTCP6,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
m := webrtc.MediaEngine{}
|
m := webrtc.MediaEngine{}
|
||||||
|
|
||||||
for _, codec := range codecs {
|
for _, codec := range codecs {
|
||||||
|
|
Loading…
Reference in a new issue