*** protocol.c	Wed Jan 24 21:53:10 2001
--- protocol.c.new	Fri Jun 29 19:28:06 2001
***************
*** 37,42 ****
--- 37,44 ----
  static int smb_server(int, int);
  static int smtp_client(int, int);
  static int smtp_server(int, int);
+ static int nntp_client(int, int);
+ static int nntp_server(int, int);
  static int telnet_client(int, int);
  static int telnet_server(int, int);
  static int RFC2487(int);
***************
*** 63,68 ****
--- 65,76 ----
          else
              return smtp_server(local, remote);
      }
+     if(!strcmp(protocol, "nntp")) {
+         if(client)
+             return nntp_client(local, remote);
+         else
+             return nntp_server(local, remote);
+     }
      if(!strcmp(protocol, "telnet")) {
          if(client)
              return telnet_client(local, remote);
***************
*** 122,127 ****
--- 130,162 ----
      return 0;
  }
  
+ static int nntp_client(int local, int remote)
+ {
+     char line[STRLEN];
+ 
+     fdscanf(remote, "%[^\r]", line);
+     if( strncmp(line,"200 ",4) && strncmp(line,"201 ",4) ) {
+         log(LOG_ERR, "Unknown server welcome");
+         return -1;
+     }
+     if(fdprintf(local, line)<0)
+         return -1;
+     if(fdprintf(remote, "STARTTLS")<0)
+         return -1;
+     fdscanf(remote, "%[^\r]", line);
+     if(strncmp(line,"382 ",4)) {
+         log(LOG_ERR, "Server does not support TLS");
+         return -1;
+     }
+     return 0;
+ }
+ 
+ static int nntp_server(int local, int remote)
+ {
+     log(LOG_ERR, "Protocol not supported in server mode");
+     return -1;
+ }
+ 
  static int telnet_client(int local, int remote)
  {
      log(LOG_ERR, "Protocol not supported");

