Changeset 2637
- Timestamp:
- 02/08/09 12:17:37 (2 years ago)
- Files:
-
- climm/doc/climmrc.5 (modified) (3 diffs)
- climm/include/connection.h (modified) (1 diff)
- climm/include/preferences.h (modified) (2 diffs)
- climm/include/util_opts.h (modified) (2 diffs)
- climm/src/connection.c (modified) (1 diff)
- climm/src/file_util.c (modified) (8 diffs)
- climm/src/oscar_dc.c (modified) (1 diff)
- climm/src/util_io.c (modified) (15 diffs)
- climm/src/util_opts.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
climm/doc/climmrc.5
r2628 r2637 122 122 Remote control FIFOs do not use this setting. 123 123 .RE 124 .SH GENERAL 125 The 126 .B General 127 section includes the options for SOCKS 5, that may be eventually 128 moved to their own section, general options, and some strings to override. 129 .TP 130 .BI s5_use \ <number> 131 Set 132 .I number 133 to 0 to disable and 1 to enable. 124 .TP 125 .BI options \ <options> 126 Define options for this server connection. These give default values for the 127 contacts belonging to this server connection, as well as the following 128 server specific settings: 129 .RS 130 .TP 131 .BI s5_use 132 Enable the use of a socks 5 proxy. 134 133 .TP 135 134 .BI s5_host \ <host> … … 140 139 Connect to socks 5 proxy listening on port 141 140 .IR port . 142 .TP143 .BI s5_auth \ <number>144 Set145 .I number146 to 0 to omit authentication and 1 to do authentication.147 141 .TP 148 142 .BI s5_name \ <name> … … 155 149 .I password 156 150 to socks 5 proxy. 151 .RE 152 .SH GENERAL 153 The 154 .B General 155 section includes general options and some strings to override. 157 156 .PP 158 157 A few book-keeping options are usually placed at the beginning of climm/include/connection.h
r2574 r2637 131 131 UWORD ConnectionServerNType (const char *type, char del); 132 132 val_t ConnectionPrefVal (Server *conn, UDWORD flag); 133 const char *ConnectionPrefStr (Server *conn, UDWORD flag); 133 134 134 135 #define ConnectionC(t) ConnectionC (t DEBUGARGS) climm/include/preferences.h
r2488 r2637 9 9 struct Preferences_s 10 10 { 11 char *s5Host; /* socks 5 settings */12 char *s5Name;13 char *s5Pass;14 UWORD s5Port;15 BOOL s5Use;16 BOOL s5Auth;17 18 11 char *locale; /* the used locale (stripped of encoding) */ 19 12 char *locale_orig; /* the original locale (as from ENV) */ … … 43 36 SBYTE autoupdate; 44 37 45 char *prompt_strftime; /* user define prompt */46 char *prompt; /* user define prompt */38 char *prompt_strftime; /* user defined prompt */ 39 char *prompt; /* user defined prompt */ 47 40 48 41 #ifdef ENABLE_TCL climm/include/util_opts.h
r2536 r2637 88 88 89 89 #define CO_SCRIPT (COF_BOOL | CO_GLOBAL | 0x000104UL) /* open a scripting connection */ 90 #define CO_S5USE (COF_BOOL | CO_SERVER | 0x000404UL) /* use Socks 5 proxy */ 90 91 91 92 #define CO_ENCODING (COF_NUMERIC | CO_CONTACT | 0x06UL) /* the default encoding for this contact */ … … 119 120 120 121 #define CO_OTRPOLICY (COF_STRING | CO_CONTACT | 0x40UL) /* OTR policy for a contact */ 122 123 #define CO_S5HOST (COF_STRING | CO_SERVER | 0x50UL) /* the Socks 5 host */ 124 #define CO_S5PORT (COF_NUMERIC | CO_SERVER | 0x51UL) /* the Socks 5 port */ 125 #define CO_S5NAME (COF_STRING | CO_SERVER | 0x52UL) /* the Socks 5 user name */ 126 #define CO_S5PASS (COF_STRING | CO_SERVER | 0x53UL) /* the Socks 5 user password */ 121 127 122 128 #define CO_COLORNONE (COF_COLOR | CO_GLOBAL | 0x80UL) /* the escape sequence to print for no color */ climm/src/connection.c
r2601 r2637 504 504 } 505 505 506 /* 507 * Query an option for a contact group 508 */ 509 const char *ConnectionPrefStr (Server *serv, UDWORD flag) 510 { 511 const char *res = 0; 512 if (serv->contacts && OptGetStr (&serv->copts, flag, &res)) 513 return res; 514 if (OptGetStr (&prG->copts, flag, &res)) 515 return res; 516 return 0; 517 } 518 climm/src/file_util.c
r2598 r2637 237 237 } 238 238 239 prG->s5Use = 0;240 prG->s5Port = 0;241 242 239 rl_print (i18n (1784, "If you are firewalled, you may need to use a SOCKS5 server. If you do, please enter its hostname or IP address. Otherwise, or if unsure, just press return.\n")); 243 240 rl_printf ("%s ", i18n (1094, "SOCKS5 server:")); … … 249 246 if (strchr (line->txt, ':')) 250 247 { 251 prG->s5Host= strdup (line->txt);252 t = strchr ( prG->s5Host, ':');253 prG->s5Port = atoi (t + 1);248 char *tmp = strdup (line->txt); 249 t = strchr (tmp, ':'); 250 OptSetVal (&prG->copts, CO_S5PORT, atoi (t + 1)); 254 251 *t = '\0'; 252 OptSetStr (&prG->copts, CO_S5HOST, tmp); 253 free (tmp); 255 254 } 256 255 else 257 256 { 258 prG->s5Host = strdup (line->txt); 257 UWORD p = 0; 258 OptSetStr (&prG->copts, CO_S5HOST, line->txt); 259 259 rl_print (i18n (1786, "I also need the port the socks server listens on. If unsure, press return for the default port.\n")); 260 260 rl_printf ("%s ", i18n (1095, "SOCKS5 port:")); … … 262 262 line = UtilIOReadline (stdin); 263 263 if (line) 264 sscanf (line->txt, "%hu", &prG->s5Port); 264 sscanf (line->txt, "%hu", &p); 265 if (!p) 266 p = 1080; 267 OptSetVal (&prG->copts, CO_S5PORT, p); 265 268 } 266 if (!prG->s5Port) 267 prG->s5Port = 1080; 268 269 prG->s5Use = 1; 270 prG->s5Auth = 0; 271 prG->s5Pass = NULL; 272 prG->s5Name = NULL; 269 OptSetVal (&prG->copts, CO_S5USE, 1); 273 270 274 271 rl_print ("\n"); … … 279 276 if (line && line->len) 280 277 { 281 prG->s5Auth = 1; 282 prG->s5Name = strdup (line->txt); 278 OptSetStr (&prG->copts, CO_S5NAME, line->txt); 283 279 rl_print (i18n (1788, "Now I also need the password for this user.\n")); 284 280 rl_printf ("%s ", i18n (1097, "SOCKS5 password:")); … … 286 282 line = UtilIOReadline (stdin); 287 283 if (line && line->len) 288 prG->s5Pass = strdup (line->txt);284 OptSetStr (&prG->copts, CO_S5PASS, line->txt); 289 285 } 290 286 } … … 531 527 { 532 528 PrefParseInt (i); 533 prG->s5Use = i; 529 OptSetVal (&prG->copts, CO_S5USE, i ? 1 : 0); 530 dep = 55; 534 531 } 535 532 else if (!strcasecmp (cmd, "s5_host")) 536 533 { 537 534 PrefParse (tmp); 538 prG->s5Host = strdup (tmp); 535 OptSetStr (&prG->copts, CO_S5HOST, tmp); 536 dep = 55; 539 537 } 540 538 else if (!strcasecmp (cmd, "s5_port")) 541 539 { 542 540 PrefParseInt (i); 543 prG->s5Port = i; 541 OptSetVal (&prG->copts, CO_S5PORT, i); 542 dep = 55; 544 543 } 545 544 else if (!strcasecmp (cmd, "s5_auth")) 546 545 { 547 546 PrefParseInt (i); 548 prG->s5Auth = i;547 dep = 55; 549 548 } 550 549 else if (!strcasecmp (cmd, "s5_name")) 551 550 { 552 551 PrefParse (tmp); 553 prG->s5Name = strdup (tmp); 552 OptSetStr (&prG->copts, CO_S5NAME, tmp); 553 dep = 55; 554 554 } 555 555 else if (!strcasecmp (cmd, "s5_pass")) 556 556 { 557 557 PrefParse (tmp); 558 prG->s5Pass = strdup (tmp); 558 OptSetStr (&prG->copts, CO_S5PASS, tmp); 559 dep = 55; 559 560 } 560 561 else if (!strcasecmp (cmd, "verbose")) … … 1254 1255 case TYPE_SERVER: 1255 1256 serv->c_open = &ConnectionInitServer; 1256 if ( prG->s5Use &&!serv->pref_version)1257 if (!serv->pref_version) 1257 1258 serv->pref_version = 2; 1258 1259 break; … … 1761 1762 } 1762 1763 1763 fprintf (rcf, "\n[General]\n# Support for SOCKS5 server\n"); 1764 fprintf (rcf, "s5_use %d\n", prG->s5Use); 1765 if (!prG->s5Host) 1766 fprintf (rcf, "s5_host \"[none]\"\n"); 1767 else 1768 fprintf (rcf, "s5_host %s\n", s_quote (prG->s5Host)); 1769 fprintf (rcf, "s5_port %d\n", prG->s5Port); 1770 fprintf (rcf, "# If you need authentication, put 1 for s5_auth and fill your name/password\n"); 1771 fprintf (rcf, "s5_auth %d\n", prG->s5Auth); 1772 if (!prG->s5Name) 1773 fprintf (rcf, "s5_name \"[none]\"\n"); 1774 else 1775 fprintf (rcf, "s5_name %s\n", s_quote (prG->s5Name)); 1776 if (!prG->s5Pass) 1777 fprintf (rcf, "s5_pass \"[none]\"\n"); 1778 else 1779 fprintf (rcf, "s5_pass %s\n", s_quote (prG->s5Pass)); 1780 1764 fprintf (rcf, "\n[General]\n"); 1781 1765 fprintf (rcf, "\n#in seconds\nauto_away %lu\n", UD2UL (prG->away_time)); 1782 1766 fprintf (rcf, "\n#For dumb terminals that don't wrap set this."); climm/src/oscar_dc.c
r2567 r2637 282 282 peer->dispatch = &TCPDispatchShake; 283 283 284 if ( prG->s5Use)284 if (ConnectionPrefVal (list->serv, CO_S5USE)) 285 285 { 286 286 peer->sok = list->sok; climm/src/util_io.c
r2574 r2637 113 113 rl_print (i18n (1056, "Socket created, attempting to connect.\n")); 114 114 115 if ( prG->s5Use)115 if (ConnectionPrefVal (conn->serv, CO_S5USE)) 116 116 { 117 117 sin.sin_addr.s_addr = INADDR_ANY; … … 131 131 s5OurPort = ntohs (sin.sin_port); 132 132 133 s5sin.sin_addr.s_addr = inet_addr ( prG->s5Host);133 s5sin.sin_addr.s_addr = inet_addr (ConnectionPrefStr (conn->serv, CO_S5HOST)); 134 134 if (!~s5sin.sin_addr.s_addr) /* name isn't n.n.n.n so must be DNS */ 135 135 { 136 host_struct = gethostbyname ( prG->s5Host);136 host_struct = gethostbyname (ConnectionPrefStr (conn->serv, CO_S5HOST)); 137 137 if (!host_struct) 138 138 { 139 139 if (prG->verbose || (conn->serv && conn == conn->serv->conn)) 140 140 { 141 rl_printf (i18n (1596, "[SOCKS] Can't find hostname %s: %s."), prG->s5Host, hstrerror (h_errno));141 rl_printf (i18n (1596, "[SOCKS] Can't find hostname %s: %s."), ConnectionPrefStr (conn->serv, CO_S5HOST), hstrerror (h_errno)); 142 142 rl_print ("\n"); 143 143 } … … 148 148 } 149 149 s5sin.sin_family = AF_INET; /* we're using the inet not appletalk */ 150 s5sin.sin_port = htons ( prG->s5Port); /* port */150 s5sin.sin_port = htons (ConnectionPrefVal (conn->serv, CO_S5PORT)); /* port */ 151 151 s5Sok = socket (AF_INET, SOCK_STREAM, 0); /* create the unconnected socket */ 152 152 if (s5Sok < 0) … … 170 170 buf[0] = 5; /* protocol version */ 171 171 buf[1] = 1; /* number of methods */ 172 if (! *prG->s5Name || !*prG->s5Pass || !prG->s5Auth)172 if (!ConnectionPrefStr (conn->serv, CO_S5NAME) || !ConnectionPrefStr (conn->serv, CO_S5PASS)) 173 173 buf[2] = 0; /* no authorization required */ 174 174 else … … 176 176 send (s5Sok, buf, 3, 0); 177 177 res = recv (s5Sok, buf, 2, 0); 178 if ( strlen (prG->s5Name) && strlen (prG->s5Pass) && prG->s5Auth)178 if (buf[2]) 179 179 { 180 180 if (res != 2 || buf[0] != 5 || buf[1] != 2) /* username/password authentication */ … … 190 190 } 191 191 buf[0] = 1; /* version of subnegotiation */ 192 buf[1] = strlen ( prG->s5Name);193 memcpy (&buf[2], prG->s5Name, buf[1]);194 buf[2 + buf[1]] = strlen ( prG->s5Pass);195 memcpy (&buf[3 + buf[1]], prG->s5Pass, buf[2 + buf[1]]);192 buf[1] = strlen (ConnectionPrefStr (conn->serv, CO_S5NAME)); 193 memcpy (&buf[2], ConnectionPrefStr (conn->serv, CO_S5NAME), buf[1]); 194 buf[2 + buf[1]] = strlen (ConnectionPrefStr (conn->serv, CO_S5PASS)); 195 memcpy (&buf[3 + buf[1]], ConnectionPrefStr (conn->serv, CO_S5PASS), buf[2 + buf[1]]); 196 196 send (s5Sok, buf, buf[1] + buf[2 + buf[1]] + 3, 0); 197 197 res = recv (s5Sok, buf, 2, 0); … … 267 267 sin.sin_port = htons (conn->port); 268 268 269 if ( prG->s5Use)269 if (ConnectionPrefVal (conn->serv, CO_S5USE)) 270 270 { 271 271 memcpy (&sin.sin_addr.s_addr, &buf[4], 4); … … 357 357 if (rc == -1) 358 358 CONN_FAIL_RC (i18n (1950, "Couldn't set socket nonblocking")); 359 if (conn->server || conn->ip || prG->s5Use)360 { 361 if ( prG->s5Use)359 if (conn->server || conn->ip || ConnectionPrefVal (conn->serv, CO_S5USE)) 360 { 361 if (ConnectionPrefVal (conn->serv, CO_S5USE) && ConnectionPrefStr (conn->serv, CO_S5HOST)) 362 362 { 363 363 origserver = conn->server; 364 364 origip = conn->ip; 365 365 origport = conn->port; 366 conn->server = prG->s5Host;367 conn->port = prG->s5Port;366 conn->server = strdup (ConnectionPrefStr (conn->serv, CO_S5HOST)); 367 conn->port = ConnectionPrefVal (conn->serv, CO_S5PORT); 368 368 conn->ip = -1; 369 369 } … … 387 387 sin.sin_addr.s_addr = htonl (conn->ip); 388 388 389 if (prG->s5Use) 390 { 389 if (ConnectionPrefVal (conn->serv, CO_S5USE)) 390 { 391 free (conn->server); 391 392 conn->server = origserver; 392 393 conn->port = origport; … … 409 410 if (rl_pos () > 0) 410 411 rl_print (i18n (1634, "ok.\n")); 411 if ( prG->s5Use)412 if (ConnectionPrefVal (conn->serv, CO_S5USE)) 412 413 { 413 414 QueueEnqueueData (conn, QUEUE_CON_TIMEOUT, conn->ip, … … 572 573 conn->connect += CONNECT_SOCKS_ADD; 573 574 case 1: 574 if (! prG->s5Use)575 if (!ConnectionPrefVal (conn->serv, CO_S5USE)) 575 576 CONN_OK 576 577 … … 578 579 conn->connect |= CONNECT_SELECT_R; 579 580 conn->connect &= ~CONNECT_SELECT_W & ~CONNECT_SELECT_X; 580 sockwrite (conn->sok, prG->s5Auth ? "\x05\x02\x02\x00" : "\x05\x01\x00", prG->s5Auth ? 4 : 3); 581 if (ConnectionPrefVal (conn->serv, CO_S5NAME) && ConnectionPrefVal (conn->serv, CO_S5PASS)) 582 sockwrite (conn->sok, "\x05\x02\x02\x00", 4); 583 else 584 sockwrite (conn->sok, "\x05\x01\x00", 3); 581 585 return; 582 586 case 2: 583 587 rc = sockread (conn->sok, buf, 2); 584 588 CONN_CHECK (i18n (1601, "[SOCKS] General SOCKS server failure")); 585 if (buf[0] != 5 || !(buf[1] == 0 || (buf[1] == 2 && prG->s5Auth)))589 if (buf[0] != 5 || !(buf[1] == 0 || (buf[1] == 2 && ConnectionPrefVal (conn->serv, CO_S5NAME) && ConnectionPrefVal (conn->serv, CO_S5PASS)))) 586 590 CONN_FAIL (i18n (1599, "[SOCKS] Authentication method incorrect")); 587 591 … … 589 593 if (buf[1] == 2) 590 594 { 591 snprintf (buf, sizeof (buf), "%c%c%s%c%s%n", 1, (char) strlen ( prG->s5Name),592 prG->s5Name, (char) strlen (prG->s5Pass), prG->s5Pass, &len);595 snprintf (buf, sizeof (buf), "%c%c%s%c%s%n", 1, (char) strlen (ConnectionPrefStr (conn->serv, CO_S5NAME)), 596 ConnectionPrefStr (conn->serv, CO_S5NAME), (char) strlen (ConnectionPrefStr (conn->serv, CO_S5PASS)), ConnectionPrefStr (conn->serv, CO_S5NAME), &len); 593 597 sockwrite (conn->sok, buf, len); 594 598 return; … … 934 938 UBYTE *body = NULL, *data = pak->data; 935 939 936 if ( prG->s5Use)940 if (ConnectionPrefVal (conn->serv, CO_S5USE)) 937 941 { 938 942 s5len = 10; … … 965 969 int s5len; 966 970 967 s5len = prG->s5Use? 10 : 0;971 s5len = ConnectionPrefVal (conn->serv, CO_S5USE) ? 10 : 0; 968 972 pak = PacketC (); 969 973 970 pak->len = sockread (conn->sok, prG->s5Use? pak->socks : pak->data, sizeof (pak->data) + s5len);974 pak->len = sockread (conn->sok, ConnectionPrefVal (conn->serv, CO_S5USE) ? pak->socks : pak->data, sizeof (pak->data) + s5len); 971 975 972 976 if (pak->len <= 4 + s5len || pak->len == (UWORD)-1) climm/src/util_opts.c
r2636 r2637 96 96 { "scripting", CO_SCRIPT }, 97 97 { "scriptingpath", CO_SCRIPT_PATH }, 98 { "s5_use", CO_S5USE }, 99 { "s5_port", CO_S5PORT }, 100 { "s5_host", CO_S5HOST }, 101 { "s5_name", CO_S5NAME }, 102 { "s5_pass", CO_S5PASS }, 98 103 #ifdef ENABLE_OTR 99 104 { "otrpolicy", CO_OTRPOLICY },
