mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Rework configuration of built-in TURN server.
The default configuration is now defined by an explicit value "auto", which is easier to check and to explain.
This commit is contained in:
parent
c1b689bccf
commit
c103d1cfb0
4 changed files with 32 additions and 30 deletions
29
README
29
README
|
@ -242,24 +242,27 @@ user entry with a hashed password looks like this:
|
|||
ICE is the NAT and firewall traversal protocol used by WebRTC. ICE can
|
||||
make use of two kinds of servers to help with NAT traversal: STUN servers,
|
||||
that simply help punching holes in NATs, and TURN servers, that serve as
|
||||
relays for traffic. TURN is a superset of NAT: no STUN server is
|
||||
relays for traffic. TURN is a superset of STUN: no STUN server is
|
||||
necessary if a TURN server is available.
|
||||
|
||||
Galène includes a simple IPv4-only TURN server, which is controlled by the
|
||||
`-turn` command-line option. If the value of this option is the empty
|
||||
string `""`, then the built-in server is disabled. If the value of this
|
||||
option is a colon followed with a port number `:1194`, then the TURN
|
||||
server will listen on all public IPv4 addresses of the local host, over
|
||||
UDP and TCP. If the value of this option is a socket address, such as
|
||||
`-turn` command-line option. If its value is set to the empty string
|
||||
`""`, then the built-in server is disabled. If its value is a colon
|
||||
followed with a port number, for example `:1194`, then the TURN server
|
||||
will listen on all public IPv4 addresses of the local host, over UDP and
|
||||
TCP. If the value of this option is a socket address, such as
|
||||
`192.0.2.1:1194`, then the TURN server will listen on all addresses of the
|
||||
local host but assume that the address seen by the clients is the one
|
||||
given in the option; this is the recommended configuration when running
|
||||
behind NAT with port forwarding.
|
||||
behind NAT with port forwarding. The default value is `-turn auto`, which
|
||||
enables the TURN server on port 1194 if there is no
|
||||
`data/ice-servers.json` file.
|
||||
|
||||
Some users may prefer to disable Galène's built in TURN server (`-turn ""`)
|
||||
and configure an external ICE server. In that case, the ICE configuration
|
||||
should appear in the file `data/ice-servers.json`. In the case of a STUN
|
||||
server, it should look like this:
|
||||
Some users may prefer to use an external ICE server. In that case, the
|
||||
built-in TURN server should be disabled (`-turn ""` or the default
|
||||
`-turn auto`), and a working ICE configuration should appear in the file
|
||||
`data/ice-servers.json`. In the case of a single STUN server, it should
|
||||
look like this:
|
||||
|
||||
[
|
||||
{
|
||||
|
@ -283,8 +286,8 @@ look like this:
|
|||
}
|
||||
]
|
||||
|
||||
If you prefer to use coturn's `use-auth-secret` option, then your
|
||||
`ice-servers.json` should look like this:
|
||||
If you prefer to use coturn's `use-auth-secret` option, then the
|
||||
`ice-servers.json` file should look like this:
|
||||
|
||||
[
|
||||
{
|
||||
|
|
|
@ -43,16 +43,10 @@ func main() {
|
|||
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
|
||||
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
|
||||
"require use of TURN relays for all media traffic")
|
||||
flag.StringVar(&turnserver.Address, "turn", ":1194",
|
||||
flag.StringVar(&turnserver.Address, "turn", "auto",
|
||||
"built-in TURN server `address` (\"\" to disable)")
|
||||
flag.Parse()
|
||||
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
if f.Name == "turn" {
|
||||
turnserver.Force = true
|
||||
}
|
||||
})
|
||||
|
||||
if cpuprofile != "" {
|
||||
f, err := os.Create(cpuprofile)
|
||||
if err != nil {
|
||||
|
|
|
@ -107,7 +107,7 @@ func Update() *configuration {
|
|||
}
|
||||
}
|
||||
|
||||
err := turnserver.StartStop(found)
|
||||
err := turnserver.StartStop(!found)
|
||||
if err != nil {
|
||||
log.Printf("TURN: %v", err)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
var username string
|
||||
var password string
|
||||
var Address string
|
||||
var Force bool
|
||||
|
||||
var mu sync.Mutex
|
||||
var addresses []net.Addr
|
||||
|
@ -96,7 +95,12 @@ func Start() error {
|
|||
if Address == "" {
|
||||
return errors.New("built-in TURN server disabled")
|
||||
}
|
||||
addr, err := net.ResolveUDPAddr("udp4", Address)
|
||||
|
||||
ad := Address
|
||||
if Address == "auto" {
|
||||
ad = ":1194"
|
||||
}
|
||||
addr, err := net.ResolveUDPAddr("udp4", ad)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -234,13 +238,14 @@ func Stop() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func StartStop(found bool) error {
|
||||
if Force && Address != "" {
|
||||
return Start()
|
||||
} else if found {
|
||||
func StartStop(start bool) error {
|
||||
if Address == "auto" {
|
||||
if start {
|
||||
return Start()
|
||||
}
|
||||
return Stop()
|
||||
} else if Address == "" {
|
||||
return Stop()
|
||||
} else if Address != "" {
|
||||
return Start()
|
||||
}
|
||||
return nil
|
||||
return Start()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue