mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-08 08:10:30 +00:00
The cache address was detected once at startup, and the interface fallback ranked ethernet names above IPv4. A runner that started before DHCPv4 finished could advertise a global IPv6 address to IPv4-only job networks until it restarted, failing every artifact and cache call. IPv4 now ranks first, and the address is detected again for each job unless `cache.host` sets it. Detecting an IPv6 address logs a warning. Fixes: https://gitea.com/gitea/runner/issues/1379 Co-authored-by: silverwind <[email protected]> Co-authored-by: silverwind <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1398 Reviewed-by: silverwind <[email protected]> Co-authored-by: bircni <[email protected]>
22 lines
589 B
Go
22 lines
589 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package common
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPreferredIP(t *testing.T) {
|
|
assert.Nil(t, preferredIP(nil))
|
|
assert.Equal(t, net.ParseIP("2001:db8::1"), preferredIP([]interfaceIP{{IP: net.ParseIP("2001:db8::1")}}))
|
|
assert.Equal(t, net.ParseIP("192.0.2.1"), preferredIP([]interfaceIP{
|
|
{IP: net.ParseIP("192.0.2.1"), Name: "wlan0"},
|
|
{IP: net.ParseIP("2001:db8::1"), Name: "eth0"},
|
|
{IP: net.ParseIP("172.18.0.1"), Name: "br-0123456789ab"},
|
|
}))
|
|
}
|