void StartupComplete() { char str[200]; connection_node conn; session_node *s; len_admin_response_buf = 0; conn.type = CONN_CONSOLE; s = CreateSession(conn); if (s == NULL) FatalError("Interface can't make session for console"); s->account = GetConsoleAccount(); InitSessionState(s,STATE_ADMIN); console_session_id = s->session_id; if (Edit_GetText(GetDlgItem(HWND_STATUS,IDC_STARTUP_TEXT),str,sizeof(str)) == 0) StartupPrintf("No errors on startup\n"); SendDlgItemMessage(hwndMain,IDC_TOOLBAR,TB_ENABLEBUTTON,IDM_FILE_EXIT,MAKELPARAM(TRUE,0)); SendDlgItemMessage(hwndMain,IDC_TOOLBAR,TB_ENABLEBUTTON,IDM_FILE_SAVE,MAKELPARAM(TRUE,0)); SendDlgItemMessage(hwndMain,IDC_TOOLBAR,TB_ENABLEBUTTON,IDM_FILE_RELOADSYSTEM, MAKELPARAM(TRUE,0)); SendDlgItemMessage(hwndMain,IDC_TOOLBAR,TB_ENABLEBUTTON,IDM_MESSAGES_MESSAGEOFTHEDAY, MAKELPARAM(TRUE,0)); }
void SetSessionState(session_node *s,int state) { /* a recent write could have failed, if so don't do anything since they were closed */ if (s->connected) { /* dprintf("state %i to %i\n",s->state,state); */ ExitSessionState(s); InitSessionState(s,state); } }
// XXX: identical to windows version void StartupComplete(void) { char str[200]; connection_node conn; session_node *s; len_admin_response_buf = 0; conn.type = CONN_CONSOLE; s = CreateSession(conn); if (s == NULL) FatalError("Interface can't make session for console"); s->account = GetConsoleAccount(); InitSessionState(s,STATE_ADMIN); console_session_id = s->session_id; }
void AsyncSocketAccept(SOCKET sock,int event,int error,int connection_type) { SOCKET new_sock; SOCKADDR_IN acc_sin; /* Accept socket address - internet style */ int acc_sin_len; /* Accept socket address length */ SOCKADDR_IN peer_info; int peer_len; struct in_addr peer_addr; connection_node conn; session_node *s; if (event != FD_ACCEPT) { eprintf("AsyncSocketAccept got non-accept %i\n",event); return; } if (error != 0) { eprintf("AsyncSocketAccept got error %i\n",error); return; } acc_sin_len = sizeof acc_sin; new_sock = accept(sock,(struct sockaddr *) &acc_sin,&acc_sin_len); if (new_sock == SOCKET_ERROR) { eprintf("AcceptSocketConnections accept failed, error %i\n", GetLastError()); return; } peer_len = sizeof peer_info; if (getpeername(new_sock,(SOCKADDR *)&peer_info,&peer_len) < 0) { eprintf("AcceptSocketConnections getpeername failed error %i\n", GetLastError()); return; } memcpy(&peer_addr,(long *)&(peer_info.sin_addr),sizeof(struct in_addr)); memcpy(&conn.addr, &peer_addr, sizeof(struct in_addr)); sprintf(conn.name,"%s",inet_ntoa(peer_addr)); // Too out following line to prevent log files from becoming spammed with extra lines. // This line is extraneous because the outcome of the authentication is always posted to logs. // lprintf("Got connection from %s to be authenticated.\n", conn.name); if (connection_type == SOCKET_MAINTENANCE_PORT) { if (!CheckMaintenanceMask(&peer_info,peer_len)) { lprintf("Blocked maintenance connection from %s.\n", conn.name); closesocket(new_sock); return; } } else { if (!CheckBlockList(&peer_addr)) { lprintf("Blocked connection from %s.\n", conn.name); closesocket(new_sock); return; } } conn.type = CONN_SOCKET; conn.socket = new_sock; EnterServerLock(); s = CreateSession(conn); if (s != NULL) { StartAsyncSession(s); switch (connection_type) { case SOCKET_PORT : InitSessionState(s,STATE_SYNCHED); break; case SOCKET_MAINTENANCE_PORT : InitSessionState(s,STATE_MAINTENANCE); break; default : eprintf("AcceptSocketConnections got invalid connection type %i\n",connection_type); } /* need to do this AFTER s->conn is set in place, because the async call writes to that mem address */ if (ConfigBool(SOCKET_DNS_LOOKUP)) { s->conn.hLookup = StartAsyncNameLookup((char *)&peer_addr,s->conn.peer_data); } else { s->conn.hLookup = 0; } } LeaveServerLock(); }