mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
Merge pull request #11 from xpzouying/zy/fix-remove-dup-close-db
fix: remove db twice
This commit is contained in:
commit
6fa84004b3
5
cli.go
5
cli.go
@ -2,6 +2,7 @@ package headscale
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||||||
log.Printf("Cannot open DB: %s", err)
|
log.Printf("Cannot open DB: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer db.Close()
|
|
||||||
routes, _ := json.Marshal([]string{routeStr}) // TODO: only one for the time being, so overwriting the rest
|
routes, _ := json.Marshal([]string{routeStr}) // TODO: only one for the time being, so overwriting the rest
|
||||||
m.EnabledRoutes = postgres.Jsonb{RawMessage: json.RawMessage(routes)}
|
m.EnabledRoutes = postgres.Jsonb{RawMessage: json.RawMessage(routes)}
|
||||||
db.Save(&m)
|
db.Save(&m)
|
||||||
@ -107,6 +108,6 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Could not find routable range")
|
|
||||||
|
|
||||||
|
return errors.New("could not find routable range")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user