Sat, 21 Apr 2001 23:53:06 +0000
[gaim-migrate @ 1751]
thanks decklin :)
committer: Eric Warmenhoven <warmenhoven@yahoo.com>
| 1152 | 1 | /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | /* | |
|
1432
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
3 | $Id: proxy.c 1442 2001-01-28 01:52:27Z warmenhoven $ |
| 1152 | 4 | $Log$ |
|
1432
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
5 | Revision 1.3 2001/01/28 01:52:27 warmenhoven |
|
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
6 | icqlib 1.1.5 |
|
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
7 | |
|
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
8 | Revision 1.9 2001/01/17 01:19:49 bills |
|
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
9 | cleanup |
| 1152 | 10 | |
| 11 | Revision 1.8 2000/05/10 18:51:23 denis | |
| 12 | icq_Disconnect() now called before icq_Disconnected callback to | |
| 13 | prevent high CPU usage in kicq's "reconnect on disconnect" code. | |
| 14 | ||
| 15 | Revision 1.7 2000/05/03 18:29:15 denis | |
| 16 | Callbacks have been moved to the ICQLINK structure. | |
| 17 | ||
| 18 | Revision 1.6 2000/04/05 14:37:02 denis | |
| 19 | Applied patch from "Guillaume R." <grs@mail.com> for basic Win32 | |
| 20 | compatibility. | |
| 21 | ||
| 22 | Revision 1.5 1999/10/07 18:00:59 denis | |
| 23 | proxy.h file removed. | |
| 24 | ||
| 25 | Revision 1.4 1999/07/16 12:01:06 denis | |
| 26 | ICQLINK support added. | |
| 27 | ||
| 28 | Revision 1.3 1999/07/12 15:13:33 cproch | |
| 29 | - added definition of ICQLINK to hold session-specific global variabled | |
| 30 | applications which have more than one connection are now possible | |
| 31 | - changed nearly every function defintion to support ICQLINK parameter | |
| 32 | ||
| 33 | Revision 1.2 1999/04/14 14:51:42 denis | |
| 34 | Switched from icq_Log callback to icq_Fmt function. | |
| 35 | Cleanups for "strict" compiling (-ansi -pedantic) | |
| 36 | ||
| 37 | Revision 1.1 1999/03/24 11:37:38 denis | |
| 38 | Underscored files with TCP stuff renamed. | |
| 39 | TCP stuff cleaned up | |
| 40 | Function names changed to corresponding names. | |
| 41 | icqlib.c splitted to many small files by subject. | |
| 42 | C++ comments changed to ANSI C comments. | |
| 43 | ||
| 44 | */ | |
| 45 | ||
| 46 | #ifndef _WIN32 | |
| 47 | #include <unistd.h> | |
|
1432
ab10a52f94a7
[gaim-migrate @ 1442]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1309
diff
changeset
|
48 | #else |
| 1152 | 49 | #include <winsock.h> |
| 50 | #endif | |
| 51 | ||
| 52 | #include <stdlib.h> | |
| 53 | ||
| 54 | #include "util.h" | |
| 55 | #include "icqtypes.h" | |
| 56 | #include "icq.h" | |
| 57 | #include "icqlib.h" | |
| 58 | ||
| 59 | void icq_HandleProxyResponse(ICQLINK *link) | |
| 60 | { | |
| 61 | int s; | |
| 62 | char buf[256]; | |
| 63 | #ifdef _WIN32 | |
| 64 | s = recv(link->icq_ProxySok, buf, sizeof(buf), 0); | |
| 65 | #else | |
| 66 | s = read(link->icq_ProxySok, &buf, sizeof(buf)); | |
| 67 | #endif | |
| 68 | if(s<=0) | |
| 69 | { | |
| 70 | icq_FmtLog(link, ICQ_LOG_FATAL, "[SOCKS] Connection terminated\n"); | |
| 71 | icq_Disconnect(link); | |
| 72 | if(link->icq_Disconnected) | |
| 73 | (*link->icq_Disconnected)(link); | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | /******************* | |
| 78 | SOCKS5 Proxy support | |
| 79 | ********************/ | |
| 80 | void icq_SetProxy(ICQLINK *link, const char *phost, unsigned short pport, int pauth, const char *pname, const char *ppass) | |
| 81 | { | |
| 82 | if(link->icq_ProxyHost) | |
| 83 | free(link->icq_ProxyHost); | |
| 84 | if(link->icq_ProxyName) | |
| 85 | free(link->icq_ProxyName); | |
| 86 | if(link->icq_ProxyPass) | |
| 87 | free(link->icq_ProxyPass); | |
| 88 | if(strlen(pname)>255) | |
| 89 | { | |
| 90 | icq_FmtLog(link, ICQ_LOG_ERROR, "[SOCKS] User name greater than 255 chars\n"); | |
| 91 | link->icq_UseProxy = 0; | |
| 92 | return; | |
| 93 | } | |
| 94 | if(strlen(ppass)>255) | |
| 95 | { | |
| 96 | icq_FmtLog(link, ICQ_LOG_ERROR, "[SOCKS] User password greater than 255 chars\n"); | |
| 97 | link->icq_UseProxy = 0; | |
| 98 | return; | |
| 99 | } | |
| 100 | link->icq_UseProxy = 1; | |
| 101 | link->icq_ProxyHost = strdup(phost); | |
| 102 | link->icq_ProxyPort = pport; | |
| 103 | link->icq_ProxyAuth = pauth; | |
| 104 | link->icq_ProxyName = strdup(pname); | |
| 105 | link->icq_ProxyPass = strdup(ppass); | |
| 106 | } | |
| 107 | ||
| 108 | void icq_UnsetProxy(ICQLINK *link) | |
| 109 | { | |
| 110 | link->icq_UseProxy = 0; | |
| 111 | } | |
| 112 | ||
| 113 | int icq_GetProxySok(ICQLINK *link) | |
| 114 | { | |
| 115 | return link->icq_ProxySok; | |
| 116 | } |