diff -r ii-1.8/config.mk ii-ssl-1.8/config.mk 13c13 < LIBS = --- > LIBS = -s -lssl -lcrypto diff -r ii-1.8/ii.1 ii-ssl-1.8/ii.1 23a24,25 > .RB [ \-e > .IR ssl ] 43a46,48 > .TP > .BI \-e " ssl" > lets you connect using ssl encryption. The default ssl port is 6697. diff -r ii-1.8/ii.c ii-ssl-1.8/ii.c 21a22,24 > #include > #include > #include 44a48,54 > typedef struct { > int use_ssl; > int irc; > SSL *sslHandle; > SSL_CTX *sslContext; > } conn; > 58,60c68,71 < static void ewritestr(int, const char *); < static void handle_channels_input(int, Channel *); < static void handle_server_output(int); --- > static int swrite(conn *, const char *, size_t); > static void ewritestr(conn *, const char *); > static void handle_channels_input(conn *, Channel *); > static void handle_server_output(conn *); 62,68c73,81 < static void loginkey(int, const char *); < static void loginuser(int, const char *, const char *); < static void proc_channels_input(int, Channel *, char *); < static void proc_channels_privmsg(int, Channel *, char *); < static void proc_server_cmd(int, char *); < static int read_line(int, char *, size_t); < static void run(int, const char *); --- > static void loginkey(conn *, const char *); > static void loginuser(conn *, const char *, const char *); > static void proc_channels_input(conn *, Channel *, char *); > static void proc_channels_privmsg(conn *, Channel *, char *); > static void proc_server_cmd(conn *, char *); > static int sread(conn *, char *, size_t); > static int read_line(conn *, char *, size_t); > static int read_line_from_channel(int, char *, size_t); > static void run(conn *, const char *); 71c84 < static int tcpopen(const char *, const char *); --- > static void tcpopen(conn *ircfd, const char *, const char *); 89c102 < "[-u ] [-n ] [-k ] " --- > "[-e ] [-u ] [-n ] [-k ] " 93a107,115 > static int > swrite(conn *ircfd, const char *msg, size_t len) > { > if (ircfd->use_ssl) > return SSL_write(ircfd->sslHandle, msg, len); > > return write(ircfd->irc, msg, len); > } > 95c117 < ewritestr(int fd, const char *s) --- > ewritestr(conn *fd, const char *s) 102c124 < if ((w = write(fd, s + off, len - off)) == -1) --- > if ((w = swrite(fd, s + off, len - off)) == -1) 322c344 < loginkey(int ircfd, const char *key) --- > loginkey(conn *ircfd, const char *key) 329c351 < loginuser(int ircfd, const char *host, const char *fullname) --- > loginuser(conn *ircfd, const char *host, const char *fullname) 362,363c384,385 < static int < tcpopen(const char *host, const char *service) --- > static void > tcpopen(conn *ircfd, const char *host, const char *service) 367a390,392 > ircfd->sslHandle = NULL; > ircfd->sslContext = NULL; > 396c421,433 < return fd; --- > ircfd->irc = fd; > if (!ircfd->use_ssl) > return; > > //SSL_load_error_strings(); > //SSL_library_init(); > ircfd->sslContext = SSL_CTX_new(SSLv23_client_method()); > if (ircfd->sslContext == NULL) > ERR_print_errors_fp(stderr); > ircfd->sslHandle = SSL_new(ircfd->sslContext); > if (!SSL_set_fd(ircfd->sslHandle, ircfd->irc) || > (SSL_connect(ircfd->sslHandle) != 1)) > ERR_print_errors_fp(stderr); 448c485 < proc_channels_privmsg(int ircfd, Channel *c, char *buf) --- > proc_channels_privmsg(conn *ircfd, Channel *c, char *buf) 457c494 < proc_channels_input(int ircfd, Channel *c, char *buf) --- > proc_channels_input(conn *ircfd, Channel *c, char *buf) 543c580 < proc_server_cmd(int fd, char *buf) --- > proc_server_cmd(conn *fd, char *buf) 663c700,724 < read_line(int fd, char *buf, size_t bufsiz) --- > sread(conn *fd, char *buf, size_t bufsize) > { > if (fd->use_ssl) > return SSL_read(fd->sslHandle, buf, bufsize); > > return read(fd->irc, buf, bufsize); > } > > static int > read_line(conn *fd, char *buf, size_t bufsiz) > { > size_t i = 0; > char c = '\0'; > > do { > if (sread(fd, &c, sizeof(char)) != sizeof(char)) > return -1; > buf[i++] = c; > } while (c != '\n' && i < bufsiz); > buf[i - 1] = '\0'; /* eliminates '\n' */ > return 0; > } > > static int > read_line_from_channel(int fd, char *buf, size_t bufsiz) 678c739 < handle_channels_input(int ircfd, Channel *c) --- > handle_channels_input(conn *ircfd, Channel *c) 682c743 < if (read_line(c->fdin, buf, sizeof(buf)) == -1) { --- > if (read_line_from_channel(c->fdin, buf, sizeof(buf)) == -1) { 691c752 < handle_server_output(int ircfd) --- > handle_server_output(conn *ircfd) 724c785 < run(int ircfd, const char *host) --- > run(conn *ircfd, const char *host) 734c795 < maxfd = ircfd; --- > maxfd = ircfd->irc; 736c797 < FD_SET(ircfd, &rdset); --- > FD_SET(ircfd->irc, &rdset); 758c819 < if (FD_ISSET(ircfd, &rdset)) { --- > if (FD_ISSET(ircfd->irc, &rdset)) { 776c837,839 < const char *uds = NULL, *service = "6667"; --- > const char *uds = NULL; > const char *service = "6667"; > const char *sservice = "6697"; 778c841,842 < int ircfd, r; --- > int r, defaultPort = 1; > conn ircfd; 802a867 > defaultPort = 0; 809a875,879 > case 'e': > if (defaultPort) > service = sservice; > ircfd.use_ssl = 1; > break; 819c889 < ircfd = udsopen(uds); --- > ircfd.irc = udsopen(uds); 821c891 < ircfd = tcpopen(host, service); --- > tcpopen(&ircfd, host, service); 840,841c910,911 < loginkey(ircfd, key); < loginuser(ircfd, host, fullname && *fullname ? fullname : nick); --- > loginkey(&ircfd, key); > loginuser(&ircfd, host, fullname && *fullname ? fullname : nick); 843c913 < run(ircfd, host); --- > run(&ircfd, host); 851a922,929 > if (ircfd.use_ssl) { > SSL_shutdown(ircfd.sslHandle); > SSL_free(ircfd.sslHandle); > SSL_CTX_free(ircfd.sslContext); > } > > close(ircfd.irc); >