From e0021256960625c168940dabce7b8c2997d7bffe Mon Sep 17 00:00:00 2001 From: chrox Date: Thu, 18 Sep 2014 20:39:46 +0800 Subject: [PATCH] use calibre ip address returned by receivefrom This fixes unresolved hostname issue in some network configurations. --- plugins/calibrecompanion.koplugin/main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/calibrecompanion.koplugin/main.lua b/plugins/calibrecompanion.koplugin/main.lua index dcf2c6dd6..69afa6310 100644 --- a/plugins/calibrecompanion.koplugin/main.lua +++ b/plugins/calibrecompanion.koplugin/main.lua @@ -68,12 +68,12 @@ function CalibreCompanion:find_calibre_server() -- broadcast anything to calibre ports and listen to the reply local sent, err = udp:sendto("hello", "255.255.255.255", port) if not err then - local dgram, err = udp:receivefrom() - if dgram then + local dgram, host = udp:receivefrom() + if dgram and host then -- replied diagram has greet message from calibre and calibre hostname -- calibre opds port and calibre socket port we will later connect to - local _, host, _, port = dgram:match("(.-)%(on (.-)%);(.-),(.-)$") - return socket.dns.toip(host), port + local _, hostname, _, port = dgram:match("(.-)%(on (.-)%);(.-),(.-)$") + return host, port end end end