bedrocktool/subcommands/debug.go

39 lines
860 B
Go
Raw Permalink Normal View History

2022-09-05 11:13:43 +00:00
package subcommands
import (
"context"
"flag"
"github.com/bedrock-tool/bedrocktool/locale"
2022-09-05 11:13:43 +00:00
"github.com/bedrock-tool/bedrocktool/utils"
)
type DebugProxyCMD struct {
2023-03-06 01:03:31 +00:00
ServerAddress string
2022-09-05 11:13:43 +00:00
}
func (*DebugProxyCMD) Name() string { return "debug-proxy" }
func (*DebugProxyCMD) Synopsis() string { return locale.Loc("debug_proxy_synopsis", nil) }
2022-09-05 11:13:43 +00:00
func (c *DebugProxyCMD) SetFlags(f *flag.FlagSet) {
2023-03-06 01:03:31 +00:00
f.StringVar(&c.ServerAddress, "address", "", locale.Loc("remote_address", nil))
2023-03-05 21:50:58 +00:00
}
func (c *DebugProxyCMD) Execute(ctx context.Context, ui utils.UI) error {
2023-04-02 14:49:24 +00:00
address, hostname, err := utils.ServerInput(ctx, c.ServerAddress)
2022-09-05 11:13:43 +00:00
if err != nil {
return err
2022-09-05 11:13:43 +00:00
}
2023-03-05 21:50:58 +00:00
utils.Options.Debug = true
2022-09-05 11:13:43 +00:00
2023-03-06 01:03:31 +00:00
proxy, err := utils.NewProxy()
2023-02-12 21:22:44 +00:00
if err != nil {
return err
2022-09-05 11:13:43 +00:00
}
2023-04-02 14:49:24 +00:00
return proxy.Run(ctx, address, hostname)
2022-09-05 11:13:43 +00:00
}
func init() {
utils.RegisterCommand(&DebugProxyCMD{})
}