Skip to content
Snippets Groups Projects
Commit e818f9d1 authored by deuce's avatar deuce
Browse files

Support quiet mode for telnet, ssh, and modem connections as well.

parent 361b02ae
No related branches found
No related tags found
No related merge requests found
...@@ -130,6 +130,7 @@ void telnet_output_thread(void *args) ...@@ -130,6 +130,7 @@ void telnet_output_thread(void *args)
int telnet_connect(struct bbslist *bbs) int telnet_connect(struct bbslist *bbs)
{ {
if (!bbs->hidepopups)
init_uifc(TRUE, TRUE); init_uifc(TRUE, TRUE);
telnet_log_level = bbs->telnet_loglevel; telnet_log_level = bbs->telnet_loglevel;
...@@ -166,6 +167,7 @@ int telnet_connect(struct bbslist *bbs) ...@@ -166,6 +167,7 @@ int telnet_connect(struct bbslist *bbs)
_beginthread(telnet_output_thread, 0, NULL); _beginthread(telnet_output_thread, 0, NULL);
_beginthread(telnet_input_thread, 0, bbs); _beginthread(telnet_input_thread, 0, bbs);
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(0); return(0);
......
...@@ -139,10 +139,12 @@ int modem_connect(struct bbslist *bbs) ...@@ -139,10 +139,12 @@ int modem_connect(struct bbslist *bbs)
int ret; int ret;
char respbuf[1024]; char respbuf[1024];
if (!bbs->hidepopups)
init_uifc(TRUE, TRUE); init_uifc(TRUE, TRUE);
if(bbs->conn_type == CONN_TYPE_SERIAL) { if(bbs->conn_type == CONN_TYPE_SERIAL) {
if((com=comOpen(bbs->addr)) == COM_HANDLE_INVALID) { if((com=comOpen(bbs->addr)) == COM_HANDLE_INVALID) {
if (!bbs->hidepopups)
uifcmsg("Cannot Open Port", "`Cannot Open Port`\n\n" uifcmsg("Cannot Open Port", "`Cannot Open Port`\n\n"
"Cannot open the specified serial device.\n"); "Cannot open the specified serial device.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -150,6 +152,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -150,6 +152,7 @@ int modem_connect(struct bbslist *bbs)
} }
if(bbs->bpsrate) { if(bbs->bpsrate) {
if(!comSetBaudRate(com, bbs->bpsrate)) { if(!comSetBaudRate(com, bbs->bpsrate)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Set Baud Rate", "`Cannot Set Baud Rate`\n\n" uifcmsg("Cannot Set Baud Rate", "`Cannot Set Baud Rate`\n\n"
"Cannot open the specified serial device.\n"); "Cannot open the specified serial device.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -158,6 +161,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -158,6 +161,7 @@ int modem_connect(struct bbslist *bbs)
} }
} }
if(!comRaiseDTR(com)) { if(!comRaiseDTR(com)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n" uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n"
"comRaiseDTR() returned an error.\n"); "comRaiseDTR() returned an error.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -167,6 +171,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -167,6 +171,7 @@ int modem_connect(struct bbslist *bbs)
} }
else { else {
if((com=comOpen(settings.mdm.device_name)) == COM_HANDLE_INVALID) { if((com=comOpen(settings.mdm.device_name)) == COM_HANDLE_INVALID) {
if (!bbs->hidepopups)
uifcmsg("Cannot Open Modem", "`Cannot Open Modem`\n\n" uifcmsg("Cannot Open Modem", "`Cannot Open Modem`\n\n"
"Cannot open the specified modem device.\n"); "Cannot open the specified modem device.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -174,6 +179,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -174,6 +179,7 @@ int modem_connect(struct bbslist *bbs)
} }
if(settings.mdm.com_rate) { if(settings.mdm.com_rate) {
if(!comSetBaudRate(com, settings.mdm.com_rate)) { if(!comSetBaudRate(com, settings.mdm.com_rate)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Set Baud Rate", "`Cannot Set Baud Rate`\n\n" uifcmsg("Cannot Set Baud Rate", "`Cannot Set Baud Rate`\n\n"
"Cannot open the specified modem device.\n"); "Cannot open the specified modem device.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -182,6 +188,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -182,6 +188,7 @@ int modem_connect(struct bbslist *bbs)
} }
} }
if(!comRaiseDTR(com)) { if(!comRaiseDTR(com)) {
if (!bbs->hidepopups)
uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n" uifcmsg("Cannot Raise DTR", "`Cannot Raise DTR`\n\n"
"comRaiseDTR() returned an error.\n"); "comRaiseDTR() returned an error.\n");
conn_api.terminate=-1; conn_api.terminate=-1;
...@@ -193,6 +200,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -193,6 +200,7 @@ int modem_connect(struct bbslist *bbs)
while(kbhit()) while(kbhit())
getch(); getch();
if (!bbs->hidepopups)
uifc.pop("Initializing..."); uifc.pop("Initializing...");
comWriteString(com, settings.mdm.init_string); comWriteString(com, settings.mdm.init_string);
...@@ -202,11 +210,13 @@ int modem_connect(struct bbslist *bbs) ...@@ -202,11 +210,13 @@ int modem_connect(struct bbslist *bbs)
while(1) { while(1) {
if((ret=modem_response(respbuf, sizeof(respbuf), 5))!=0) { if((ret=modem_response(respbuf, sizeof(respbuf), 5))!=0) {
modem_close(); modem_close();
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
if(ret<0) if(ret<0)
uifcmsg("Modem Not Responding", "`Modem Not Responding`\n\n" uifcmsg("Modem Not Responding", "`Modem Not Responding`\n\n"
"The modem did not respond to the initializtion string\n" "The modem did not respond to the initializtion string\n"
"Check your init string and phone number.\n"); "Check your init string and phone number.\n");
}
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
...@@ -217,15 +227,19 @@ int modem_connect(struct bbslist *bbs) ...@@ -217,15 +227,19 @@ int modem_connect(struct bbslist *bbs)
if(!strstr(respbuf, "OK")) { if(!strstr(respbuf, "OK")) {
modem_close(); modem_close();
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifcmsg(respbuf, "`Initialization Error`\n\n" uifcmsg(respbuf, "`Initialization Error`\n\n"
"The modem did not respond favorably to your initialization string.\n"); "The modem did not respond favorably to your initialization string.\n");
}
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Dialing..."); uifc.pop("Dialing...");
}
comWriteString(com, settings.mdm.dial_string); comWriteString(com, settings.mdm.dial_string);
comWriteString(com, bbs->addr); comWriteString(com, bbs->addr);
comWriteString(com, "\r"); comWriteString(com, "\r");
...@@ -234,10 +248,12 @@ int modem_connect(struct bbslist *bbs) ...@@ -234,10 +248,12 @@ int modem_connect(struct bbslist *bbs)
while(1) { while(1) {
if((ret=modem_response(respbuf, sizeof(respbuf), 60))!=0) { if((ret=modem_response(respbuf, sizeof(respbuf), 60))!=0) {
modem_close(); modem_close();
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
if(ret<0) if(ret<0)
uifcmsg(respbuf, "`No Answer`\n\n" uifcmsg(respbuf, "`No Answer`\n\n"
"The modem did not connect within 60 seconds.\n"); "The modem did not connect within 60 seconds.\n");
}
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
...@@ -248,18 +264,22 @@ int modem_connect(struct bbslist *bbs) ...@@ -248,18 +264,22 @@ int modem_connect(struct bbslist *bbs)
if(!strstr(respbuf, "CONNECT")) { if(!strstr(respbuf, "CONNECT")) {
modem_close(); modem_close();
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifcmsg(respbuf, "`Connection Failed`\n\n" uifcmsg(respbuf, "`Connection Failed`\n\n"
"SyncTERM was unable to establish a connection.\n"); "SyncTERM was unable to establish a connection.\n");
}
conn_api.terminate=-1; conn_api.terminate=-1;
return(-1); return(-1);
} }
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop(respbuf); uifc.pop(respbuf);
SLEEP(1000); SLEEP(1000);
uifc.pop(NULL); uifc.pop(NULL);
} }
}
if(!create_conn_buf(&conn_inbuf, BUFFER_SIZE)) { if(!create_conn_buf(&conn_inbuf, BUFFER_SIZE)) {
conn_api.close(); conn_api.close();
...@@ -295,6 +315,7 @@ int modem_connect(struct bbslist *bbs) ...@@ -295,6 +315,7 @@ int modem_connect(struct bbslist *bbs)
_beginthread(modem_input_thread, 0, NULL); _beginthread(modem_input_thread, 0, NULL);
} }
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(0); return(0);
......
...@@ -150,10 +150,12 @@ int ssh_connect(struct bbslist *bbs) ...@@ -150,10 +150,12 @@ int ssh_connect(struct bbslist *bbs)
int rows,cols; int rows,cols;
const char *term; const char *term;
if (!bbs->hidepopups)
init_uifc(TRUE, TRUE); init_uifc(TRUE, TRUE);
pthread_mutex_init(&ssh_mutex, NULL); pthread_mutex_init(&ssh_mutex, NULL);
if(!crypt_loaded) { if(!crypt_loaded) {
if (!bbs->hidepopups) {
uifcmsg("Cannot load cryptlib - SSH inoperative", "`Cannot load cryptlib`\n\n" uifcmsg("Cannot load cryptlib - SSH inoperative", "`Cannot load cryptlib`\n\n"
"Cannot load the file " "Cannot load the file "
#ifdef _WIN32 #ifdef _WIN32
...@@ -167,6 +169,7 @@ int ssh_connect(struct bbslist *bbs) ...@@ -167,6 +169,7 @@ int ssh_connect(struct bbslist *bbs)
); );
return(conn_api.terminate=-1); return(conn_api.terminate=-1);
} }
}
sock=conn_socket_connect(bbs); sock=conn_socket_connect(bbs);
if(sock==INVALID_SOCKET) if(sock==INVALID_SOCKET)
...@@ -174,13 +177,16 @@ int ssh_connect(struct bbslist *bbs) ...@@ -174,13 +177,16 @@ int ssh_connect(struct bbslist *bbs)
ssh_active=FALSE; ssh_active=FALSE;
if (!bbs->hidepopups)
uifc.pop("Creating Session"); uifc.pop("Creating Session");
status=cl.CreateSession(&ssh_session, CRYPT_UNUSED, CRYPT_SESSION_SSH); status=cl.CreateSession(&ssh_session, CRYPT_UNUSED, CRYPT_SESSION_SSH);
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str,"Error %d creating session",status); sprintf(str,"Error %d creating session",status);
if (!bbs->hidepopups)
uifcmsg("Error creating session",str); uifcmsg("Error creating session",str);
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
...@@ -191,94 +197,130 @@ int ssh_connect(struct bbslist *bbs) ...@@ -191,94 +197,130 @@ int ssh_connect(struct bbslist *bbs)
SAFECOPY(password,bbs->password); SAFECOPY(password,bbs->password);
SAFECOPY(username,bbs->user); SAFECOPY(username,bbs->user);
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
if(!username[0]) if(!username[0]) {
if (bbs->hidepopups)
init_uifc(FALSE, FALSE);
uifcinput("UserID",MAX_USER_LEN,username,0,"No stored UserID."); uifcinput("UserID",MAX_USER_LEN,username,0,"No stored UserID.");
if (bbs->hidepopups)
uifcbail();
}
if (!bbs->hidepopups)
uifc.pop("Setting Username"); uifc.pop("Setting Username");
/* Add username/password */ /* Add username/password */
status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_USERNAME, username, strlen(username)); status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_USERNAME, username, strlen(username));
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str,"Error %d setting username",status); sprintf(str,"Error %d setting username",status);
if (!bbs->hidepopups)
uifcmsg("Error setting username",str); uifcmsg("Error setting username",str);
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
if(!password[0]) if(!password[0]) {
if (bbs->hidepopups)
init_uifc(FALSE, FALSE);
uifcinput("Password",MAX_PASSWD_LEN,password,K_PASSWORD,"Incorrect password. Try again."); uifcinput("Password",MAX_PASSWD_LEN,password,K_PASSWORD,"Incorrect password. Try again.");
if (bbs->hidepopups)
uifcbail();
}
if (!bbs->hidepopups)
uifc.pop("Setting Password"); uifc.pop("Setting Password");
status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_PASSWORD, password, strlen(password)); status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_PASSWORD, password, strlen(password));
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str,"Error %d setting password",status); sprintf(str,"Error %d setting password",status);
if (!bbs->hidepopups)
uifcmsg("Error setting password",str); uifcmsg("Error setting password",str);
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Setting Username"); uifc.pop("Setting Username");
}
/* Pass socket to cryptlib */ /* Pass socket to cryptlib */
status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_NETWORKSOCKET, sock); status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_NETWORKSOCKET, sock);
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str,"Error %d passing socket",status); sprintf(str,"Error %d passing socket",status);
if (!bbs->hidepopups)
uifcmsg("Error passing socket",str); uifcmsg("Error passing socket",str);
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Setting Terminal Type"); uifc.pop("Setting Terminal Type");
}
term = get_emulation_str(get_emulation(bbs)); term = get_emulation_str(get_emulation(bbs));
status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_SSH_TERMINAL, term, strlen(term)); status=cl.SetAttributeString(ssh_session, CRYPT_SESSINFO_SSH_TERMINAL, term, strlen(term));
get_term_win_size(&cols, &rows, &bbs->nostatus); get_term_win_size(&cols, &rows, &bbs->nostatus);
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Setting Terminal Width"); uifc.pop("Setting Terminal Width");
}
/* Pass socket to cryptlib */ /* Pass socket to cryptlib */
status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_SSH_WIDTH, cols); status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_SSH_WIDTH, cols);
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Setting Terminal Height"); uifc.pop("Setting Terminal Height");
}
/* Pass socket to cryptlib */ /* Pass socket to cryptlib */
status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_SSH_HEIGHT, rows); status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_SSH_HEIGHT, rows);
cl.SetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 1); cl.SetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 1);
/* Activate the session */ /* Activate the session */
if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Activating Session"); uifc.pop("Activating Session");
}
status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_ACTIVE, 1); status=cl.SetAttribute(ssh_session, CRYPT_SESSINFO_ACTIVE, 1);
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
if (!bbs->hidepopups)
cryptlib_error_message(status, "activating session"); cryptlib_error_message(status, "activating session");
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
ssh_active=TRUE; ssh_active=TRUE;
uifc.pop(NULL); if (!bbs->hidepopups) {
/* Clear ownership */ /* Clear ownership */
uifc.pop(NULL); // TODO: Why is this called twice?
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Clearing Ownership"); uifc.pop("Clearing Ownership");
}
status=cl.SetAttribute(ssh_session, CRYPT_PROPERTY_OWNER, CRYPT_UNUSED); status=cl.SetAttribute(ssh_session, CRYPT_PROPERTY_OWNER, CRYPT_UNUSED);
if(cryptStatusError(status)) { if(cryptStatusError(status)) {
if (!bbs->hidepopups)
cryptlib_error_message(status, "clearing session ownership"); cryptlib_error_message(status, "clearing session ownership");
conn_api.terminate=1; conn_api.terminate=1;
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(-1); return(-1);
} }
if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
create_conn_buf(&conn_inbuf, BUFFER_SIZE); create_conn_buf(&conn_inbuf, BUFFER_SIZE);
...@@ -291,7 +333,8 @@ int ssh_connect(struct bbslist *bbs) ...@@ -291,7 +333,8 @@ int ssh_connect(struct bbslist *bbs)
_beginthread(ssh_output_thread, 0, NULL); _beginthread(ssh_output_thread, 0, NULL);
_beginthread(ssh_input_thread, 0, NULL); _beginthread(ssh_input_thread, 0, NULL);
uifc.pop(NULL); if (!bbs->hidepopups)
uifc.pop(NULL); // TODO: Why is this called twice?
return(0); return(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment