From 9bbc78ae4d29a536bb272a680222d9d3df7a13a0 Mon Sep 17 00:00:00 2001 From: jdork0 Date: Tue, 14 Mar 2023 10:19:15 -0400 Subject: [PATCH] hard coded mac on user networking --- usernet/usernet.go | 10 ++++------ vzcli/CommonVM.swift | 4 ++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/usernet/usernet.go b/usernet/usernet.go index 78f0095..ceefea1 100644 --- a/usernet/usernet.go +++ b/usernet/usernet.go @@ -57,11 +57,9 @@ func StartUserNet(sockFD int32, portForwards string) { GatewayVirtualIPs: []string{"172.16.10.254"}, Protocol: types.BessProtocol, } - // Forwards: map[string]string{ - // fmt.Sprintf("127.0.0.1:%d", sshPort): "172.16.10.2:22", - // }, - // shush go + // try to turn off golang logging + // some still sneaking through null, _ := os.Open(os.DevNull) os.Stdout = null os.Stderr = null @@ -77,13 +75,14 @@ func StartUserNet(sockFD int32, portForwards string) { // create a background context ctx := context.Background() - // get a file connection to the fd pass in + // get a file connection to the socket file descriptor file := os.NewFile(uintptr(sockFD), "server") conn, err := net.FileConn(file) if err != nil { fmt.Printf("err: %q\n", err) } + // connect the socket to the virtualnetwork groupErrs, ctx := errgroup.WithContext(ctx) groupErrs.Go(func() error { return vn.AcceptBess(ctx, conn) @@ -94,5 +93,4 @@ func StartUserNet(sockFD int32, portForwards string) { fmt.Printf("virtual network error: %q\n", err) } }() - // return nil } diff --git a/vzcli/CommonVM.swift b/vzcli/CommonVM.swift index 0e415c9..036b3f2 100644 --- a/vzcli/CommonVM.swift +++ b/vzcli/CommonVM.swift @@ -267,6 +267,10 @@ class CommonVM: NSObject, NSApplicationDelegate, VZVirtualMachineDelegate { // connect second socket as vm device let socketDev = VZFileHandleNetworkDeviceAttachment(fileHandle: FileHandle(fileDescriptor: socket_pair[1])) + // hard code the mac address on this connection + // should probably block two "user" type interfaces on same VM + let vzMac = VZMACAddress(string: "5a:ca:b5:c7:1b:e7")! + networkDevice.macAddress = vzMac networkDevice.attachment = socketDev case "nat":