summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2003-12-13 11:44:33 +0000
committererdgeist <>2003-12-13 11:44:33 +0000
commitdc6e7bc1160c777a0464de1985501a4e4a046b1e (patch)
tree349a3997e80b163cbb41dbc70ceddc3e6b845b79
parent56453afa766ac8bf74e04d630d06ca2119e7b538 (diff)
Experimental V6 support
-rwxr-xr-xMakefile16
-rwxr-xr-xsample-count.fmt4
-rwxr-xr-xsample-devlog.fmt4
-rwxr-xr-xsample-erdgeist.fmt4
-rwxr-xr-xsample-mAsq.fmt4
-rwxr-xr-xsample-oldstyle.fmt2
-rwxr-xr-xsample-xzivi.fmt4
-rwxr-xr-xvchat-client.c8
-rwxr-xr-xvchat-config.h6
-rwxr-xr-xvchat-protocol.c35
-rwxr-xr-xvchat.h2
11 files changed, 65 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 0342b47..5e14ccd 100755
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ CFLAGS = -Wall -Os
12## use this line when you've got an readline before 4.(x|2) 12## use this line when you've got an readline before 4.(x|2)
13#CFLAGS += -DOLDREADLINE 13#CFLAGS += -DOLDREADLINE
14 14
15CFLAGS += $(OLDREADLINE) 15CFLAGS += $(OLDREADLINE) $(EXPERIMENTAL_IPV6)
16 16
17## you might need one or more of these: 17## you might need one or more of these:
18#CFLAGS += -I/usr/local/ssl/include -L/usr/local/ssl/lib 18#CFLAGS += -I/usr/local/ssl/include -L/usr/local/ssl/lib
@@ -39,6 +39,19 @@ OBJS = vchat-client.o vchat-ui.o vchat-protocol.o vchat-user.o vchat-commands.
39 39
40 40
41all: vchat-client #vchat-client.1 41all: vchat-client #vchat-client.1
42 @echo " ***************************************"
43 @echo " ** **"
44 @echo " ** W A R N I N G **"
45 @echo " ** **"
46 @echo " ** Internal representation of server **"
47 @echo " ** port has changed. If you have got **"
48 @echo " ** a ~/.vchat/formats laying around, **"
49 @echo " ** please verify, that FS_CONNECTED **"
50 @echo " ** and FS_CONSOLE both don't contain **"
51 @echo " ** '%d' and, if they do, please **"
52 @echo " ** change those '%d' to '%s'. **"
53 @echo " ** **"
54 @echo " ***************************************"
42 55
43install: vchat-client vchat-keygen vchatrc.ex 56install: vchat-client vchat-keygen vchatrc.ex
44 install -d $(DESTDIR)/etc 57 install -d $(DESTDIR)/etc
@@ -49,7 +62,6 @@ install: vchat-client vchat-keygen vchatrc.ex
49# install -m 0644 ./vchat-client.1 $(DESTDIR)$(PREFIX)/share/man/man1 62# install -m 0644 ./vchat-client.1 $(DESTDIR)$(PREFIX)/share/man/man1
50 install -m 0644 ./vchatrc.ex $(DESTDIR)/etc/vchatrc 63 install -m 0644 ./vchatrc.ex $(DESTDIR)/etc/vchatrc
51 64
52
53uninstall: 65uninstall:
54 rm -f $(DESTDIR)$(PREFIX)/bin/vchat-client 66 rm -f $(DESTDIR)$(PREFIX)/bin/vchat-client
55 rm -f $(DESTDIR)$(PREFIX)/bin/vchat-keygen 67 rm -f $(DESTDIR)$(PREFIX)/bin/vchat-keygen
diff --git a/sample-count.fmt b/sample-count.fmt
index d008991..bab9751 100755
--- a/sample-count.fmt
+++ b/sample-count.fmt
@@ -42,8 +42,8 @@ FS_IDLE = "^8%s"
42FS_TIME = "^5[%H:%M]-- ^0" 42FS_TIME = "^5[%H:%M]-- ^0"
43FS_TOPICW = "[ Channel %d: %s" 43FS_TOPICW = "[ Channel %d: %s"
44FS_NOTOPICW = "[ Channel %d has no topic" 44FS_NOTOPICW = "[ Channel %d has no topic"
45FS_CONSOLE = "%s@%s:%d, use .h to get help" 45FS_CONSOLE = "%s@%s:%s, use .h to get help"
46FS_CONNECTED = "^2# Connected to '^6%s^2', port ^6%d^2 ..." 46FS_CONNECTED = "^2# Connected to '^6%s^2', port ^6%s^2 ..."
47FS_TOPIC = "^2# Channel ^6%d^2 topic is: '^0%s^2'" 47FS_TOPIC = "^2# Channel ^6%d^2 topic is: '^0%s^2'"
48FS_NOTOPIC = "^2# Channel ^6%d^2 has no topic" 48FS_NOTOPIC = "^2# Channel ^6%d^2 has no topic"
49FS_CHGTOPIC = "^2# ^6%s^2 changes topic to: '^0%s^2'" 49FS_CHGTOPIC = "^2# ^6%s^2 changes topic to: '^0%s^2'"
diff --git a/sample-devlog.fmt b/sample-devlog.fmt
index e70364d..ac30551 100755
--- a/sample-devlog.fmt
+++ b/sample-devlog.fmt
@@ -47,8 +47,8 @@ FS_IDLE = "^8%s"
47FS_TIME = "^2[%H:%M]^0 " 47FS_TIME = "^2[%H:%M]^0 "
48FS_TOPICW = "[ Channel %d: %s" 48FS_TOPICW = "[ Channel %d: %s"
49FS_NOTOPICW = "[ Channel %d has no topic" 49FS_NOTOPICW = "[ Channel %d has no topic"
50FS_CONSOLE = "%s@%s:%d, use .h to get help" 50FS_CONSOLE = "%s@%s:%s, use .h to get help"
51FS_CONNECTED = "^2# Connected to '^0%s^2', port ^0%d^2 ..." 51FS_CONNECTED = "^2# Connected to '^0%s^2', port ^0%s^2 ..."
52FS_TOPIC = "^1# Channel ^6%d^2 topic is: '^0%s^2'" 52FS_TOPIC = "^1# Channel ^6%d^2 topic is: '^0%s^2'"
53FS_NOTOPIC = "^1# Channel ^6%d^2 has no topic" 53FS_NOTOPIC = "^1# Channel ^6%d^2 has no topic"
54FS_CHGTOPIC = "^1# ^4%s^1 changes topic to: '^0%s^1'" 54FS_CHGTOPIC = "^1# ^4%s^1 changes topic to: '^0%s^1'"
diff --git a/sample-erdgeist.fmt b/sample-erdgeist.fmt
index 5fc87e1..7545d3d 100755
--- a/sample-erdgeist.fmt
+++ b/sample-erdgeist.fmt
@@ -42,8 +42,8 @@ FS_TIME = "^9[%H:%M]^0 "
42FS_CONSOLETIME = "[%H:%M] " 42FS_CONSOLETIME = "[%H:%M] "
43FS_TOPICW = "[ Channel %d: %s" 43FS_TOPICW = "[ Channel %d: %s"
44FS_NOTOPICW = "[ Channel %d has no topic" 44FS_NOTOPICW = "[ Channel %d has no topic"
45FS_CONSOLE = "%s@%s:%d, use .h to get help" 45FS_CONSOLE = "%s@%s:%s, use .h to get help"
46FS_CONNECTED = "^2# Connected to '^0%s^2', port ^0%d^2 ..." 46FS_CONNECTED = "^2# Connected to '^0%s^2', port ^0%s^2 ..."
47FS_TOPIC = "^1# Channel ^6%d^2 topic is: '^0%s^2'" 47FS_TOPIC = "^1# Channel ^6%d^2 topic is: '^0%s^2'"
48FS_NOTOPIC = "^1# Channel ^6%d^2 has no topic" 48FS_NOTOPIC = "^1# Channel ^6%d^2 has no topic"
49FS_CHGTOPIC = "^1# ^4%s^1 changes topic to: '^0%s^1'" 49FS_CHGTOPIC = "^1# ^4%s^1 changes topic to: '^0%s^1'"
diff --git a/sample-mAsq.fmt b/sample-mAsq.fmt
index 9bed139..af001d7 100755
--- a/sample-mAsq.fmt
+++ b/sample-mAsq.fmt
@@ -42,8 +42,8 @@ FS_IDLE = "^8%s"
42FS_TIME = "^5%H:%M^0 " 42FS_TIME = "^5%H:%M^0 "
43FS_TOPICW = "[ Channel %d: %s" 43FS_TOPICW = "[ Channel %d: %s"
44FS_NOTOPICW = "[ Channel %d has no topic" 44FS_NOTOPICW = "[ Channel %d has no topic"
45FS_CONSOLE = "%s@%s:%d, use .h to get help" 45FS_CONSOLE = "%s@%s:%s, use .h to get help"
46FS_CONNECTED = "^2*^0C^2* Connected to '^6%s^2', port ^6%d^2 ..." 46FS_CONNECTED = "^2*^0C^2* Connected to '^6%s^2', port ^6%s^2 ..."
47FS_TOPIC = "^2*^0T^2* Channel ^6%d^2 topic is: '^0%s^2'" 47FS_TOPIC = "^2*^0T^2* Channel ^6%d^2 topic is: '^0%s^2'"
48FS_NOTOPIC = "^2*^0T^2* Channel ^6%d^2 has no topic" 48FS_NOTOPIC = "^2*^0T^2* Channel ^6%d^2 has no topic"
49FS_CHGTOPIC = "^5*^0T^2* ^6%s^2 changes topic to: '^0%s^2'" 49FS_CHGTOPIC = "^5*^0T^2* ^6%s^2 changes topic to: '^0%s^2'"
diff --git a/sample-oldstyle.fmt b/sample-oldstyle.fmt
index a1b0eb5..d0d8f17 100755
--- a/sample-oldstyle.fmt
+++ b/sample-oldstyle.fmt
@@ -43,7 +43,7 @@ FS_TIME = "^0%H:%M "
43FS_TOPICW = "Channel %d: %s" 43FS_TOPICW = "Channel %d: %s"
44FS_NOTOPICW = "Channel %d has no topic" 44FS_NOTOPICW = "Channel %d has no topic"
45FS_CONSOLE = "-=- VChat V0.1 -=- type .h for help -=-" 45FS_CONSOLE = "-=- VChat V0.1 -=- type .h for help -=-"
46FS_CONNECTED = "^0* Connected to '%s', port %d ..." 46FS_CONNECTED = "^0* Connected to '%s', port %s ..."
47FS_TOPIC = "^0* Channel %d topic is: '%s'" 47FS_TOPIC = "^0* Channel %d topic is: '%s'"
48FS_NOTOPIC = "^0* Channel %d has no topic" 48FS_NOTOPIC = "^0* Channel %d has no topic"
49FS_CHGTOPIC = "^0* %s changed the channel topic to '%s'" 49FS_CHGTOPIC = "^0* %s changed the channel topic to '%s'"
diff --git a/sample-xzivi.fmt b/sample-xzivi.fmt
index f839366..dbbf2b4 100755
--- a/sample-xzivi.fmt
+++ b/sample-xzivi.fmt
@@ -41,8 +41,8 @@ FS_IDLE = "^1^b%s^B"
41FS_TIME = "^4[%H:%M]^0 " 41FS_TIME = "^4[%H:%M]^0 "
42FS_TOPICW = "Channel %d: %s" 42FS_TOPICW = "Channel %d: %s"
43FS_NOTOPICW = "Channel %d has no topic" 43FS_NOTOPICW = "Channel %d has no topic"
44FS_CONSOLE = "%s@%s:%d" 44FS_CONSOLE = "%s@%s:%s"
45FS_CONNECTED = "# Connected to %s:%d ..." 45FS_CONNECTED = "# Connected to %s:%s ..."
46FS_TOPIC = "# Channel %d topic is: ^6%s" 46FS_TOPIC = "# Channel %d topic is: ^6%s"
47FS_NOTOPIC = "# Channel %d has no topic" 47FS_NOTOPIC = "# Channel %d has no topic"
48FS_CHGTOPIC = "# ^b%s^B changes topic to: ^6%s" 48FS_CHGTOPIC = "# ^b%s^B changes topic to: ^6%s"
diff --git a/vchat-client.c b/vchat-client.c
index a3e7fd2..f30e1c0 100755
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -458,7 +458,7 @@ void usage(unsigned char *name) {
458 puts (" -l local connect (no SSL + connects localhost:2323)"); 458 puts (" -l local connect (no SSL + connects localhost:2323)");
459 puts (" -z don't use certificate files"); 459 puts (" -z don't use certificate files");
460 printf (" -s set server (default \"%s\")\n",getstroption(CF_SERVERHOST)); 460 printf (" -s set server (default \"%s\")\n",getstroption(CF_SERVERHOST));
461 printf (" -p set port (default %d)\n",getintoption(CF_SERVERPORT)); 461 printf (" -p set port (default %s)\n",getstroption(CF_SERVERPORT));
462 printf (" -c set channel (default %d)\n",getintoption(CF_CHANNEL)); 462 printf (" -c set channel (default %d)\n",getintoption(CF_CHANNEL));
463 if (nick) 463 if (nick)
464 printf(" -n set nickname (default \"%s\")\n",nick); 464 printf(" -n set nickname (default \"%s\")\n",nick);
@@ -499,7 +499,7 @@ main (int argc, char **argv)
499 case 'l': setintoption(CF_USESSL,0); break; 499 case 'l': setintoption(CF_USESSL,0); break;
500 case 'z': setintoption(CF_USECERT,0); break; 500 case 'z': setintoption(CF_USECERT,0); break;
501 case 's': setstroption(CF_SERVERHOST,optarg); break; 501 case 's': setstroption(CF_SERVERHOST,optarg); break;
502 case 'p': setintoption(CF_SERVERPORT,strtol(optarg,NULL,10)); break; 502 case 'p': setstroption(CF_SERVERPORT,optarg); break;
503 case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break; 503 case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break;
504 case 'n': setstroption(CF_NICK,optarg); break; 504 case 'n': setstroption(CF_NICK,optarg); break;
505 case 'f': setstroption(CF_FROM,optarg); break; 505 case 'f': setstroption(CF_FROM,optarg); break;
@@ -518,7 +518,7 @@ main (int argc, char **argv)
518 518
519 if (!getintoption(CF_USESSL)) { 519 if (!getintoption(CF_USESSL)) {
520 setstroption(CF_SERVERHOST,"localhost"); 520 setstroption(CF_SERVERHOST,"localhost");
521 setintoption(CF_SERVERPORT,2323); 521 setstroption(CF_SERVERPORT,"2323");
522 } else { 522 } else {
523 SSL_library_init (); 523 SSL_library_init ();
524 SSL_load_error_strings (); 524 SSL_load_error_strings ();
@@ -535,7 +535,7 @@ main (int argc, char **argv)
535 initui (); 535 initui ();
536 536
537 /* attempt connection */ 537 /* attempt connection */
538 if (!vcconnect (getstroption(CF_SERVERHOST), getintoption(CF_SERVERPORT))) 538 if (!vcconnect (getstroption(CF_SERVERHOST), getstroption(CF_SERVERPORT)))
539 { 539 {
540 snprintf (tmpstr, TMPSTRSIZE, "Could not connect to server, %s.", 540 snprintf (tmpstr, TMPSTRSIZE, "Could not connect to server, %s.",
541 sys_errlist[errno]); 541 sys_errlist[errno]);
diff --git a/vchat-config.h b/vchat-config.h
index 856b00c..f011a4c 100755
--- a/vchat-config.h
+++ b/vchat-config.h
@@ -32,7 +32,7 @@ static volatile configoption configoptions[] = {
32 {CF_NICK, CO_STR, "nick", NULL, NULL, { .pstr = &nick } }, 32 {CF_NICK, CO_STR, "nick", NULL, NULL, { .pstr = &nick } },
33 {CF_FROM, CO_STR, "from", "vc-alpha-0.16", NULL, { NULL } }, 33 {CF_FROM, CO_STR, "from", "vc-alpha-0.16", NULL, { NULL } },
34 {CF_SERVERHOST, CO_STR, "host", "pulse.flatline.de",NULL, { NULL } }, 34 {CF_SERVERHOST, CO_STR, "host", "pulse.flatline.de",NULL, { NULL } },
35 {CF_SERVERPORT, CO_INT, "port", (char *) 2325, (char *)-1, { NULL } }, 35 {CF_SERVERPORT, CO_STR, "port", "2325", NULL, { NULL } },
36 {CF_CIPHERSUITE, CO_STR, "ciphers", "HIGH:MEDIUM", NULL, { NULL } }, 36 {CF_CIPHERSUITE, CO_STR, "ciphers", "HIGH:MEDIUM", NULL, { NULL } },
37 {CF_CONFIGFILE, CO_STR, "conffile", "~/.vchat/config", NULL, { NULL } }, 37 {CF_CONFIGFILE, CO_STR, "conffile", "~/.vchat/config", NULL, { NULL } },
38 {CF_CERTFILE, CO_STR, "certfile", "~/.vchat/cert", NULL, { NULL } }, 38 {CF_CERTFILE, CO_STR, "certfile", "~/.vchat/cert", NULL, { NULL } },
@@ -96,8 +96,8 @@ static formatstring formatstrings[] = {
96 FE( FS_CONSOLETIME, "[%H:%M] "), 96 FE( FS_CONSOLETIME, "[%H:%M] "),
97 FE( FS_TOPICW, "[ Channel %d: %s"), 97 FE( FS_TOPICW, "[ Channel %d: %s"),
98 FE( FS_NOTOPICW, "[ Channel %d has no topic"), 98 FE( FS_NOTOPICW, "[ Channel %d has no topic"),
99 FE( FS_CONSOLE, "%s@%s:%d, use .h to get help "), 99 FE( FS_CONSOLE, "%s@%s:%s, use .h to get help "),
100 FE( FS_CONNECTED, "\0012# Connected to '\0016%s\0012', port \0016%d\0012 ..."), 100 FE( FS_CONNECTED, "\0012# Connected to '\0016%s\0012', port \0016%s\0012 ..."),
101 FE( FS_TOPIC, "\0012# Channel \0016%d\0012 topic is: '\0010%s\0012'"), 101 FE( FS_TOPIC, "\0012# Channel \0016%d\0012 topic is: '\0010%s\0012'"),
102 FE( FS_NOTOPIC, "\0012# Channel \0016%d\0012 has no topic"), 102 FE( FS_NOTOPIC, "\0012# Channel \0016%d\0012 has no topic"),
103 FE( FS_CHGTOPIC, "\0012# \0016%s\0012 changes topic to: '\0010%s\0012'"), 103 FE( FS_CHGTOPIC, "\0012# \0016%s\0012 changes topic to: '\0010%s\0012'"),
diff --git a/vchat-protocol.c b/vchat-protocol.c
index f1e8b5c..03161e0 100755
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -83,7 +83,7 @@ unsigned char *encoding;
83 83
84/* connects to server */ 84/* connects to server */
85int 85int
86vcconnect (unsigned char *server, unsigned int port) 86vcconnect (unsigned char *server, unsigned char *port)
87{ 87{
88 /* used for tilde expansion of cert & key filenames */ 88 /* used for tilde expansion of cert & key filenames */
89 unsigned char *tildex = NULL; 89 unsigned char *tildex = NULL;
@@ -98,10 +98,16 @@ vcconnect (unsigned char *server, unsigned int port)
98 EVP_PKEY *certpubkey = NULL; 98 EVP_PKEY *certpubkey = NULL;
99 /* temporary result */ 99 /* temporary result */
100 int result; 100 int result;
101#ifndef EXPERIMENTAL_IPV6
101 /* servers hostentry */ 102 /* servers hostentry */
102 struct hostent *serverhe; 103 struct hostent *serverhe;
103 /* servers sockaddr */ 104 /* servers sockaddr */
104 struct sockaddr_in serversi; 105 struct sockaddr_in serversi;
106 int portnr = strtoul(port,NULL,10);
107#else
108 /* protocol independent server addresses */
109 struct addrinfo hints, *addr, *tmpaddr;
110#endif
105 /* SSL-context */ 111 /* SSL-context */
106 SSL_CTX *sslctx = NULL; 112 SSL_CTX *sslctx = NULL;
107 /* SSL server certificate */ 113 /* SSL server certificate */
@@ -115,6 +121,7 @@ vcconnect (unsigned char *server, unsigned int port)
115 /* variable for verify return */ 121 /* variable for verify return */
116 long verify; 122 long verify;
117 123
124#ifndef EXPERIMENTAL_IPV6
118 /* get host-entry for server */ 125 /* get host-entry for server */
119 if ((serverhe = gethostbyname (server)) == NULL) 126 if ((serverhe = gethostbyname (server)) == NULL)
120 return 0; 127 return 0;
@@ -125,13 +132,35 @@ vcconnect (unsigned char *server, unsigned int port)
125 132
126 /* initialize datastructure for connect */ 133 /* initialize datastructure for connect */
127 serversi.sin_family = AF_INET; 134 serversi.sin_family = AF_INET;
128 serversi.sin_port = htons (port); 135 serversi.sin_port = htons(portnr);
129 serversi.sin_addr = *((struct in_addr *) serverhe->h_addr); 136 serversi.sin_addr = *((struct in_addr *) serverhe->h_addr);
130 memset (&(serversi.sin_zero), 0, 8); 137 memset (&(serversi.sin_zero), 0, 8);
131 138
132 /* attempt connect */ 139 /* attempt connect */
133 if (connect (serverfd, (struct sockaddr *) &serversi, sizeof (struct sockaddr)) == -1) 140 if (connect (serverfd, (struct sockaddr *) &serversi, sizeof (struct sockaddr)) == -1)
134 return 0; 141 return 0;
142#else
143 memset( &hints, 0, sizeof(hints));
144 /* Expect v4 and v6 */
145 hints.ai_family = PF_UNSPEC;
146 hints.ai_socktype = SOCK_STREAM;
147 if( getaddrinfo( server, port, &hints, &addr ))
148 return 0;
149 for( tmpaddr = addr; addr; addr = addr->ai_next )
150 {
151 if( (serverfd = socket( addr->ai_family, addr->ai_socktype, addr->ai_protocol)) < 0)
152 continue;
153 if( connect( serverfd, addr->ai_addr, addr->ai_addrlen ) < 0)
154 {
155 close( serverfd );
156 continue;
157 }
158 break;
159 }
160 if( serverfd < 0 )
161 return 0;
162 freeaddrinfo( tmpaddr );
163#endif
135 164
136 /* inform user */ 165 /* inform user */
137 snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_CONNECTED), server, port); 166 snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_CONNECTED), server, port);
@@ -537,7 +566,7 @@ justloggedin (unsigned char *message)
537 setstroption(CF_NICK,str1); 566 setstroption(CF_NICK,str1);
538 567
539 /* show change in console window */ 568 /* show change in console window */
540 snprintf (consolestr, CONSOLESTRSIZE, getformatstr(FS_CONSOLE), nick, getstroption (CF_SERVERHOST), getintoption (CF_SERVERPORT)); 569 snprintf (consolestr, CONSOLESTRSIZE, getformatstr(FS_CONSOLE), nick, getstroption (CF_SERVERHOST), getstroption (CF_SERVERPORT));
541 consoleline (NULL); 570 consoleline (NULL);
542 571
543 /* announce login as servermessage */ 572 /* announce login as servermessage */
diff --git a/vchat.h b/vchat.h
index ec5da02..fcae04f 100755
--- a/vchat.h
+++ b/vchat.h
@@ -181,7 +181,7 @@ void clearfilters ( char colour );
181extern unsigned char *vchat_io_version; 181extern unsigned char *vchat_io_version;
182 182
183/* connect/disconnect */ 183/* connect/disconnect */
184int vcconnect (unsigned char *server, unsigned int port); 184int vcconnect (unsigned char *server, unsigned char *port);
185void vcdisconnect (); 185void vcdisconnect ();
186 186
187/* network I/O */ 187/* network I/O */