Skip to content

Commit f40fedd

Browse files
committed
feat: add flag for disabling SRV lookup in CLI
1 parent 21514ca commit f40fedd

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

cmd/main.go

+23-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/jessevdk/go-flags"
1212
"github.com/mcstatus-io/mcutil/v3"
13+
"github.com/mcstatus-io/mcutil/v3/options"
1314
)
1415

1516
var (
@@ -19,8 +20,9 @@ var (
1920
)
2021

2122
type Options struct {
22-
Type string `short:"t" long:"type" description:"The type of status to retrieve" default:"java"`
23-
Timeout uint `short:"T" long:"timeout" description:"The amount of seconds before the status retrieval times out" default:"5"`
23+
Type string `short:"t" long:"type" description:"The type of status to retrieve" default:"java"`
24+
Timeout uint `short:"T" long:"timeout" description:"The amount of seconds before the status retrieval times out" default:"5"`
25+
DisableSRV bool `short:"S" long:"disable-srv" description:"Disables SRV lookup"`
2426
}
2527

2628
func init() {
@@ -87,25 +89,40 @@ func main() {
8789
switch opts.Type {
8890
case "java":
8991
{
90-
result, err = mcutil.Status(ctx, host, port)
92+
result, err = mcutil.Status(ctx, host, port, options.JavaStatus{
93+
EnableSRV: !opts.DisableSRV,
94+
Timeout: time.Duration(opts.Timeout) * time.Second,
95+
ProtocolVersion: 47,
96+
})
9197

9298
break
9399
}
94100
case "raw":
95101
{
96-
result, err = mcutil.StatusRaw(ctx, host, port)
102+
result, err = mcutil.StatusRaw(ctx, host, port, options.JavaStatus{
103+
EnableSRV: !opts.DisableSRV,
104+
Timeout: time.Duration(opts.Timeout) * time.Second,
105+
ProtocolVersion: 47,
106+
})
97107

98108
break
99109
}
100110
case "legacy":
101111
{
102-
result, err = mcutil.StatusLegacy(ctx, host, port)
112+
result, err = mcutil.StatusLegacy(ctx, host, port, options.JavaStatusLegacy{
113+
EnableSRV: !opts.DisableSRV,
114+
Timeout: time.Duration(opts.Timeout) * time.Second,
115+
ProtocolVersion: 47,
116+
})
103117

104118
break
105119
}
106120
case "bedrock":
107121
{
108-
result, err = mcutil.StatusBedrock(ctx, host, port)
122+
result, err = mcutil.StatusBedrock(ctx, host, port, options.BedrockStatus{
123+
EnableSRV: !opts.DisableSRV,
124+
Timeout: time.Duration(opts.Timeout) * time.Second,
125+
})
109126

110127
break
111128
}

0 commit comments

Comments
 (0)