summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2013-07-15 19:06:35 +0000
committererdgeist <>2013-07-15 19:06:35 +0000
commitf409a5e841d91237fe4034818955dd88167a679b (patch)
treebebaf6f812c1278357294f80b46bba8ff0883134
parent959d7d76aec53f03463223ee64afb805e1865464 (diff)
add a global tcp-keepalive-option. thanks to Fefe
-rwxr-xr-xvchat-client.c2
-rwxr-xr-xvchat-config.h1
-rwxr-xr-xvchat-protocol.c7
-rwxr-xr-xvchat.h3
4 files changed, 11 insertions, 2 deletions
diff --git a/vchat-client.c b/vchat-client.c
index 71a596c..f5cd516 100755
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -43,6 +43,8 @@ int status = 1;
43int ownquit = 0; 43int ownquit = 0;
44/* we set this, we DONT want to quit */ 44/* we set this, we DONT want to quit */
45int wantreconnect = 0; 45int wantreconnect = 0;
46unsigned int want_tcp_keepalive = 0;
47
46static int reconnect_delay = 6; 48static int reconnect_delay = 6;
47static time_t reconnect_time = 0; 49static time_t reconnect_time = 0;
48 50
diff --git a/vchat-config.h b/vchat-config.h
index 96fed27..8392d18 100755
--- a/vchat-config.h
+++ b/vchat-config.h
@@ -55,6 +55,7 @@ static volatile configoption configoptions[] = {
55 {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, 55 {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } },
56 {CF_CASEFIRST, CO_INT, "casefirst", (char *) 0, (char *)-1, { .pint = &ul_case_first } }, 56 {CF_CASEFIRST, CO_INT, "casefirst", (char *) 0, (char *)-1, { .pint = &ul_case_first } },
57 {CF_AUTORECONN, CO_INT, "autoreconn", (char *) 0, (char *)-1, { NULL } }, 57 {CF_AUTORECONN, CO_INT, "autoreconn", (char *) 0, (char *)-1, { NULL } },
58 {CF_KEEPALIVE, CO_INT, "keepalive", (char *) 0, (char *)-1, { .pint = &want_tcp_keepalive } },
58 {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, 59 {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } },
59}; 60};
60 61
diff --git a/vchat-protocol.c b/vchat-protocol.c
index b9a5e15..b50f511 100755
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -92,6 +92,11 @@ static int connect_socket( char *server, char *port ) {
92 break; /* okay we got one */ 92 break; /* okay we got one */
93 } 93 }
94 freeaddrinfo(res0); 94 freeaddrinfo(res0);
95
96 if (want_tcp_keepalive) { /* global from vchat-client.c */
97 int one=1;
98 setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,&one,sizeof(one));
99 }
95 return s; 100 return s;
96} 101}
97 102
@@ -373,7 +378,7 @@ justloggedin (char *message)
373 /* we're not logged in, change status and request nicks */ 378 /* we're not logged in, change status and request nicks */
374 if (!loggedin) 379 if (!loggedin)
375 { 380 {
376 loadcfg(getstroption(CF_LOGINSCRIPT),handleline); 381 loadcfg(getstroption(CF_LOGINSCRIPT),0,handleline);
377 handleline(".S"); 382 handleline(".S");
378 loggedin = 1; 383 loggedin = 1;
379 } 384 }
diff --git a/vchat.h b/vchat.h
index 7b6e0d3..1a24973 100755
--- a/vchat.h
+++ b/vchat.h
@@ -33,7 +33,7 @@ typedef enum { CF_NIL, CF_NICK, CF_FROM, CF_SERVERHOST, CF_SERVERPORT,
33CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT, 33CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT,
34CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME, 34CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME,
35CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, 35CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT,
36CF_ENCODING, CF_BELLPRIV, CF_CASEFIRST, CF_AUTORECONN } confopt; 36CF_ENCODING, CF_BELLPRIV, CF_CASEFIRST, CF_AUTORECONN, CF_KEEPALIVE } confopt;
37 37
38/* format strings */ 38/* format strings */
39typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, 39typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR,
@@ -75,6 +75,7 @@ typedef struct formatstring formatstring;
75static char tmpstr[TMPSTRSIZE]; 75static char tmpstr[TMPSTRSIZE];
76 76
77extern unsigned int loggedin; 77extern unsigned int loggedin;
78extern unsigned int want_tcp_keepalive;
78 79
79/* vchat-client.c */ 80/* vchat-client.c */
80#define ERRSTRSIZE 1024 81#define ERRSTRSIZE 1024