mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-05 16:26:50 +08:00
Remove all listeners from IPv6 interface
This commit is contained in:
@@ -49,7 +49,7 @@ func Init() {
|
|||||||
HandleFunc("api/exit", exitHandler)
|
HandleFunc("api/exit", exitHandler)
|
||||||
|
|
||||||
// ensure we can listen without errors
|
// ensure we can listen without errors
|
||||||
listener, err := net.Listen("tcp", cfg.Mod.Listen)
|
listener, err := net.Listen("tcp4", cfg.Mod.Listen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("[api] listen")
|
log.Fatal().Err(err).Msg("[api] listen")
|
||||||
return
|
return
|
||||||
@@ -169,7 +169,7 @@ func middlewareLog(next http.Handler) http.Handler {
|
|||||||
|
|
||||||
func middlewareAuth(username, password string, next http.Handler) http.Handler {
|
func middlewareAuth(username, password string, next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if !strings.HasPrefix(r.RemoteAddr, "127.") && !strings.HasPrefix(r.RemoteAddr, "[::1]") {
|
if !strings.HasPrefix(r.RemoteAddr, "127.") {
|
||||||
user, pass, ok := r.BasicAuth()
|
user, pass, ok := r.BasicAuth()
|
||||||
if !ok || user != username || pass != password {
|
if !ok || user != username || pass != password {
|
||||||
w.Header().Set("Www-Authenticate", `Basic realm="go2rtc"`)
|
w.Header().Set("Www-Authenticate", `Basic realm="go2rtc"`)
|
||||||
|
@@ -45,7 +45,7 @@ func Init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", address)
|
ln, err := net.Listen("tcp4", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("[rtsp] listen")
|
log.Error().Err(err).Msg("[rtsp] listen")
|
||||||
return
|
return
|
||||||
|
@@ -44,7 +44,7 @@ func NewServer(name string) *Server {
|
|||||||
|
|
||||||
func (s *Server) Serve(address string) (err error) {
|
func (s *Server) Serve(address string) (err error) {
|
||||||
var ln net.Listener
|
var ln net.Listener
|
||||||
if ln, err = net.Listen("tcp", address); err != nil {
|
if ln, err = net.Listen("tcp4", address); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
func TestTimeout(t *testing.T) {
|
func TestTimeout(t *testing.T) {
|
||||||
Timeout = time.Millisecond
|
Timeout = time.Millisecond
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", "localhost:0")
|
ln, err := net.Listen("tcp4", "localhost:0")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
client := NewClient("rtsp://" + ln.Addr().String() + "/stream")
|
client := NewClient("rtsp://" + ln.Addr().String() + "/stream")
|
||||||
@@ -27,7 +27,7 @@ func TestTimeout(t *testing.T) {
|
|||||||
func TestMissedControl(t *testing.T) {
|
func TestMissedControl(t *testing.T) {
|
||||||
Timeout = time.Millisecond
|
Timeout = time.Millisecond
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", "localhost:0")
|
ln, err := net.Listen("tcp4", "localhost:0")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@@ -50,13 +50,13 @@ func NewAPI(address string) (*webrtc.API, error) {
|
|||||||
if address != "" {
|
if address != "" {
|
||||||
address, network, _ := strings.Cut(address, "/")
|
address, network, _ := strings.Cut(address, "/")
|
||||||
if network == "" || network == "udp" {
|
if network == "" || network == "udp" {
|
||||||
if ln, err := net.ListenPacket("udp", address); err == nil {
|
if ln, err := net.ListenPacket("udp4", address); err == nil {
|
||||||
udpMux := webrtc.NewICEUDPMux(nil, ln)
|
udpMux := webrtc.NewICEUDPMux(nil, ln)
|
||||||
s.SetICEUDPMux(udpMux)
|
s.SetICEUDPMux(udpMux)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if network == "" || network == "tcp" {
|
if network == "" || network == "tcp" {
|
||||||
if ln, err := net.Listen("tcp", address); err == nil {
|
if ln, err := net.Listen("tcp4", address); err == nil {
|
||||||
tcpMux := webrtc.NewICETCPMux(nil, ln, 8)
|
tcpMux := webrtc.NewICETCPMux(nil, ln, 8)
|
||||||
s.SetICETCPMux(tcpMux)
|
s.SetICETCPMux(tcpMux)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user