Noah Petherbridge
a06787411d
* pkg/plus/dpp is the main plugin bridge, and defines nothing but an interface that defines the Doodle++ surface area (referring to internal game types such as doodad.Doodad or level.Level), but not their implementations. * dpp.Driver (an interface) is the main API that other parts of the game will call, for example "dpp.Driver.IsLevelSigned()" * plus_dpp.go and plus_foss.go provide the dpp.Driver implementation for their build; with plus_dpp.go generally forwarding function calls directly to the proprietary dpp package and plus_foss.go generally returning false/errors. * The bootstrap package simply assigns the above stub function to dpp.Driver * pkg/plus/bootstrap is a package directly imported by main (in the doodle and doodad programs) and it works around circular dependency issues: this package simply assigns dpp.Driver to the DPP or FOSS version. Miscellaneous fixes: * File->Open in the editor and PlayScene will use the new Open Level window instead of loading the legacy GotoLoadMenu scene. * Deprecated legacy scenes: d.GotoLoadMenu() and d.GotoPlayMenu(). * The doodle-admin program depends on the private dpp package, so can not be compiled in FOSS mode.
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package command
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"time"
|
|
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
|
"git.kirsle.net/SketchyMaze/dpp/license"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Verify a license key for Sketchy Maze.
|
|
var Verify *cli.Command
|
|
|
|
func init() {
|
|
Verify = &cli.Command{
|
|
Name: "verify",
|
|
Usage: "check the signature on a license key",
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "key",
|
|
Aliases: []string{"k"},
|
|
Usage: "Public key .pem file that signed the JWT",
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "filename",
|
|
Aliases: []string{"f"},
|
|
Usage: "File name of the license file to validate",
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(c *cli.Context) error {
|
|
key, err := license.AdminLoadPublicKey(c.String("key"))
|
|
if err != nil {
|
|
return cli.Exit(err.Error(), 1)
|
|
}
|
|
|
|
jwt, err := ioutil.ReadFile(c.String("filename"))
|
|
if err != nil {
|
|
return cli.Exit(err.Error(), 1)
|
|
}
|
|
|
|
reg, err := license.Validate(key, string(jwt))
|
|
if err != nil {
|
|
return cli.Exit(err.Error(), 1)
|
|
}
|
|
|
|
log.Info("Registration valid")
|
|
log.Info(" Name: %s", reg.Name)
|
|
log.Info(" Email: %s", reg.Email)
|
|
log.Info(" Issued: %s", time.Unix(reg.IssuedAt, 0))
|
|
log.Info(" NBF: %s", time.Unix(reg.NotBefore, 0))
|
|
log.Info("Raw:\n%+v", reg)
|
|
|
|
return nil
|
|
},
|
|
}
|
|
}
|