wip: many small fixes and improvements...

This commit is contained in:
Christoph Haas 2020-11-09 23:36:19 +01:00
parent c9a9c5b393
commit c5cb22829d
2 changed files with 17 additions and 0 deletions

View File

@ -104,6 +104,9 @@ func (s *Server) Setup() error {
if err := s.users.InitFromCurrentInterface(); err != nil { if err := s.users.InitFromCurrentInterface(); err != nil {
return errors.New("unable to initialize user manager") return errors.New("unable to initialize user manager")
} }
if err := s.RestoreWireGuardInterface(); err != nil {
return errors.New("unable to restore wirguard state")
}
dir := s.getExecutableDirectory() dir := s.getExecutableDirectory()
rDir, _ := filepath.Abs(filepath.Dir(os.Args[0])) rDir, _ := filepath.Abs(filepath.Dir(os.Args[0]))

View File

@ -164,3 +164,17 @@ func (s *Server) DeleteUser(user User) error {
return nil return nil
} }
func (s *Server) RestoreWireGuardInterface() error {
activeUsers := s.users.GetActiveUsers()
for i := range activeUsers {
if activeUsers[i].Peer == nil {
if err := s.wg.AddPeer(activeUsers[i].GetPeerConfig()); err != nil {
return err
}
}
}
return nil
}