mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-18 18:32:30 +00:00
✨ Ask for license key input
This commit is contained in:
parent
b11619fbfa
commit
db8c9ec163
45
cmd/pro.go
45
cmd/pro.go
@ -27,7 +27,7 @@ var proCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
const (
|
||||
PRO_URL = "https://master.d2hqi2yb1n0lz7.amplifyapp.com/"
|
||||
PRO_URL = "https://console.kubeshark.co"
|
||||
PRO_PORT = 5252
|
||||
)
|
||||
|
||||
@ -64,6 +64,20 @@ func acquireLicense() {
|
||||
runLicenseRecieverServer()
|
||||
}
|
||||
|
||||
func updateLicense(licenseKey string) {
|
||||
config.Config.License = licenseKey
|
||||
err := config.WriteConfig(&config.Config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
connector.PostLicense(config.Config.License)
|
||||
|
||||
log.Info().Msg("Updated the license. Exiting.")
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func runLicenseRecieverServer() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
ginApp := gin.New()
|
||||
@ -92,20 +106,21 @@ func runLicenseRecieverServer() {
|
||||
|
||||
log.Info().Str("key", licenseKey).Msg("Received license:")
|
||||
|
||||
config.Config.License = licenseKey
|
||||
err = config.WriteConfig(&config.Config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
connector.PostLicense(config.Config.License)
|
||||
|
||||
log.Info().Msg("Updated the license.")
|
||||
|
||||
os.Exit(0)
|
||||
updateLicense(licenseKey)
|
||||
})
|
||||
|
||||
if err := ginApp.Run(fmt.Sprintf(":%d", PRO_PORT)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
if err := ginApp.Run(fmt.Sprintf(":%d", PRO_PORT)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Info().Str("url", PRO_URL).Msg("Opened the login page in your browser:")
|
||||
|
||||
log.Info().Msg("Alternatively enter your license key:")
|
||||
|
||||
var licenseKey string
|
||||
fmt.Scanf("%s", &licenseKey)
|
||||
|
||||
updateLicense(licenseKey)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func InitConfig(cmd *cobra.Command) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cmd.Use != "console" {
|
||||
if cmd.Use != "console" && cmd.Use != "pro" {
|
||||
go version.CheckNewerVersion()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user