Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Commit 7800f83

Browse files
author
Anthony Emengo
committed
Inject windows vpnkit guids
* Allows for unit tests not to collide with running cfdev [#160907700] Signed-off-by: Anthony Emengo <[email protected]>
1 parent 072da26 commit 7800f83

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

cmd/root_windows.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ func NewRoot(exit chan struct{}, ui UI, config config.Config, analyticsClient An
5757
root.PersistentFlags().Bool("help", false, "")
5858
root.PersistentFlags().Lookup("help").Hidden = true
5959
lctl := daemon.NewWinSW(config.CFDevHome)
60-
vpnkit := &network.VpnKit{Config: config, DaemonRunner: lctl, Powershell: runner.Powershell{}, Label: network.VpnKitLabel}
60+
vpnkit := &network.VpnKit{
61+
Config: config,
62+
DaemonRunner: lctl,
63+
Powershell: runner.Powershell{},
64+
Label: network.VpnKitLabel,
65+
EthernetGUID: "7207f451-2ca3-4b88-8d01-820a21d78293",
66+
PortGUID: "cc2a519a-fb40-4e45-a9f1-c7f04c5ad7fa",
67+
ForwarderGUID: "e3ae8f06-8c25-47fb-b6ed-c20702bcef5e",
68+
}
6169
isoReader := iso.New()
6270
hostnet := &network.HostNet{
6371
VMSwitchName: "cfdev",

network/vpnkit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type VpnKit struct {
2020
DaemonRunner DaemonRunner
2121
Powershell runner.Powershell
2222
Label string
23+
EthernetGUID string
24+
PortGUID string
25+
ForwarderGUID string
2326
}
2427

2528
type DaemonRunner interface {

network/vpnkit_windows.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import (
1414
"io/ioutil"
1515
)
1616

17-
const ethernetGUID = "7207f451-2ca3-4b88-8d01-820a21d78293"
18-
const portGUID = "cc2a519a-fb40-4e45-a9f1-c7f04c5ad7fa"
19-
const forwarderGUID = "e3ae8f06-8c25-47fb-b6ed-c20702bcef5e"
20-
2117
func (v *VpnKit) Start() error {
2218
if err := v.Setup(); err != nil {
2319
return errors.SafeWrap(err, "Failed to Setup VPNKit")
@@ -64,9 +60,9 @@ func (v *VpnKit) daemonSpec(vmGuid string) daemon.DaemonSpec {
6460
Label: v.Label,
6561
Program: path.Join(v.Config.CacheDir, "vpnkit.exe"),
6662
ProgramArguments: []string{
67-
fmt.Sprintf("--ethernet hyperv-connect://%s/%s", vmGuid, ethernetGUID),
68-
fmt.Sprintf("--port hyperv-connect://%s/%s", vmGuid, portGUID),
69-
fmt.Sprintf("--port hyperv-connect://%s/%s", vmGuid, forwarderGUID),
63+
fmt.Sprintf("--ethernet hyperv-connect://%s/%s", vmGuid, v.EthernetGUID),
64+
fmt.Sprintf("--port hyperv-connect://%s/%s", vmGuid, v.PortGUID),
65+
fmt.Sprintf("--port hyperv-connect://%s/%s", vmGuid, v.ForwarderGUID),
7066
fmt.Sprintf("--dns %s", dnsPath),
7167
fmt.Sprintf("--dhcp %s", dhcpPath),
7268
"--http", path.Join(v.Config.VpnKitStateDir, "http_proxy.json"),
@@ -105,13 +101,13 @@ func (v *VpnKit) Setup() error {
105101
}
106102

107103
func (v *VpnKit) registerServiceGUIDs() error {
108-
if err := v.registerGUID(ethernetGUID, "Ethernet"); err != nil {
104+
if err := v.registerGUID(v.EthernetGUID, "Ethernet"); err != nil {
109105
return err
110106
}
111-
if err := v.registerGUID(portGUID, "Port"); err != nil {
107+
if err := v.registerGUID(v.PortGUID, "Port"); err != nil {
112108
return err
113109
}
114-
return v.registerGUID(forwarderGUID, "Forwarder")
110+
return v.registerGUID(v.ForwarderGUID, "Forwarder")
115111
}
116112

117113
func (v *VpnKit) registerGUID(guid, name string) error {

network/vpnkit_windows_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ var _ = Describe("VpnKit", func() {
2929
Config: config.Config{
3030
CFDevHome: tempDir,
3131
},
32+
EthernetGUID: "65319afc-c1a2-4ad9-97a0-0058737b94c2",
33+
PortGUID: "d611c86d-22c9-417c-ac09-3ed4ce5fbfb0",
34+
ForwarderGUID: "2ad4fb96-7f0b-4ff9-b42b-8e25da407647",
3235
}
3336
})
3437

0 commit comments

Comments
 (0)