Skip to content

Commit

Permalink
Merge pull request #333 from kthcloud/dev
Browse files Browse the repository at this point in the history
fix ssh bug that caused same conn string for all vms in list
  • Loading branch information
saffronjam authored Dec 14, 2023
2 parents ee6a72a + c9e371b commit c6231fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion service/deployment_service/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func (c *BaseClient[parent]) fetchDeployments(dmc *deploymentModel.Client) ([]de
}

for _, deployment := range deployments {
c.StoreDeployment(&deployment)
d := deployment
c.StoreDeployment(&d)
}

return deployments, nil
Expand Down
3 changes: 2 additions & 1 deletion service/vm_service/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func (c *BaseClient[parent]) fetchVMs(vmc *vmModel.Client) ([]vmModel.VM, error)
}

for _, vm := range vms {
c.StoreVM(&vm)
v := vm
c.StoreVM(&v)
}

return vms, nil
Expand Down
9 changes: 6 additions & 3 deletions service/vm_service/vm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,16 @@ func (c *Client) GetConnectionString(id string) (*string, error) {
}

domainName := zone.ParentDomain
port := vm.Subsystems.CS.PortForwardingRuleMap["__ssh"].PublicPort
rule := vm.Subsystems.CS.GetPortForwardingRule("__ssh")
if rule == nil {
return nil, nil
}

if domainName == "" || port == 0 {
if domainName == "" || rule.PublicPort == 0 {
return nil, nil
}

connectionString := fmt.Sprintf("ssh root@%s -p %d", domainName, port)
connectionString := fmt.Sprintf("ssh root@%s -p %d", domainName, rule.PublicPort)

return &connectionString, nil
}
Expand Down

0 comments on commit c6231fa

Please sign in to comment.