From 15141506721dd33792ca9da3385ca93104182511 Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Fri, 5 Aug 2022 16:21:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B4=D1=83=D0=B1=D0=BB=D0=B8=D1=80=D0=B2?= =?UTF-8?q?=D0=BE=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20host=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9,=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20CMake-=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=D0=B8=20FreeRDP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.c | 8 +++++--- gui.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db.c b/db.c index 0ea5ddc..ff768cf 100644 --- a/db.c +++ b/db.c @@ -252,10 +252,11 @@ int dbAddServer(char *ip, char *dns) } sqlite3_stmt *res; - char *sql = "SELECT * FROM `hosts` WHERE `ip` = ?"; + char *sql = "SELECT * FROM `hosts` WHERE `ip` = ? OR `dns` = ?"; if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK) { sqlite3_bind_text(res, 1, ip, -1, 0); + sqlite3_bind_text(res, 2, dns, -1, 0); } else { @@ -272,12 +273,13 @@ int dbAddServer(char *ip, char *dns) sql = "UPDATE `hosts` set `set` = 0"; if (sqlite3_exec(db, sql, NULL, NULL, NULL) == SQLITE_OK) { - sql = "UPDATE `hosts` set `dns` = ?, `set` = 1 where id = ?"; + sql = "UPDATE `hosts` set `dns` = ?, `ip` = ?, `set` = 1 where id = ?"; if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK) { sqlite3_bind_text(res, 1, dns, -1, 0); - sqlite3_bind_int(res, 2, id); + sqlite3_bind_text(res, 2, ip, -1, 0); + sqlite3_bind_int(res, 3, id); } if (sqlite3_step(res) == SQLITE_BUSY) diff --git a/gui.c b/gui.c index 4ad1325..6df7d02 100644 --- a/gui.c +++ b/gui.c @@ -47,9 +47,9 @@ static int guiConnect(Ihandle *self) // if (free_rdp_connect(args.argc, args.argv) != XF_EXIT_DNS_NAME_NOT_FOUND) // { - dbInsertHistory(login, host); if (!dbAddServer(result, host)) { + dbInsertHistory(login, host); IupSetAttribute(IupGetDialogChild(self, "SERVER"), "APPENDITEM", host); } dbSetUserNameCurrent(login);