Skip to content

Commit

Permalink
NET-1565:fix extClient ip conflict issue (#3082)
Browse files Browse the repository at this point in the history
* fix extClient ip conflict issue

* Update users.go

---------

Co-authored-by: Abhishek K <[email protected]>
  • Loading branch information
yabinma and abhishek9686 authored Aug 28, 2024
1 parent 19d7bb1 commit bbca20e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 24 additions & 8 deletions logic/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,35 @@ func SetAllocatedIpMap() error {
pMap := map[string]net.IP{}
netName := v.NetID

//nodes
nodes, err := GetNetworkNodes(netName)
if err != nil {
slog.Error("could not load node for network", netName, "error", err.Error())
continue
}

for _, n := range nodes {
} else {
for _, n := range nodes {

if n.Address.IP != nil {
pMap[n.Address.IP.String()] = n.Address.IP
if n.Address.IP != nil {
pMap[n.Address.IP.String()] = n.Address.IP
}
if n.Address6.IP != nil {
pMap[n.Address6.IP.String()] = n.Address6.IP
}
}
if n.Address6.IP != nil {
pMap[n.Address6.IP.String()] = n.Address6.IP

}

//extClients
extClients, err := GetNetworkExtClients(netName)
if err != nil {
slog.Error("could not load extClient for network", netName, "error", err.Error())
} else {
for _, extClient := range extClients {
if extClient.Address != "" {
pMap[extClient.Address] = net.ParseIP(extClient.Address)
}
if extClient.Address6 != "" {
pMap[extClient.Address6] = net.ParseIP(extClient.Address6)
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions pro/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
return
}
userGwNodes := proLogic.GetUserRAGNodes(*user)
logger.Log(0, fmt.Sprintf("1. User Gw Nodes: %+v", userGwNodes))
for _, extClient := range allextClients {
node, ok := userGwNodes[extClient.IngressGatewayID]
if !ok {
Expand Down Expand Up @@ -885,7 +884,6 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
delete(userGwNodes, node.ID.String())
}
}
logger.Log(0, fmt.Sprintf("2. User Gw Nodes: %+v", userGwNodes))
// add remaining gw nodes to resp
for gwID := range userGwNodes {
node, err := logic.GetNodeByID(gwID)
Expand Down

0 comments on commit bbca20e

Please sign in to comment.