Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ChpasswdCmd = &cobra.Command{ Use: "chpasswd", Short: "Force change password", Long: `Force change password`, Example: `komari chpasswd -p <password>`, RunE: func(cmd *cobra.Command, args []string) error { if NewPassword == "" { return cmd.Help() } if _, err := os.Stat(flags.DatabaseFile); os.IsNotExist(err) { return fmt.Errorf("database file does not exist") } return withOfflineDatabase(func() error { user := &models.User{} if err := dbcore.GetDBInstance().Model(&models.User{}).First(user).Error; err != nil { return err } cmd.Println("Changing password for user:", user.Username) if err := accounts.ForceResetPassword(user.Username, NewPassword); err != nil { return err } if err := accounts.DeleteAllSessions(); err != nil { return fmt.Errorf("password changed, but unable to force logout of other devices: %w", err) } cmd.Println("Password changed successfully.") cmd.Println("Please restart the server to apply the changes.") return nil }) }, }
View Source
var Disable2FA = &cobra.Command{ Use: "disable-2fa", Short: "Force disable 2FA", Long: `Force disable 2FA`, RunE: func(cmd *cobra.Command, args []string) error { return withOfflineDatabase(func() error { db := dbcore.GetDBInstance() if err := db.Transaction(func(tx *gorm.DB) error { return tx.Model(&models.User{}).Where("two_factor != ?", ""). Update("two_factor", "").Error }); err != nil { return err } cmd.Println("2FA has been disabled.") cmd.Println("Please restart the server to apply the changes.") return nil }) }, }
View Source
var NetcheckCmd = &cobra.Command{ Use: "netcheck <host[:port]>", Short: "探测目标的 ICMP/TCP 可达性并给出监测任务类型建议", Long: `netcheck 会在当前机器上对一个目标做多协议探测: · DNS 解析(A / AAAA) · ICMP ping · TCP 连接(默认 22/80/443) 然后给出结论:该目标适合用 icmp、还是必须用 tcp(以及端口)。 典型用途:在配置延迟监测任务前,先确认目标答应哪种协议。 注意:结论反映的是【当前这台机器】的可达性。`, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { var ports []int for _, s := range strings.Split(ncPorts, ",") { if v, err := strconv.Atoi(strings.TrimSpace(s)); err == nil && v > 0 && v <= 65535 { ports = append(ports, v) } } rep := netcheck.Run(args[0], netcheck.Options{ Ports: ports, Count: ncCount, Timeout: ncTimeout, SkipICMP: ncNoICMP, }) if ncJSON { b, _ := json.MarshalIndent(rep, "", " ") fmt.Println(string(b)) return } printReport(rep) }, }
View Source
var ( //Username string NewPassword string )
View Source
var PermitPasswordLoginCmd = &cobra.Command{ Use: "permit-login", Short: "Force permit password login", Long: `Force permit password login`, RunE: func(cmd *cobra.Command, args []string) error { return withOfflineDatabase(func() error { if err := config.Set(config.DisablePasswordLoginKey, false); err != nil { return err } cmd.Println("Password login has been permitted.") cmd.Println("Please restart the server to apply the changes.") return nil }) }, }
Functions ¶
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.