Changeset 19210

Show
Ignore:
Timestamp:
22.04.2009 22:32:44 (10 years ago)
Author:
davidb
Message:

Local Library Server can now either be configured to connects from anywhere or be restricted to only allow local connections. The option is controlled by setting 'externalaccess' to 1 or 0 appropriately. A widget for this is provided under File/Settings

Location:
gsdl/trunk/runtime-src/src/w32server
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/w32server/netio.cpp

    r9598 r19210  
    3535#include "locate.h" 
    3636#include "d_winsock.h" 
     37#include "settings.h" 
    3738 
    3839//Private Variables and Declarations 
     
    217218    ServerSockAddr.sin_port = d_htons( (WORD) bind_port); 
    218219    ServerSockAddr.sin_family = AF_INET; 
    219     ServerSockAddr.sin_addr.s_addr = d_htonl(INADDR_ANY); 
    220      
     220    if (gsdl_external_access) { 
     221      ServerSockAddr.sin_addr.s_addr = d_htonl(INADDR_ANY); 
     222    } 
     223    else { 
     224      ServerSockAddr.sin_addr.s_addr = d_htonl(INADDR_LOOPBACK); 
     225    } 
     226 
     227 
    221228    // Try to bind the socket with the address 
    222229    if (d_bind(ServerSocket, (LPSOCKADDR) &ServerSockAddr, 
  • gsdl/trunk/runtime-src/src/w32server/resource.h

    r11319 r19210  
    4040#define ID_ARM_127_0_0_1                1026 
    4141#define ID_ARM_LOCALHOST                1027 
     42#define ID_EXTERNAL_ACCESS              1028 
    4243#define ID_PROJECT_SETTINGS             40001 
    4344#define ID_PROJECT_EXIT                 40002 
  • gsdl/trunk/runtime-src/src/w32server/settings.cpp

    r19015 r19210  
    6161// general settings 
    6262int gsdl_port_num = 80; 
     63int gsdl_external_access = 0; 
    6364int gsdl_auto_enter = 0; 
    6465int gsdl_browser = GS_DEFAULT; 
     
    310311     
    311312    write_ini_line(fout, "portnumber", text_t(gsdl_port_num)); 
     313    write_ini_line(fout, "externalaccess", text_t(gsdl_external_access)); 
    312314    write_ini_line(fout, "autoenter", text_t(gsdl_auto_enter)); 
    313315    write_ini_line(fout, "browser", text_t(gsdl_browser)); 
     
    402404  // general settings 
    403405  gsdl_port_num = 80; 
     406  gsdl_external_access = 0; 
    404407  gsdl_auto_enter = 0; 
    405408  gsdl_start_browser = 1; 
     
    464467      } else if (key == "portnumber") { 
    465468        gsdl_port_num = value.getint(); 
     469 
     470      } else if (key == "externalaccess") { 
     471        gsdl_external_access = value.getint(); 
    466472         
    467473      } else if (key == "autoenter") { 
     
    636642  gsdl_port_num = GetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, &bres, 0); 
    637643  if (!bres) gsdl_port_num = 80; 
    638    
     644 
     645  // whether to allow external access or not 
     646  res = SendDlgItemMessage(hwndDlg, ID_EXTERNAL_ACCESS, BM_GETCHECK, 0, 0); 
     647  gsdl_external_access = (res == 1); 
     648     
    639649  // whether to enter the library automatically on startup 
    640650  res = SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_GETCHECK, 0, 0); 
    641651  gsdl_auto_enter = (res == 1); 
    642    
     652 
    643653  // which browser to use 
    644654  gsdl_browser = read_dialog_browser_field (hwndDlg); 
     
    666676    // set current values 
    667677    SetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, gsdl_port_num, FALSE); 
     678    SendDlgItemMessage(hwndDlg, ID_EXTERNAL_ACCESS, BM_SETCHECK, 
     679               gsdl_external_access ? 1 : 0, 0); 
    668680    SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_SETCHECK, 
    669681               gsdl_auto_enter ? 1 : 0, 0); 
     
    877889  int old_gsdl_show_console = gsdl_show_console; 
    878890  int old_gsdl_port_num = gsdl_port_num; 
     891  int old_gsdl_external_access = gsdl_external_access; 
    879892   
    880893  int res = 0; 
     
    912925    if (res == 1) { 
    913926      // only update if exited via the OK button 
    914       if (gsdl_port_num != old_gsdl_port_num) { 
     927      if ((gsdl_port_num != old_gsdl_port_num)  
     928      || (gsdl_external_access != old_gsdl_external_access)) { 
    915929    EndHTTPServer(); 
    916930    StartHTTPServer(window); 
  • gsdl/trunk/runtime-src/src/w32server/settings.h

    r16310 r19210  
    6262// general settings 
    6363extern int gsdl_port_num; 
     64extern int gsdl_external_access; 
    6465extern int gsdl_auto_enter; 
    6566extern int gsdl_browser;