Ticket #1444: PASVPatch.patch

File PASVPatch.patch, 10.8 KB (added by thejcab, 23 years ago)

The patch file. I hope it works, as it's the first patch file I ever created.

  • source/ControlSocket.cpp

    ? source/Debug
    ? source/FileZilla server.aps
    ? source/FileZilla server.clw
    ? source/FileZilla server.ncb
    ? source/FileZilla server.opt
    ? source/FileZilla server.plg
    ? source/Release
    RCS file: /cvsroot/filezilla/FileZilla Server/source/ControlSocket.cpp,v
    retrieving revision 1.10
    diff -u -r1.10 ControlSocket.cpp
     
    372372                m_transferstatus.socket=0;
    373373            }
    374374            m_transferstatus.socket=new CTransferSocket;
    375             if (!m_transferstatus.socket->Create())
    376             {
     375            unsigned int port = 0;
     376            CString ip;
     377            unsigned int retries = 3;
     378            while (retries > 0) {
     379                if (COptions::GetOptionVal(OPTION_CUSTOMPASVENABLE)) {
     380                    static UINT customPort = 0;
     381                    unsigned int minPort = COptions::GetOptionVal(OPTION_CUSTOMPASVMINPORT);
     382                    unsigned int maxPort = COptions::GetOptionVal(OPTION_CUSTOMPASVMAXPORT);
     383                    if (minPort > maxPort) {
     384                        unsigned int temp = minPort;
     385                        minPort = maxPort;
     386                        maxPort = temp;
     387                    }
     388                    if (customPort < minPort || customPort > maxPort) {
     389                        customPort = minPort;
     390                    }
     391                    port = customPort;
     392                    ip = COptions::GetOption(OPTION_CUSTOMPASVIP);
     393                    ++customPort;
     394                } else {
     395                    //Get the ip of the control socket
     396                    unsigned int junkPort;
     397                    GetSockName(ip,junkPort);
     398                }
     399                if (m_transferstatus.socket->Create(port))
     400                {
     401                    break;
     402                }
     403                --retries;
     404            }
     405            if (retries <= 0) {
    377406                delete m_transferstatus.socket;
    378407                m_transferstatus.socket=0;
    379408                Send("421 Can't create socket");
     
    381410            }
    382411            m_transferstatus.socket->Listen();
    383412            m_transferstatus.socket->AsyncSelect();
    384             CString ip,tmp;
    385             unsigned int port;
    386             //Get the ip of the control socket (the newly created socket would only return 127.0.0.1)
    387             GetSockName(ip,port);
     413            CString tmp;
    388414            //Now retrieve the port
    389415            m_transferstatus.socket->GetSockName(tmp,port);
    390416            //Reformat the ip
  • source/FileZilla

    RCS file: /cvsroot/filezilla/FileZilla Server/source/FileZilla server.rc,v
    retrieving revision 1.8
    diff -u -r1.8 FileZilla server.rc
     
    1313#undef APSTUDIO_READONLY_SYMBOLS
    1414
    1515/////////////////////////////////////////////////////////////////////////////
    16 // Deutsch (Deutschland) resources
     16// German (Germany) resources
    1717
    1818#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
    1919#ifdef _WIN32
     
    337337                    IDC_STATIC,13,178,259,16
    338338END
    339339
    340 IDD_OPTIONS_MISC DIALOG DISCARDABLE 0, 0, 286, 208
     340IDD_OPTIONS_MISC DIALOGEX 0, 0, 286, 208
    341341STYLE DS_CONTROL | WS_CHILD
    342342FONT 8, "MS Sans Serif"
    343343BEGIN
    344344    CONTROL         "Don't show &passwords in message log",
    345345                    IDC_OPTIONS_MISC_DONTSHOWPASS,"Button",BS_AUTOCHECKBOX |
    346346                    WS_TABSTOP,7,7,135,10
     347    GROUPBOX        "Custom PASV settings",IDC_STATIC,7,21,272,63
     348    CONTROL         "Enable custom PASV settings",
     349                    IDC_OPTIONS_MISC_CUSTOM_PASV,"Button",BS_AUTOCHECKBOX |
     350                    WS_TABSTOP,13,33,109,10
     351    LTEXT           "IP Address",IDC_STATIC,13,52,35,8
     352    EDITTEXT        IDC_CUSTOM_PASV_IP,53,48,68,14,ES_AUTOHSCROLL
     353    LTEXT           "---.---.---.---",IDC_STATIC,125,51,31,8
     354    LTEXT           "Port range",IDC_STATIC,13,70,34,8
     355    CTEXT           "-",IDC_STATIC,83,68,8,8
     356    EDITTEXT        IDC_CUSTOM_PASV_MIN_PORT,53,66,27,14,ES_AUTOHSCROLL
     357    EDITTEXT        IDC_CUSTOM_PASV_MAX_PORT,94,66,27,14,ES_AUTOHSCROLL
     358    LTEXT           "(1-65535)",IDC_STATIC,126,69,31,8
     359    EDITTEXT        IDC_CUSTOM_PASV_TEXT,160,27,113,54,ES_MULTILINE |
     360                    ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL,
     361                    WS_EX_STATICEDGE
    347362END
    348363
    349364
     
    585600    ID_LOCK                 "Lock server, no new connections will be accepted"
    586601END
    587602
    588 #endif    // Deutsch (Deutschland) resources
     603STRINGTABLE DISCARDABLE
     604BEGIN
     605    IDC_CUSTOM_PASV_TEXT    "Use custom PASV settings if you are operating the server from behind a NAT router or a firewall. In that case, the IP address of the server is not accessible from outside of the router, so you should fill in the correct address here. Use the port range to limit the number of ports that will need to be forwarded through the router."
     606END
     607
     608#endif    // German (Germany) resources
    589609/////////////////////////////////////////////////////////////////////////////
    590610
    591611
    592612/////////////////////////////////////////////////////////////////////////////
    593 // Englisch (USA) resources
     613// English (U.S.) resources
    594614
    595615#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
    596616#ifdef _WIN32
     
    657677END
    658678#endif    // APSTUDIO_INVOKED
    659679
    660 #endif    // Englisch (USA) resources
     680#endif    // English (U.S.) resources
    661681/////////////////////////////////////////////////////////////////////////////
    662682
    663683
  • source/Options.cpp

    RCS file: /cvsroot/filezilla/FileZilla Server/source/Options.cpp,v
    retrieving revision 1.2
    diff -u -r1.2 Options.cpp
     
    6262    m_OptionsSecurityPage.m_bOutFxpStrict=GetOptionVal(OPTION_NOOUTFXPSTRICT);
    6363
    6464    m_OptionsMiscPage.m_bDontShowPass=GetOptionVal(OPTION_LOGSHOWPASS)?FALSE:TRUE;
     65    m_OptionsMiscPage.m_bEnableCustomPASV=GetOptionVal(OPTION_CUSTOMPASVENABLE)?TRUE:FALSE;
     66    m_OptionsMiscPage.m_sCustomPASVString=GetOption(OPTION_CUSTOMPASVIP);
     67    m_OptionsMiscPage.m_sCustomPASVMinPort=GetOptionVal(OPTION_CUSTOMPASVMINPORT);
     68    m_OptionsMiscPage.m_sCustomPASVMaxPort=GetOptionVal(OPTION_CUSTOMPASVMAXPORT);
    6569
    6670    DoModal();
    6771
     
    7882    SetOption(OPTION_NOOUTFXPSTRICT,m_OptionsSecurityPage.m_bOutFxpStrict);
    7983
    8084    SetOption(OPTION_LOGSHOWPASS,m_OptionsMiscPage.m_bDontShowPass?0:1);
     85    SetOption(OPTION_CUSTOMPASVENABLE,m_OptionsMiscPage.m_bEnableCustomPASV?1:0);
     86    SetOption(OPTION_CUSTOMPASVIP,m_OptionsMiscPage.m_sCustomPASVString);
     87    SetOption(OPTION_CUSTOMPASVMINPORT,m_OptionsMiscPage.m_sCustomPASVMinPort);
     88    SetOption(OPTION_CUSTOMPASVMAXPORT,m_OptionsMiscPage.m_sCustomPASVMaxPort);
    8189}
    8290
    8391BOOL COptions::OnInitDialog()
     
    9098
    9199char keyname[][30]={"Serverport",         "Number of Threads", "Maximum user count","Timeout",
    92100                    "No Transfer Timeout","Allow Incoming FXP","Allow outgoing FXP","No Strict In Fxp",
    93                     "No Strict Out Fxp",  "Login Timeout",     "Show Pass in log"};
     101                    "No Strict Out Fxp",  "Login Timeout",     "Show Pass in log",
     102                    "Custom PASV Enable", "Custom PASV IP", "Custom PASV min port", "Custom PASV max port" };
    94103
    95104void COptions::SetOption(int OptionID,int value)
    96105{
  • source/Options.h

    RCS file: /cvsroot/filezilla/FileZilla Server/source/Options.h,v
    retrieving revision 1.2
    diff -u -r1.2 Options.h
     
    6868#define OPTION_NOOUTFXPSTRICT 9
    6969#define OPTION_LOGINTIMEOUT 10
    7070#define OPTION_LOGSHOWPASS 11
     71#define OPTION_CUSTOMPASVENABLE 12
     72#define OPTION_CUSTOMPASVIP 13
     73#define OPTION_CUSTOMPASVMINPORT 14
     74#define OPTION_CUSTOMPASVMAXPORT 15
    7175
    7276
    7377//{{AFX_INSERT_LOCATION}}
  • source/OptionsMiscPage.cpp

    RCS file: /cvsroot/filezilla/FileZilla Server/source/OptionsMiscPage.cpp,v
    retrieving revision 1.1
    diff -u -r1.1 OptionsMiscPage.cpp
     
    2121    //{{AFX_DATA_INIT(COptionsMisc)
    2222    m_bDontShowPass = FALSE;
    2323    //}}AFX_DATA_INIT
     24    m_bEnableCustomPASV = FALSE;
     25    m_sCustomPASVString = "";
     26    m_sCustomPASVMinPort = 1024;
     27    m_sCustomPASVMaxPort = 65535;
     28    m_sCustomPASVHelp = CString((LPCTSTR)IDC_CUSTOM_PASV_TEXT);
    2429}
    2530
    2631
     
    3035    //{{AFX_DATA_MAP(COptionsMiscPage)
    3136    DDX_Check(pDX, IDC_OPTIONS_MISC_DONTSHOWPASS, m_bDontShowPass);
    3237    //}}AFX_DATA_MAP
     38    DDX_Check(pDX, IDC_OPTIONS_MISC_CUSTOM_PASV, m_bEnableCustomPASV);
     39    DDX_Text(pDX, IDC_CUSTOM_PASV_IP, m_sCustomPASVString);
     40    DDX_Text(pDX, IDC_CUSTOM_PASV_MIN_PORT, m_sCustomPASVMinPort);
     41    DDX_Text(pDX, IDC_CUSTOM_PASV_MAX_PORT, m_sCustomPASVMaxPort);
     42    DDX_Text(pDX, IDC_CUSTOM_PASV_TEXT, m_sCustomPASVHelp);
    3343}
    3444
    3545
  • source/OptionsMiscPage.h

    RCS file: /cvsroot/filezilla/FileZilla Server/source/OptionsMiscPage.h,v
    retrieving revision 1.1
    diff -u -r1.1 OptionsMiscPage.h
     
    2121    enum { IDD = IDD_OPTIONS_MISC };
    2222    BOOL    m_bDontShowPass;
    2323    //}}AFX_DATA
     24    BOOL m_bEnableCustomPASV;
     25    CString m_sCustomPASVString;
     26    UINT m_sCustomPASVMinPort;
     27    UINT m_sCustomPASVMaxPort;
     28    CString m_sCustomPASVHelp;
     29
    2430
    2531
    2632// Überschreibungen
  • source/resource.h

    RCS file: /cvsroot/filezilla/FileZilla Server/source/resource.h,v
    retrieving revision 1.5
    diff -u -r1.5 resource.h
     
    5454#define IDC_PORT                        1023
    5555#define IDC_MAXUSERS                    1024
    5656#define IDC_THREADNUM                   1025
     57#define IDC_CUSTOM_PASV_MAX_PORT        1025
    5758#define IDC_MAXUSERBYPASS               1026
    5859#define IDC_MAXCONNCOUNT                1027
    5960#define IDC_IPLIMIT                     1028
     
    7172#define IDC_MAIL                        1039
    7273#define IDC_HOMEPAGE                    1040
    7374#define IDC_OPTIONS_MISC_DONTSHOWPASS   1041
     75#define IDC_OPTIONS_MISC_CUSTOM_PASV    1042
     76#define IDC_CUSTOM_PASV_IP              1043
     77#define IDC_CUSTOM_PASV_MIN_PORT        1044
     78#define IDC_CUSTOM_PASV_TEXT            1045
    7479#define ID_OUTPUTCONTEXT_CLEARALL       32770
    7580#define ID_USERMENU_ADD                 32771
    7681#define ID_TRAY_RESTORE                 32771
     
    103108#define _APS_3D_CONTROLS                     1
    104109#define _APS_NEXT_RESOURCE_VALUE        143
    105110#define _APS_NEXT_COMMAND_VALUE         32785
    106 #define _APS_NEXT_CONTROL_VALUE         1042
     111#define _APS_NEXT_CONTROL_VALUE         1046
    107112#define _APS_NEXT_SYMED_VALUE           101
    108113#endif
    109114#endif