sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 92965b1f1ab596991c5811aef21e0ea848067810
parent 6e3450a047c5f7eda300f68814f7b1dfd499119e
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date:   Sat,  7 May 2016 03:42:36 +0200

ii: add patch for ucspi support

Diffstat:
Atools.suckless.org/ii/patches/ii-1.7-ucspi.diff | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools.suckless.org/ii/patches/ucspi.md | 20++++++++++++++++++++
2 files changed, 185 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/ii/patches/ii-1.7-ucspi.diff b/tools.suckless.org/ii/patches/ii-1.7-ucspi.diff @@ -0,0 +1,165 @@ +diff --git a/ii.1 b/ii.1 +index dd1f6e3..c293c37 100644 +--- a/ii.1 ++++ b/ii.1 +@@ -20,6 +20,10 @@ server with basic command line tools. + For example if you will join a channel just do echo "/j #channel" > in + and ii creates a new channel directory with in and out file. + .SH SYNOPSIS ++.B tcpclient ++host ++port ++.RB [ tlsc ] + .B ii + .RB [ \-s + .IR servername ] +@@ -93,5 +97,7 @@ Write to ii (at) modprobe (dot) de for suggestions, fixes, 7|-|>< ;) etc. + Copyright \(co 2005-2006 by Anselm R. Garbe <garbeam (at) gmail (dot) com> and + Copyright \(co 2005-2008 by Nico Golde <nico (at) ngolde (dot) de> + .SH SEE ALSO ++.BR tcpclient(1), ++.BR tlsc(1), + .BR echo (1), + .BR tail (1), +diff --git a/ii.c b/ii.c +index d93266c..5305869 100644 +--- a/ii.c ++++ b/ii.c +@@ -5,9 +5,7 @@ + #include <netdb.h> + #include <sys/types.h> + #include <sys/stat.h> +-#include <sys/socket.h> + #include <sys/select.h> +-#include <netinet/in.h> + #include <stdio.h> + #include <stdlib.h> + #include <limits.h> +@@ -19,6 +17,9 @@ + #include <time.h> + #include <unistd.h> + ++#define READ_FD 6 ++#define WRITE_FD 7 ++ + #ifndef PIPE_BUF /* FreeBSD don't know PIPE_BUF */ + #define PIPE_BUF 4096 + #endif +@@ -33,7 +34,6 @@ struct Channel { + Channel *next; + }; + +-static int irc; + static time_t last_response; + static Channel *channels = NULL; + static char *host = "irc.freenode.net"; +@@ -148,31 +148,7 @@ static void login(char *key, char *fullname) { + nick, nick, host, fullname ? fullname : nick); + else snprintf(message, PIPE_BUF, "NICK %s\r\nUSER %s localhost %s :%s\r\n", + nick, nick, host, fullname ? fullname : nick); +- write(irc, message, strlen(message)); /* login */ +-} +- +-static int tcpopen(unsigned short port) { +- int fd; +- struct sockaddr_in sin; +- struct hostent *hp = gethostbyname(host); +- +- memset(&sin, 0, sizeof(struct sockaddr_in)); +- if(!hp) { +- perror("ii: cannot retrieve host information"); +- exit(EXIT_FAILURE); +- } +- sin.sin_family = AF_INET; +- memcpy(&sin.sin_addr, hp->h_addr, hp->h_length); +- sin.sin_port = htons(port); +- if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { +- perror("ii: cannot create socket"); +- exit(EXIT_FAILURE); +- } +- if(connect(fd, (const struct sockaddr *) &sin, sizeof(sin)) < 0) { +- perror("ii: cannot connect to host"); +- exit(EXIT_FAILURE); +- } +- return fd; ++ write(WRITE_FD, message, strlen(message)); /* login */ + } + + static size_t tokenize(char **result, size_t reslen, char *str, char delim) { +@@ -219,7 +195,7 @@ static void proc_channels_privmsg(char *channel, char *buf) { + snprintf(message, PIPE_BUF, "<%s> %s", nick, buf); + print_out(channel, message); + snprintf(message, PIPE_BUF, "PRIVMSG %s :%s\r\n", channel, buf); +- write(irc, message, strlen(message)); ++ write(WRITE_FD, message, strlen(message)); + } + + static void proc_channels_input(Channel *c, char *buf) { +@@ -273,7 +249,7 @@ static void proc_channels_input(Channel *c, char *buf) { + else + snprintf(message, PIPE_BUF, + "PART %s :ii - 500 SLOC are too much\r\n", c->name); +- write(irc, message, strlen(message)); ++ write(WRITE_FD, message, strlen(message)); + close(c->fd); + /*create_filepath(infile, sizeof(infile), c->name, "in"); + unlink(infile); */ +@@ -288,7 +264,7 @@ static void proc_channels_input(Channel *c, char *buf) { + snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]); + + if (message[0] != '\0') +- write(irc, message, strlen(message)); ++ write(WRITE_FD, message, strlen(message)); + } + + static void proc_server_cmd(char *buf) { +@@ -339,7 +315,7 @@ static void proc_server_cmd(char *buf) { + return; + } else if(!strncmp("PING", argv[TOK_CMD], 5)) { + snprintf(message, PIPE_BUF, "PONG %s\r\n", argv[TOK_TEXT]); +- write(irc, message, strlen(message)); ++ write(WRITE_FD, message, strlen(message)); + return; + } else if(!argv[TOK_NICKSRV] || !argv[TOK_USER]) { /* server command */ + snprintf(message, PIPE_BUF, "%s%s", argv[TOK_ARG] ? argv[TOK_ARG] : "", argv[TOK_TEXT] ? argv[TOK_TEXT] : ""); +@@ -402,7 +378,7 @@ static void handle_channels_input(Channel *c) { + + static void handle_server_output() { + static char buf[PIPE_BUF]; +- if(read_line(irc, PIPE_BUF, buf) == -1) { ++ if(read_line(READ_FD, PIPE_BUF, buf) == -1) { + perror("ii: remote host closed connection"); + exit(EXIT_FAILURE); + } +@@ -419,8 +395,8 @@ static void run() { + snprintf(ping_msg, sizeof(ping_msg), "PING %s\r\n", host); + for(;;) { + FD_ZERO(&rd); +- maxfd = irc; +- FD_SET(irc, &rd); ++ maxfd = READ_FD; ++ FD_SET(READ_FD, &rd); + for(c = channels; c; c = c->next) { + if(maxfd < c->fd) + maxfd = c->fd; +@@ -440,10 +416,10 @@ static void run() { + print_out(NULL, "-!- ii shutting down: ping timeout"); + exit(EXIT_FAILURE); + } +- write(irc, ping_msg, strlen(ping_msg)); ++ write(WRITE_FD, ping_msg, strlen(ping_msg)); + continue; + } +- if(FD_ISSET(irc, &rd)) { ++ if(FD_ISSET(READ_FD, &rd)) { + handle_server_output(); + last_response = time(NULL); + } +@@ -479,7 +455,6 @@ int main(int argc, char *argv[]) { + default: usage(); break; + } + } +- irc = tcpopen(port); + if(!snprintf(path, sizeof(path), "%s/%s", prefix, host)) { + fputs("ii: path to irc directory too long\n", stderr); + exit(EXIT_FAILURE); diff --git a/tools.suckless.org/ii/patches/ucspi.md b/tools.suckless.org/ii/patches/ucspi.md @@ -0,0 +1,20 @@ +UCSPI +===== + +Description +----------- + +Replaces the socket back-end with the [ucspi](https://cr.yp.to/proto/ucspi.txt). +This makes ii more flexable and outsources the handling of IPv6, TLS and SOCKS +to other tools like [tcpclient](https://cr.yp.to/ucspi-tcp.html), +[tlc and socks](https://github.com/younix/ucspi). + +Download +-------- + +* [ii-1.7-ucspi.diff](ii-1.7-ucspi.diff) + +Author +------ + +* Jan Klemkow (younix) <[j.klemkow@wemelug.de](mailto:j.klemkow@wemelug.de)>