mirror of
https://github.com/livekit/livekit.git
synced 2026-11-23 02:29:22 +00:00
CreateIngress for a URL pull ingress only checked the URL scheme, so the ingress handler could be pointed at loopback, private, link-local (including the cloud metadata address) or other internal hosts. Resolve the host of http, https and srt URLs at create time and reject localhost names, unresolvable hosts, and any host with a resolved address that is loopback, private, link-local, CGNAT, unspecified, 0.0.0.0/8, multicast or broadcast. IPv4-mapped addresses are checked as IPv4. ingress.allow_private_url_pull (default false) turns the check off for deployments that pull from sources on their own network. This is a create-time check against the server's DNS. Redirects, HLS sub-fetches and DNS answers that change before the fetch still have to be enforced where the fetch happens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
849 B
Go
29 lines
849 B
Go
// Copyright 2026 LiveKit, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
|
|
package service
|
|
|
|
import (
|
|
"context"
|
|
"net/netip"
|
|
"testing"
|
|
)
|
|
|
|
func SetLookupNetIP(t *testing.T, fn func(ctx context.Context, network, host string) ([]netip.Addr, error)) {
|
|
prev := lookupNetIP
|
|
lookupNetIP = fn
|
|
t.Cleanup(func() { lookupNetIP = prev })
|
|
}
|