Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DomainAddCommand = &cobra.Command{ Use: "add", Short: "Add domain", Long: "Adds a new domain to the database", Run: func(cmd *cobra.Command, args []string) { configuration, err := config.Initialize() if err != nil { logger.Fatalf("domain:add", "failed to initialize configuration: %s", err.Error()) } db := database.NewDatabase( storage.NewStorage(configuration.GetDatabase().GetPath(), 0755), configuration.GetDatabase().GetName(), ) if err := db.Start(); err != nil { logger.Fatalf("domain:add", "failed to start database: %s", err.Error()) } defer db.Stop() domainName := prompt.Text("Domain Name") proxify := prompt.Confirm("Route through proxy") if db.DomainCreate(domainName, proxify) { logger.Infof("domain:add", "domain '%s' added successfully", domainName) pac.NewPac( storage.NewStorage(configuration.GetPac().GetPath(), 0755), configuration.GetPac().GetName(), ).Generate(db.ProxyList(), db.DomainList()) } else { logger.Warnf("domain:add", "failed to add domain '%s'", domainName) } }, }
View Source
var DomainCommand = &cobra.Command{ Use: "domain", Short: "Domain commands", Long: "Displays commands which are related to domain management", Run: func(cmd *cobra.Command, args []string) { if err := cmd.Help(); err != nil { logger.Fatalf("cmd:domain", "error while executing help command: %s", err.Error()) } }, }
View Source
var DomainDeleteCommand = &cobra.Command{ Use: "delete", Short: "Delete domain", Long: "Deletes domain from the database", Run: func(cmd *cobra.Command, args []string) { configuration, err := config.Initialize() if err != nil { logger.Fatalf("domain:delete", "failed to initialize configuration: %s", err.Error()) } db := database.NewDatabase( storage.NewStorage(configuration.GetDatabase().GetPath(), 0755), configuration.GetDatabase().GetName(), ) if err := db.Start(); err != nil { logger.Fatalf("domain:delete", "failed to start database: %s", err.Error()) } defer db.Stop() domainName := prompt.Text("Domain Name") if db.DomainExists(domainName) { delete := prompt.Confirm("Delete domain") if delete { if db.DomainDelete(domainName) { logger.Infof("domain:delete", "domain '%s' deleted successfully", domainName) pac.NewPac( storage.NewStorage(configuration.GetPac().GetPath(), 0755), configuration.GetPac().GetName(), ).Generate(db.ProxyList(), db.DomainList()) } else { logger.Warnf("domain:delete", "failed to delete domain '%s'", domainName) } } } else { logger.Warnf("domain:delete", "domain '%s' does not exist", domainName) } }, }
View Source
var DomainUpdateCommand = &cobra.Command{ Use: "update", Short: "Update domain", Long: "Updates domain", Run: func(cmd *cobra.Command, args []string) { configuration, err := config.Initialize() if err != nil { logger.Fatalf("domain:update", "failed to initialize configuration: %s", err.Error()) } db := database.NewDatabase( storage.NewStorage(configuration.GetDatabase().GetPath(), 0755), configuration.GetDatabase().GetName(), ) if err := db.Start(); err != nil { logger.Fatalf("domain:update", "failed to start database: %s", err.Error()) } defer db.Stop() domainName := prompt.Text("Domain Name") if db.DomainExists(domainName) { proxify := prompt.Confirm("Route through proxy") if db.DomainUpdate(domainName, proxify) { logger.Infof("domain:update", "domain '%s' updated successfully", domainName) pac.NewPac( storage.NewStorage(configuration.GetPac().GetPath(), 0755), configuration.GetPac().GetName(), ).Generate(db.ProxyList(), db.DomainList()) } else { logger.Warnf("domain:update", "failed to update domain '%s'", domainName) } } else { logger.Warnf("domain:update", "domain '%s' does not exist", domainName) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.