diff options
Diffstat (limited to 'idle.c')
-rw-r--r-- | idle.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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); |