From d7e1c69c24d0a6e69cf811ae916f0bab46c50e0c Mon Sep 17 00:00:00 2001 From: Maxim Zhuchkov Date: Wed, 4 May 2022 03:38:35 +0300 Subject: [PATCH 1/3] Don't send empty host string in handshake --- bot/mcbot.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bot/mcbot.go b/bot/mcbot.go index 7f0a000..5b89e01 100644 --- a/bot/mcbot.go +++ b/bot/mcbot.go @@ -51,6 +51,9 @@ func (c *Client) join(ctx context.Context, d *mcnet.Dialer, addr string) error { return LoginErr{"parse port", err} } } + if host == "" { + host = addr + } // Dial connection c.Conn, err = d.DialMCContext(ctx, addr) From 97e3a988c457e8384c40abba498c5fef20b52f2f Mon Sep 17 00:00:00 2001 From: Maxim Zhuchkov Date: Wed, 4 May 2022 17:02:34 +0300 Subject: [PATCH 2/3] Less checks --- bot/mcbot.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bot/mcbot.go b/bot/mcbot.go index 5b89e01..1aadd1f 100644 --- a/bot/mcbot.go +++ b/bot/mcbot.go @@ -38,6 +38,7 @@ func (c *Client) join(ctx context.Context, d *mcnet.Dialer, addr string) error { host, portStr, err := net.SplitHostPort(addr) var port uint64 if err != nil { + host = addr var addrErr *net.AddrError const missingPort = "missing port in address" if errors.As(err, &addrErr) && addrErr.Err == missingPort { @@ -51,9 +52,6 @@ func (c *Client) join(ctx context.Context, d *mcnet.Dialer, addr string) error { return LoginErr{"parse port", err} } } - if host == "" { - host = addr - } // Dial connection c.Conn, err = d.DialMCContext(ctx, addr) From 3043305d6a181d6c4434103ac766a7d415f895f2 Mon Sep 17 00:00:00 2001 From: Tnze <19628575+Tnze@users.noreply.github.com> Date: Wed, 4 May 2022 22:11:05 +0800 Subject: [PATCH 3/3] Update mcbot.go --- bot/mcbot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/mcbot.go b/bot/mcbot.go index 1aadd1f..0eff75a 100644 --- a/bot/mcbot.go +++ b/bot/mcbot.go @@ -38,10 +38,10 @@ func (c *Client) join(ctx context.Context, d *mcnet.Dialer, addr string) error { host, portStr, err := net.SplitHostPort(addr) var port uint64 if err != nil { - host = addr var addrErr *net.AddrError const missingPort = "missing port in address" if errors.As(err, &addrErr) && addrErr.Err == missingPort { + host = addr port = 25565 } else { return LoginErr{"split address", err}