1
0

feat: export GetFreeAddrPort

This commit is contained in:
dump_stack() 2024-02-20 11:58:41 +00:00
parent 6036211172
commit 67ffa2347a
Signed by: dump_stack
GPG Key ID: C9905BA72B5E02BB
2 changed files with 3 additions and 3 deletions

View File

@ -152,7 +152,7 @@ func getRandomPort(ip string) (addr string) {
return fmt.Sprintf("%s:%d", ip, port)
}
func getFreeAddrPort() (addrPort string) {
func GetFreeAddrPort() (addrPort string) {
timeout := time.Now().Add(time.Second)
for {
if runtime.GOOS == "linux" {
@ -233,7 +233,7 @@ func (q System) Executable() string {
func (q *System) Args() (qemuArgs []string) {
if q.SSH.AddrPort == "" {
q.SSH.AddrPort = getFreeAddrPort()
q.SSH.AddrPort = GetFreeAddrPort()
}
hostfwd := fmt.Sprintf("hostfwd=tcp:%s-:22", q.SSH.AddrPort)
qemuArgs = []string{"-nographic",

View File

@ -63,7 +63,7 @@ func TestSystemStart(t *testing.T) {
}
func TestGetFreeAddrPort(t *testing.T) {
addrPort := getFreeAddrPort()
addrPort := GetFreeAddrPort()
ln, err := net.Listen("tcp", addrPort)
if err != nil {
t.Fatal(err)