v2.0.0.0000

This commit is contained in:
marmei
2019-08-02 20:12:09 +02:00
parent e396af91cb
commit e001b06b62
85 changed files with 22786 additions and 2 deletions

69
src/ssdp.go Normal file
View File

@@ -0,0 +1,69 @@
package src
import (
"fmt"
"log"
"os"
"os/signal"
"time"
"github.com/koron/go-ssdp"
)
// SSDP : SSPD / DLNA Server
func SSDP() {
showInfo(fmt.Sprintf("SSDP / DLNA:%t", Settings.SSDP))
if Settings.SSDP == false {
return
}
time.Sleep(10 * time.Second)
ad, err := ssdp.Advertise(
"upnp:"+System.AppName, // send as "ST"
System.DeviceID+"::upnp:"+System.AppName, // send as "USN"
System.URLBase+"/device.xml", // send as "LOCATION"
System.AppName, // send as "SERVER"
1800) // send as "maxAge" in "CACHE-CONTROL"
if err != nil {
ShowError(err, 000)
}
// Debug SSDP
if System.Flag.Debug == 3 {
ssdp.Logger = log.New(os.Stderr, "[SSDP] ", log.LstdFlags)
}
var aliveTick <-chan time.Time
var ai = 10
if ai > 0 {
aliveTick = time.Tick(time.Duration(ai) * time.Second)
} else {
aliveTick = make(chan time.Time)
}
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
loop:
for {
select {
case <-aliveTick:
ad.Alive()
case <-quit:
os.Exit(0)
break loop
}
}
ad.Bye()
ad.Close()
}