diff --git a/hooks/run.go b/hooks/run.go index 7c00500..2e006fe 100644 --- a/hooks/run.go +++ b/hooks/run.go @@ -29,6 +29,7 @@ import ( ) var NodeApp = app.New() +var AllowedCmdPattern = `^[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*$` func Run(cmd *cobra.Command, args []string) { NodeApp.InitialHooks( @@ -60,7 +61,7 @@ func RunHook(ctx context.Context, cs *corestate.CoreState, x *app.AppX) error { serverv1 := sv1.InitV1Server(&sv1.HandlerV1InitStruct{ X: x, CS: cs, - AllowedCmd: regexp.MustCompile(`^[a-zA-Z0-9]+(>[a-zA-Z0-9]+)*$`), + AllowedCmd: regexp.MustCompile(AllowedCmdPattern), Ver: "v1", }) diff --git a/internal/server/sv1/path.go b/internal/server/sv1/path.go index dc35b6c..a58692a 100644 --- a/internal/server/sv1/path.go +++ b/internal/server/sv1/path.go @@ -9,12 +9,14 @@ import ( "github.com/akyaiy/GoSally-mvp/internal/server/rpc" ) +var RPCMethodSeparator = "." + func (h *HandlerV1) resolveMethodPath(method string) (string, error) { if !h.allowedCmd.MatchString(method) { return "", errors.New(rpc.ErrInvalidMethodFormatS) } - parts := strings.Split(method, ">") + parts := strings.Split(method, RPCMethodSeparator) relPath := filepath.Join(parts...) + ".lua" fullPath := filepath.Join(*h.x.Config.Conf.Node.ComDir, relPath)