ComunicRTCProxy/main.go

41 lines
781 B
Go
Raw Normal View History

2020-04-09 15:32:16 +00:00
package main
import (
"fmt"
2020-04-12 15:24:49 +00:00
"log"
2020-04-10 06:46:34 +00:00
"os"
2020-04-12 15:24:49 +00:00
"time"
2020-04-09 15:32:16 +00:00
)
func main() {
2020-04-10 06:46:34 +00:00
println("Comunic RTC Proxy. (c) Pierre Hubert 2020")
// Command line args
if len(os.Args) != 2 {
fmt.Printf("Usage: %s <config>", os.Args[0])
}
// First, load the config
conf := loadConfig(os.Args[1])
2021-10-17 18:01:42 +00:00
if len(conf.AccessIP) > 0 {
fmt.Printf("RTC reachable at %s\n", conf.AccessIP)
}
if conf.PortStart > 0 && conf.PortEnd > conf.PortStart {
fmt.Printf("Will listen only on these ports: %d to %d\n", conf.PortStart, conf.PortEnd)
}
2020-04-12 15:24:49 +00:00
/// Avoid to quick restart loop
defer timeBeforeQuit(&conf)
2020-04-10 07:43:14 +00:00
// Then connect to websocket
openWs(&conf)
2020-04-09 15:32:16 +00:00
}
2020-04-12 15:24:49 +00:00
func timeBeforeQuit(c *Config) {
log.Printf("Waiting %d seconds before quitting...", c.Restart)
time.Sleep(time.Second * time.Duration(c.Restart))
}