feat: export GetFreeAddrPort
This commit is contained in:
parent
6036211172
commit
67ffa2347a
@ -152,7 +152,7 @@ func getRandomPort(ip string) (addr string) {
|
|||||||
return fmt.Sprintf("%s:%d", ip, port)
|
return fmt.Sprintf("%s:%d", ip, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFreeAddrPort() (addrPort string) {
|
func GetFreeAddrPort() (addrPort string) {
|
||||||
timeout := time.Now().Add(time.Second)
|
timeout := time.Now().Add(time.Second)
|
||||||
for {
|
for {
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
@ -233,7 +233,7 @@ func (q System) Executable() string {
|
|||||||
|
|
||||||
func (q *System) Args() (qemuArgs []string) {
|
func (q *System) Args() (qemuArgs []string) {
|
||||||
if q.SSH.AddrPort == "" {
|
if q.SSH.AddrPort == "" {
|
||||||
q.SSH.AddrPort = getFreeAddrPort()
|
q.SSH.AddrPort = GetFreeAddrPort()
|
||||||
}
|
}
|
||||||
hostfwd := fmt.Sprintf("hostfwd=tcp:%s-:22", q.SSH.AddrPort)
|
hostfwd := fmt.Sprintf("hostfwd=tcp:%s-:22", q.SSH.AddrPort)
|
||||||
qemuArgs = []string{"-nographic",
|
qemuArgs = []string{"-nographic",
|
||||||
|
@ -63,7 +63,7 @@ func TestSystemStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFreeAddrPort(t *testing.T) {
|
func TestGetFreeAddrPort(t *testing.T) {
|
||||||
addrPort := getFreeAddrPort()
|
addrPort := GetFreeAddrPort()
|
||||||
ln, err := net.Listen("tcp", addrPort)
|
ln, err := net.Listen("tcp", addrPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user