diff --git a/go.mod b/go.mod index acb0445..405bddb 100644 --- a/go.mod +++ b/go.mod @@ -70,6 +70,7 @@ require ( github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/twitchtv/twirp v8.1.3+incompatible // indirect + github.com/urfave/cli/v3 v3.5.0 // indirect github.com/wlynxg/anet v0.0.5 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect go.uber.org/atomic v1.11.0 // indirect diff --git a/go.sum b/go.sum index 2e02b93..d4b6a5a 100644 --- a/go.sum +++ b/go.sum @@ -205,6 +205,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU= github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A= +github.com/urfave/cli/v3 v3.5.0 h1:qCuFMmdayTF3zmjG8TSsoBzrDqszNrklYg2x3g4MSgw= +github.com/urfave/cli/v3 v3.5.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU= github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= diff --git a/main.go b/main.go index b90b256..50a0886 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,10 @@ import ( "time" + "lk-jwt-service/version" + + "github.com/urfave/cli/v3" + "github.com/livekit/protocol/auth" "github.com/livekit/protocol/livekit" lksdk "github.com/livekit/server-sdk-go/v2" @@ -304,7 +308,7 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) { } } -func main() { +func startServer(_ context.Context, c *cli.Command) error { skipVerifyTLS := os.Getenv("LIVEKIT_INSECURE_SKIP_VERIFY_TLS") == "YES_I_KNOW_WHAT_I_AM_DOING" if skipVerifyTLS { log.Printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") @@ -356,4 +360,23 @@ func main() { } log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", lkJwtPort), handler.prepareMux())) -} \ No newline at end of file + + return nil +} + +func main() { + + //version := "0.3.0" + + cmd := &cli.Command{ + Name: "lk-jwt-service", + Usage: "MatrixRTC Authorization Service", + Description: "run without subcommands to start the server", + Action: startServer, + Version: version.Version, + } + + if err := cmd.Run(context.Background(), os.Args); err != nil { + fmt.Println(err) + } +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..43fb29b --- /dev/null +++ b/version/version.go @@ -0,0 +1,9 @@ +// Copyright 2023 New Vector Ltd +// Copyright 2025 New Vector Ltd +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. + +package version + +const Version = "0.3.0"