Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions client/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ func doDaemonLogin(ctx context.Context, cmd *cobra.Command, providedSetupKey str
loginRequest.OptionalPreSharedKey = &preSharedKey
}

// set the new config
cfg, err := client.GetConfig(ctx, &proto.GetConfigRequest{
ProfileName: activeProf.Name,
Username: username,
})
if err != nil {
return fmt.Errorf("get config from daemon: %v", err)
}

req := setupSetConfigReqForLogin(cfg, activeProf.Name, username)
if _, err := client.SetConfig(ctx, req); err != nil {
if st, ok := gstatus.FromError(err); ok && st.Code() == codes.Unavailable {
log.Warnf("setConfig method is not available in the daemon")
} else {
return fmt.Errorf("call service setConfig method: %v", err)
}
}

var loginErr error

var loginResp *proto.LoginResponse
Expand Down Expand Up @@ -383,3 +401,28 @@ func setEnvAndFlags(cmd *cobra.Command) error {

return nil
}

func setupSetConfigReqForLogin(cfg *proto.GetConfigResponse, profileName, username string) *proto.SetConfigRequest {
var req proto.SetConfigRequest
req.ProfileName = profileName
req.Username = username

req.ManagementUrl = managementURL
req.AdminURL = adminURL

req.RosenpassEnabled = &cfg.RosenpassEnabled
req.RosenpassPermissive = &cfg.RosenpassPermissive
req.DisableAutoConnect = &cfg.DisableAutoConnect
req.ServerSSHAllowed = &cfg.ServerSSHAllowed
req.NetworkMonitor = &cfg.NetworkMonitor
req.DisableClientRoutes = &cfg.DisableClientRoutes
req.DisableServerRoutes = &cfg.DisableServerRoutes
req.DisableDns = &cfg.DisableDns
req.DisableFirewall = &cfg.DisableFirewall
req.BlockLanAccess = &cfg.BlockLanAccess
req.DisableNotifications = &cfg.DisableNotifications
req.LazyConnectionEnabled = &cfg.LazyConnectionEnabled
req.BlockInbound = &cfg.BlockInbound

return &req
}
20 changes: 15 additions & 5 deletions client/proto/daemon.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions client/proto/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ message GetConfigResponse {
bool disable_server_routes = 19;

bool block_lan_access = 20;

bool disable_firewall = 21;
}

// PeerState contains the latest state of a peer
Expand Down
2 changes: 2 additions & 0 deletions client/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ func (s *Server) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*p
disableClientRoutes := cfg.DisableClientRoutes
disableServerRoutes := cfg.DisableServerRoutes
blockLANAccess := cfg.BlockLANAccess
disableFirewall := cfg.DisableFirewall

return &proto.GetConfigResponse{
ManagementUrl: managementURL.String(),
Expand All @@ -1147,6 +1148,7 @@ func (s *Server) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*p
DisableClientRoutes: disableClientRoutes,
DisableServerRoutes: disableServerRoutes,
BlockLanAccess: blockLANAccess,
DisableFirewall: disableFirewall,
}, nil
}

Expand Down
Loading