From 4492ad9328e59edc4c8d3db8cd881941b7903741 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Fri, 12 Jun 2020 01:19:20 +0200 Subject: Send real hostname and port in idle check --- idle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'idle.c') diff --git a/idle.c b/idle.c index e1a73ea..0607a61 100644 --- a/idle.c +++ b/idle.c @@ -287,7 +287,8 @@ idle_check_connected_cb(struct cfg *cfg, struct connection *conn, bool connected char buf[1024]; char *pos; char *cmdbuf = idle->tbuf.buf; - uint16_t port = 25565; + uint16_t port; + char hostname[INET6_ADDRSTRLEN]; if (!connected) { fprintf(stderr, "%s: idle check connection to remote server failed\n", @@ -298,11 +299,14 @@ idle_check_connected_cb(struct cfg *cfg, struct connection *conn, bool connected fprintf(stderr, "%s: connected to remote %s\n", __func__, idle->conn.remotestr); + port = sockaddr_port(&conn->remote); + sockaddr_addr(&conn->remote, hostname, sizeof(hostname)); + pos = buf; write_byte(&pos, MC_HELO); write_varint(&pos, -1); /* Protocol version, -1 = undefined */ - write_varint(&pos, strlen("hostname")); - write_str(&pos, "hostname"); + write_varint(&pos, strlen(hostname)); + write_str(&pos, hostname); write_byte(&pos, (port >> 8) & 0xff); write_byte(&pos, (port >> 0) & 0xff); write_byte(&pos, MC_NEXT_STATE_STATUS); -- cgit v1.2.3