stream-server/srt/server.go

31 lines
573 B
Go
Raw Normal View History

2023-09-18 11:51:55 +05:00
package srt
import (
"net"
2023-09-20 15:06:32 +05:00
"fmt"
2023-09-18 11:51:55 +05:00
)
2023-09-22 14:58:33 +05:00
// main entry point, no concept of tunnels in UDP so need to implement
// that separately and cannot simply add a max connlimit here like with RTMP
2023-09-18 11:51:55 +05:00
func NewServer(port string) (error) {
l, err := net.ListenPacket("udp", ":" + port)
if err != nil {
return err
}
go start(l)
return nil
}
func start(l net.PacketConn) {
2023-09-22 14:58:33 +05:00
// basic panic logging for debugging mostly
2023-09-20 15:06:32 +05:00
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
}
}()
2023-09-22 14:58:33 +05:00
intake := NewIntake(l, 1) // limit to one concurrent tunnel
2023-09-18 11:51:55 +05:00
for {
intake.Read()
}
}