Commit 0ee6fea5 authored by deuce's avatar deuce
Browse files

Add an entry config option to force IPv4 or IPv6 resolution only.

Add -4 and -6 command-line arguments.
Add csr capability to built-in terminfo.
parent b509d44b
......@@ -153,6 +153,12 @@ struct sort_order_info sort_order[] = {
,offsetof(struct bbslist, music)
,sizeof(((struct bbslist *)NULL)->music)
}
,{
"Address Family"
,0
,offsetof(struct bbslist, address_family)
,sizeof(((struct bbslist *)NULL)->address_family)
}
,{
"Font"
,SORT_ORDER_STRING
......@@ -179,6 +185,14 @@ char *rate_names[]={"300", "600", "1200", "2400", "4800", "9600", "19200", "3840
int rates[]={300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 0};
char *music_names[]={"ESC [ | only", "BANSI Style", "All ANSI Music enabled", NULL};
char *address_families[]={"PerDNS", "IPv4", "IPv6", NULL};
char *address_family_names[]={"As per DNS", "IPv4 only", "IPv6 only", NULL};
char *address_family_help = "`Address Family`\n\n"
"Select the address family to resolve\n\n"
"`As per DNS`..: Uses what is in the DNS system\n"
"`IPv4 only`...: Only uses IPv4 addresses.\n"
"`IPv6 only`...: Only uses IPv6 addresses.\n";
char *address_help=
#ifdef __unix__
......@@ -644,6 +658,7 @@ void read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id
entry->bpsrate=iniGetInteger(section,NULL,"BPSRate",0);
entry->music=iniGetInteger(section,NULL,"ANSIMusic",CTERM_MUSIC_BANSI);
entry->address_family=iniGetEnum(section,NULL,"AddressFamily",address_families, ADDRESS_FAMILY_UNSPEC);
iniGetString(section,NULL,"Font","Codepage 437 English",entry->font);
entry->type=type;
entry->id=id;
......@@ -730,8 +745,8 @@ void read_list(char *listpath, struct bbslist **list, struct bbslist *defaults,
int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isdefault)
{
char opt[19][80]; /* <- Beware of magic number! */
char *opts[20]; /* <- Beware of magic number! */
char opt[20][80]; /* <- Beware of magic number! */
char *opts[(sizeof(opt)/sizeof(opt[0]))+1];
int changed=0;
int copt=0,i,j;
int bar=0;
......@@ -742,7 +757,7 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
char *itemname;
char *YesNo[3]={"Yes","No",""};
for(i=0;i<19;i++) /* <- Beware of magic number! */
for(i=0;i<sizeof(opt)/sizeof(opt[0]);i++)
opts[i]=opt[i];
if(item->type==SYSTEM_BBSLIST) {
uifc.helpbuf= "`Copy from system directory`\n\n"
......@@ -805,6 +820,7 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
strcpy(str,"Current");
sprintf(opt[i++], "Comm Rate %s",str);
sprintf(opt[i++], "ANSI Music %s",music_names[item->music]);
sprintf(opt[i++], "Address Family %s",address_family_names[item->address_family]);
sprintf(opt[i++], "Font %s",item->font);
opt[i][0]=0;
uifc.changes=0;
......@@ -1087,6 +1103,15 @@ int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isd
}
break;
case 17:
uifc.helpbuf=address_family_help;
i=item->address_family;
if(uifc.list(WIN_SAV, 0, 0, 0, &i, NULL, "Address Family", address_family_names)!=-1) {
item->address_family=i;
iniSetEnum(&inifile, itemname, "AddressFamily", address_families, item->address_family, &ini_style);
changed=1;
}
break;
case 18:
uifc.helpbuf= "`Font`\n\n"
"Select the desired font for this connection.\n\n"
"Some fonts do not allow some modes. When this is the case, an\n"
......@@ -1146,6 +1171,7 @@ void add_bbs(char *listpath, struct bbslist *bbs)
iniSetBool(&inifile,bbs->name,"AppendLogFile",bbs->append_logfile,&ini_style);
iniSetInteger(&inifile,bbs->name,"BPSRate",bbs->bpsrate,&ini_style);
iniSetInteger(&inifile,bbs->name,"ANSIMusic",bbs->music,&ini_style);
iniSetEnum(&inifile, bbs->name, "AddressFamily", address_families, bbs->address_family, &ini_style);
iniSetString(&inifile,bbs->name,"Font",bbs->font,&ini_style);
if((listfile=fopen(listpath,"w"))!=NULL) {
iniWriteFile(listfile,inifile);
......
......@@ -53,6 +53,12 @@ enum {
,SCREEN_MODE_TERMINATOR
};
enum {
ADDRESS_FAMILY_UNSPEC
,ADDRESS_FAMILY_INET
,ADDRESS_FAMILY_INET6
};
/* NOTE: changing this may require updating sort_order in bbslist.c */
struct bbslist {
char name[LIST_NAME_MAX+1];
......@@ -77,6 +83,7 @@ struct bbslist {
int telnet_loglevel;
int bpsrate;
int music;
int address_family;
char font[80];
};
......
......@@ -420,6 +420,18 @@ int conn_socket_connect(struct bbslist *bbs)
uifc.pop("Looking up host");
memset(&hints, 0, sizeof(hints));
hints.ai_flags=PF_UNSPEC;
switch(bbs->address_family) {
case ADDRESS_FAMILY_INET:
hints.ai_family=PF_INET;
break;
case ADDRESS_FAMILY_INET6:
hints.ai_family=PF_INET6;
break;
case ADDRESS_FAMILY_UNSPEC:
default:
hints.ai_family=PF_UNSPEC;
break;
}
hints.ai_socktype=SOCK_STREAM;
hints.ai_protocol=IPPROTO_TCP;
hints.ai_flags=AI_NUMERICSERV;
......
......@@ -1207,6 +1207,7 @@ int main(int argc, char **argv)
int conn_type=CONN_TYPE_TELNET;
int text_mode;
BOOL override_conn=FALSE;
int addr_family=PF_UNSPEC;
char *last_bbs=NULL;
const char syncterm_termcap[]="\n# terminfo database entry for SyncTERM\n"
"syncterm|SyncTERM 80x25,\n"
......@@ -1229,7 +1230,7 @@ int main(int argc, char **argv)
" il=\\E[%p1%dL,cub=\\E[%p1%dD,cuf=\\E[%p1%dC,rin=\\E[%p1%dT,cuu=\\E[%p1%dA,\n"
" rc=\\E[u,sc=\\E[s,ind=\\E[S,ri=\\E[T,setab=\\E[4%p1%dm,setaf=\\E[3%p1%dm,\n"
" sgr=\\E[0%?%p1%p6%|%t;1%;%?%p4%|%t;5%;%?%p1%p3%|%t;7%;%?%p7%|%t;8%;m,\n"
" smso=\\E[0;1;7m,\n"
" smso=\\E[0;1;7m,csr=\\E[%i%p1%d;%p2%dr\n"
"syncterm-25|SyncTERM No Status Line,\n"
" lines#25,use=syncterm,\n"
"syncterm-27|SyncTERM 80x28 With Status,\n"
......@@ -1301,6 +1302,12 @@ int main(int argc, char **argv)
#endif
)
switch(toupper(argv[i][1])) {
case '6':
addr_family=ADDRESS_FAMILY_INET6;
break;
case '4':
addr_family=ADDRESS_FAMILY_INET;
break;
case 'E':
uifc.esc_delay=atoi(argv[i]+2);
break;
......@@ -1450,6 +1457,8 @@ int main(int argc, char **argv)
parse_url(url, bbs, conn_type, FALSE);
strListFree(&inilines);
}
if(addr_family != ADDRESS_FAMILY_UNSPEC)
bbs->address_family=addr_family;
if(bbs->port==0)
goto USAGE;
}
......@@ -1599,6 +1608,8 @@ int main(int argc, char **argv)
"-t = use telnet mode if URL does not include the scheme\n"
"-r = use rlogin mode if URL does not include the scheme\n"
"-h = use SSH mode if URL does not include the scheme\n"
"-4 = Only resolve IPv4 addresses\n"
"-6 = Only resolve IPv6 addresses\n"
"-s = enable \"Safe Mode\" which prevents writing/browsing local files\n"
"-T = when the ONLY argument, dumps the terminfo entry to stdout and exits\n"
"\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment