Added PROXY capabilities to hotwayd

2003-07-24
2003-07-24
  • Frank Schaeckermann

    Since I wasn't able to use hotwayd behind our proxy firewall I took on the task of adding proxy capabilities in SOME way... the easiest - even if it is not the prettiest - way was to feed the proxy information in with the user name.

    I created a patch (against hotwayd-0.5.3) that makes it possible to specify a proxy-server to be used by pre-pending it to the user name in your e-mail-client configuration in the following way:

    Instead of your username (i.e. xxx@hotmail.com) you specifiy

    [http://<proxyname>:<port>]xxx@hotmail.com

    without any whitespaces! Naturally it works with @msn.com as well!

    Unfortunately after it was all done, I discovered, that our proxy server won't permit the PROPFIND method of the http protocol which is being used by hotwayd. Thus I STILL can't use hotwayd. :-(

    But maybe somebody else is more lucky with their proxy!

    Have fun, Frank

    P.S. If any of the developpers is interested incorporating this into the hotwayd source - and documentation - feel free to do so!

    Patch follows (not sure if that is usable though due to the line wrapping):

    diff -c hotwayd-0.5.3/commands.c hotwayd-0.5.3-mod/commands.c
    *** hotwayd-0.5.3/commands.c    2003-05-05 07:06:31.000000000 +0200
    --- hotwayd-0.5.3-mod/commands.c    2003-07-24 17:07:24.000000000 +0200
    ***************
    *** 22,27 ****
    --- 22,32 ----
       * along with this program; if not, write to the Free Software
       * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
       * 02111-1307, USA.
    +  *
    +  *
    +  * FSCHAECK 24-Jul-2003: added possibility to specify proxy-server with username
    +  *                       mailto://schaeckermann@users.sourceforge.net
    +  *
       */
     
      #include "libghttp-1.0.9-mod/ghttp.h"
    ***************
    *** 48,53 ****
    --- 53,59 ----
      char xml_length[N_XML_LENGTH];
      char UserName[N_USERNAME];
      char PassWord[N_PASSWORD];
    + char ProxyServer[N_PROXYSERVER]; /*----- FSCHAECK 24-Jul-2003 inserted -----*/
      char *WWWAuthenticate;
     
      /* Extern stuff */
    ***************
    *** 169,174 ****
    --- 175,200 ----
              }
          }
      }
    +
    +
    + /*----- FSCHAECK 24-Jul-2003 --- insert --- begin -----*/
    +
    + /* ------------------------------------------------------------------------
    +  * use_proxy defines the passed proxy server in the request and makes sure
    +  * the Host header line is included and set to the required host name
    +  * (request-uri must have been set already for this to work!)
    +  */
    + int use_proxy(ghttp_request *request, char *proxy)
    + {
    +   ghttp_set_proxy(request,ProxyServer);
    + #ifdef DEBUG
    +   fprintf( stderr, "using proxy %s\n", ProxyServer) ; fflush( stderr );
    + #endif
    + }
    +
    + /*----- FSCHAECK 24-Jul-2003 --- insert --- end -------*/
    +
    +
      /* ---------------------------------------------------------------------
       * Propfind makes a PROPFIND call on myurl
       */
    ***************
    *** 216,221 ****
    --- 242,253 ----
          if (whichrequest == MSGLIST)
              ghttp_set_digestinfo(request, UserName, PassWord, NULL, 1);
          my_set_cookies (request, myurl);
    +    
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- begin -----*/
    +     /* check if a proxy was specified and put it to use if so */
    +     if (*ProxyServer)
    +       use_proxy(request,ProxyServer);
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- end -------*/
     
          /* Prepare the connection */
          ghttp_prepare(request);
    ***************
    *** 376,381 ****
    --- 408,420 ----
     
                  /* Prepare & process the connection */
                  cur_message = num_msg;
    +    
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- begin -----*/
    +             /* check if a proxy was specified and put it to use if so */
    +             if (*ProxyServer)
    +               use_proxy(request,ProxyServer);
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- end -------*/
    +
                  ghttp_prepare(request);
                  ghttp_process(request);
     
    ***************
    *** 425,430 ****
    --- 464,475 ----
              ghttp_set_header(request, http_hdr_Connection, "Keep-Alive");
              my_set_cookies (request, inbox_props->list_props[num_msg]->href);
              ghttp_set_digestinfo(request, UserName, PassWord, NULL, 1);
    +    
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- begin -----*/
    +         /* check if a proxy was specified and put it to use if so */
    +         if (*ProxyServer)
    +           use_proxy(request,ProxyServer);
    + /*----- FSCHAECK 24-Jul-2003 --- inserted --- end -------*/
     
              /* Prepare & process the connection */
              ghttp_prepare(request);
    ***************
    *** 511,524 ****
          inbox_props = (FOLDER_STRUCT *) calloc(1, sizeof(FOLDER_STRUCT));
     
          /* Set username/password for authorization-header */
    !     strlcpy(UserName, user, N_USERNAME);
          strlcpy(PassWord, pass, N_PASSWORD);
     
          return dologin(request,mydir);
      }
     
      /* this function checks we have a user name of the form xxx@hotmail.com
         or xxx@msn.com */
      int validate_username(char *user)
      {
          mydir[0]= '\0';
    --- 556,609 ----
          inbox_props = (FOLDER_STRUCT *) calloc(1, sizeof(FOLDER_STRUCT));
     
          /* Set username/password for authorization-header */
    ! /*----- strlcpy(UserName, user, N_USERNAME); ------- FSCHAECK 24-Jul-2003 deleted ------------*/
    !
    ! /*----- FSCHAECK 24-Jul-2003 insert begin ------------*/
    !
    !     /* extract proxy from user if one was specified */
    !     /* syntax is '['+proxyname+':'+proxyport+']'+username (w/o any imbedded white space) */
    !     char *aux;
    !     *ProxyServer = '\0'; /* no proxy server specified - yet */
    !    
    !     if (user[0]=='[') /* do we have a proxy specification? */
    !     {
    !       /* yes... copy the server name */
    !       strlcpy(ProxyServer, user+1, N_PROXYSERVER);
    !       aux = index(ProxyServer,']'); /* look for the end of it */
    !       if (!aux) /* not a complete proxy-spec? */
    !       {
    !         /* then take it as part of the complete username */
    !         aux = user;
    !         ProxyServer[0] = '\0';
    !       }
    !       else
    !       {
    !         *aux = '\0';             /* cut away the user name following the proxy specification */
    !         aux = index(user,']')+1; /* and set aux to point to the following username           */
    !       }
    !     }
    !     else /* no proxy specification therefore the whole thing is taken as user name */
    !       aux = user;
    !
    !     strlcpy(UserName, aux , N_USERNAME);
    !
    ! /*----- FSCHAECK 24-Jul-2003 insert end --------------*/
    !    
          strlcpy(PassWord, pass, N_PASSWORD);
     
    + #ifdef DEBUG
    +     fprintf( stderr, "proxy server: '%s'\n", ProxyServer) ; fflush( stderr );
    +     fprintf( stderr, "username:     '%s'\n", UserName) ;    fflush( stderr );
    +     fprintf( stderr, "password:     '%s'\n", PassWord) ;    fflush( stderr );
    + #endif
    +
          return dologin(request,mydir);
      }
     
      /* this function checks we have a user name of the form xxx@hotmail.com
         or xxx@msn.com */
    + /*------ FSCHAECK 24-Jul-2003: validate_username has no problem with the - possible - extra specification
    +          of a proxy address and port preceding the actual user name and domain (see httpmail_authenticate_user) -----*/
      int validate_username(char *user)
      {
          mydir[0]= '\0';
    Only in hotwayd-0.5.3-mod: commands.c~
    diff -c hotwayd-0.5.3/hotwayd.h hotwayd-0.5.3-mod/hotwayd.h
    *** hotwayd-0.5.3/hotwayd.h    2003-04-27 10:06:04.000000000 +0200
    --- hotwayd-0.5.3-mod/hotwayd.h    2003-07-24 17:08:12.000000000 +0200
    ***************
    *** 18,23 ****
    --- 18,27 ----
       * along with this program; if not, write to the Free Software
       * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
       * 02111-1307, USA.
    +  *
    +  *
    +  * FSCHAECK 24-Jul-2003: added possibility to specify proxy-server with username
    +  *                       mailto://schaeckermann@users.sourceforge.net
       */
      #include <stdio.h>
      #include <stdlib.h>
    ***************
    *** 36,41 ****
    --- 40,46 ----
      #define N_XML_LENGTH 16
      #define N_USERNAME 32
      #define N_PASSWORD 32
    + #define N_PROXYSERVER 200 /*----- FSCHAECK 24-Jul-2003 inserted -----*/
     
      #define PAM_SERVICE_NAME "hotway"
     
    Common subdirectories: hotwayd-0.5.3/libghttp-1.0.9-mod and hotwayd-0.5.3-mod/libghttp-1.0.9-mod

     
    • Frank Schaeckermann

      Well... there are some mixups in this post due to HTML processing by the posting machine I guess... The syntay for the e-mail-client username field is:

          [h t t p : / / proxyserver:port]xxx@hotmail.com

      (I hope this time it will show up as it should - and remember NO WHITESPACES)

      The two garbled lines in the patch where my e-mail is listed need to be cleared of the HTML tags... I hope you can get that done yourself!?!?

      Sorry for the mess... maybe somebody can tell me how to do that better...

      Regards, Frank

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks