--- protocol.c.orig Sun Sep 30 13:21:15 2001 +++ protocol.c Sun Sep 30 13:21:22 2001 @@ -171,8 +171,43 @@ } static int pop3_server(int local_rd, int local_wr, int remote) { - log(LOG_ERR, "Protocol not supported in server mode"); - return -1; + char line[STRLEN]; + + fdscanf(remote, "%[^\n]", line); + if(fdprintf(local_wr, "%s + stunnel", line)<0) { + return -1; + } + + fdscanf(local_wr, "%[^\n]", line); + + if (!strncmp(line, "CAPA", 4)) { + if (fdprintf(remote, "CAPA")<0) + return -1; + + fdscanf(remote, "%[^\n]", line); + if (!strncmp(line, "+OK ", 4) && 0) { + if (fdprintf(local_wr, "STLS")<0) + return -1; + do { + fdscanf(remote, "%[^\n]", line); + if (fdprintf(local_wr, line)<0) + return -1; + } while (strncmp(line, ".", 1)); + } else { + if (fdprintf(local_wr, "+OK ")<0 || + fdprintf(local_wr, "STLS")<0 || + fdprintf(local_wr, ".")<0) + return -1; + } + fdscanf(local_wr, "%[^\n]", line); + } + + if (strncmp(line, "STLS", 4)) + return -1; + if (fdprintf(local_wr, "+OK ")<0) + return -1; + + return 0; } static int nntp_client(int local_rd, int local_wr, int remote) {