Fix protocol version and SRV record issue
This commit is contained in:
4
go.mod
4
go.mod
@@ -5,8 +5,8 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/go-redsync/redsync/v4 v4.11.0
|
github.com/go-redsync/redsync/v4 v4.11.0
|
||||||
github.com/gofiber/fiber/v2 v2.52.0
|
github.com/gofiber/fiber/v2 v2.52.0
|
||||||
github.com/mcstatus-io/mcutil/v3 v3.2.1
|
github.com/mcstatus-io/mcutil/v3 v3.3.0
|
||||||
github.com/redis/go-redis/v9 v9.3.1
|
github.com/redis/go-redis/v9 v9.4.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -31,10 +31,10 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
|
|||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mcstatus-io/mcutil/v3 v3.2.1 h1:xYRomZZCbIXU49955+XvDkUSQ9+/Ezpv1a+klIB2VBI=
|
github.com/mcstatus-io/mcutil/v3 v3.3.0 h1:FnI0hzmCtYGOlYARcdVTqNS+5iYqyo/t/U6YDpBmc8c=
|
||||||
github.com/mcstatus-io/mcutil/v3 v3.2.1/go.mod h1:f1hgiUD3WoNmeZdN1AXYASSEO7yPxVEsLCGXnPkK6p4=
|
github.com/mcstatus-io/mcutil/v3 v3.3.0/go.mod h1:f1hgiUD3WoNmeZdN1AXYASSEO7yPxVEsLCGXnPkK6p4=
|
||||||
github.com/redis/go-redis/v9 v9.3.1 h1:KqdY8U+3X6z+iACvumCNxnoluToB+9Me+TvyFa21Mds=
|
github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk=
|
||||||
github.com/redis/go-redis/v9 v9.3.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
||||||
github.com/redis/rueidis v1.0.19 h1:s65oWtotzlIFN8eMPhyYwxlwLR1lUdhza2KtWprKYSo=
|
github.com/redis/rueidis v1.0.19 h1:s65oWtotzlIFN8eMPhyYwxlwLR1lUdhza2KtWprKYSo=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||||
|
|||||||
@@ -146,6 +146,11 @@ func IconHandler(ctx *fiber.Ctx) error {
|
|||||||
return ctx.Type("png").Send(icon)
|
return ctx.Type("png").Send(icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultIconHandler returns the default server icon.
|
||||||
|
func DefaultIconHandler(ctx *fiber.Ctx) error {
|
||||||
|
return ctx.Type("png").Send(assets.DefaultIcon)
|
||||||
|
}
|
||||||
|
|
||||||
// SendVoteHandler allows sending of Votifier votes to the specified server.
|
// SendVoteHandler allows sending of Votifier votes to the specified server.
|
||||||
func SendVoteHandler(ctx *fiber.Ctx) error {
|
func SendVoteHandler(ctx *fiber.Ctx) error {
|
||||||
opts, err := GetVoteOptions(ctx)
|
opts, err := GetVoteOptions(ctx)
|
||||||
@@ -193,8 +198,3 @@ func SendVoteHandler(ctx *fiber.Ctx) error {
|
|||||||
|
|
||||||
return ctx.Status(http.StatusOK).SendString("The vote was successfully sent to the server")
|
return ctx.Status(http.StatusOK).SendString("The vote was successfully sent to the server")
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultIconHandler returns the default server icon.
|
|
||||||
func DefaultIconHandler(ctx *fiber.Ctx) error {
|
|
||||||
return ctx.Type("png").Send(assets.DefaultIcon)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -272,8 +272,7 @@ func FetchJavaStatus(host string, port uint16, opts *StatusOptions) JavaStatusRe
|
|||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
srvRecord *net.SRV
|
srvRecord *net.SRV
|
||||||
connectionHostname string = host
|
resolvedHost string = host
|
||||||
connectionPort uint16 = port
|
|
||||||
ipAddress *string
|
ipAddress *string
|
||||||
statusResult *response.JavaStatus
|
statusResult *response.JavaStatus
|
||||||
legacyStatusResult *response.JavaStatusLegacy
|
legacyStatusResult *response.JavaStatusLegacy
|
||||||
@@ -295,14 +294,13 @@ func FetchJavaStatus(host string, port uint16, opts *StatusOptions) JavaStatusRe
|
|||||||
srvRecord, err = mcutil.LookupSRV("tcp", host)
|
srvRecord, err = mcutil.LookupSRV("tcp", host)
|
||||||
|
|
||||||
if err == nil && srvRecord != nil {
|
if err == nil && srvRecord != nil {
|
||||||
connectionHostname = strings.Trim(srvRecord.Target, ".")
|
resolvedHost = strings.Trim(srvRecord.Target, ".")
|
||||||
connectionPort = srvRecord.Port
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the connection hostname to an IP address
|
// Resolve the connection hostname to an IP address
|
||||||
{
|
{
|
||||||
addr, err := net.ResolveIPAddr("ip", connectionHostname)
|
addr, err := net.ResolveIPAddr("ip", resolvedHost)
|
||||||
|
|
||||||
if err == nil && addr != nil {
|
if err == nil && addr != nil {
|
||||||
ipAddress = PointerOf(addr.IP.String())
|
ipAddress = PointerOf(addr.IP.String())
|
||||||
@@ -320,9 +318,11 @@ func FetchJavaStatus(host string, port uint16, opts *StatusOptions) JavaStatusRe
|
|||||||
// Retrieve the post-netty rewrite Java Edition status (Minecraft 1.8+)
|
// Retrieve the post-netty rewrite Java Edition status (Minecraft 1.8+)
|
||||||
{
|
{
|
||||||
go func() {
|
go func() {
|
||||||
statusResult, _ = mcutil.Status(statusContext, connectionHostname, connectionPort, options.JavaStatus{
|
statusResult, _ = mcutil.Status(statusContext, host, port, options.JavaStatus{
|
||||||
EnableSRV: false,
|
EnableSRV: true,
|
||||||
Timeout: opts.Timeout - time.Millisecond*100,
|
Timeout: opts.Timeout - time.Millisecond*100,
|
||||||
|
ProtocolVersion: 47,
|
||||||
|
Ping: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@@ -342,9 +342,10 @@ func FetchJavaStatus(host string, port uint16, opts *StatusOptions) JavaStatusRe
|
|||||||
// Retrieve the pre-netty rewrite Java Edition status (Minecraft 1.7 and below)
|
// Retrieve the pre-netty rewrite Java Edition status (Minecraft 1.7 and below)
|
||||||
{
|
{
|
||||||
go func() {
|
go func() {
|
||||||
legacyStatusResult, _ = mcutil.StatusLegacy(legacyContext, connectionHostname, connectionPort, options.JavaStatusLegacy{
|
legacyStatusResult, _ = mcutil.StatusLegacy(legacyContext, host, port, options.JavaStatusLegacy{
|
||||||
EnableSRV: false,
|
EnableSRV: true,
|
||||||
Timeout: opts.Timeout - time.Millisecond*100,
|
Timeout: opts.Timeout - time.Millisecond*100,
|
||||||
|
ProtocolVersion: 47,
|
||||||
})
|
})
|
||||||
|
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@@ -360,7 +361,7 @@ func FetchJavaStatus(host string, port uint16, opts *StatusOptions) JavaStatusRe
|
|||||||
// Retrieve the query information (if it is available)
|
// Retrieve the query information (if it is available)
|
||||||
if opts.Query {
|
if opts.Query {
|
||||||
go func() {
|
go func() {
|
||||||
queryResult, _ = mcutil.FullQuery(queryContext, connectionHostname, connectionPort, options.Query{
|
queryResult, _ = mcutil.FullQuery(queryContext, host, port, options.Query{
|
||||||
Timeout: opts.Timeout - time.Millisecond*100,
|
Timeout: opts.Timeout - time.Millisecond*100,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user