Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add code to understand the "https://" prefix on server URLs. Any attempt to use https gives an error at this point, however. This is a work in progress. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
797d680ef52b7f88390b82f106275fa6 |
| User & Date: | drh 2009-01-13 18:43:47.000 |
Context
|
2009-01-14
| ||
| 01:09 | Update SQLite to fix the OR-clause query optimizer bug. That bug is probably harmless to SQLite, but it doesn't hurt to check in the fix. check-in: 037cae8ff6 user: drh tags: trunk | |
|
2009-01-13
| ||
| 18:43 | Add code to understand the "https://" prefix on server URLs. Any attempt to use https gives an error at this point, however. This is a work in progress. check-in: 797d680ef5 user: drh tags: trunk | |
| 18:06 | Do not do the login-bypass if the HTTPS env var is ON. This might indicate that a remote HTTPS connection is being converted to HTTP locally using stunnel (or the equivalent). check-in: 3da8a12f48 user: drh tags: trunk | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
}
if( zUri[i]=='/' ){
blob_set(pPath, &zUri[i]);
}else{
blob_set(pPath, "/");
}
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
}
if( zUri[i]=='/' ){
blob_set(pPath, &zUri[i]);
}else{
blob_set(pPath, "/");
}
}
/*
** Construct a random temporary filename into zBuf[].
*/
void file_tempname(int nBuf, char *zBuf){
static const char *azDirs[] = {
"/var/tmp",
"/usr/tmp",
"/tmp",
"/temp",
".",
};
static const unsigned char zChars[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
unsigned int i, j;
struct stat buf;
const char *zDir = ".";
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
if( stat(azDirs[i], &buf) ) continue;
if( !S_ISDIR(buf.st_mode) ) continue;
if( access(azDirs[i], 07) ) continue;
zDir = azDirs[i];
break;
}
/* Check that the output buffer is large enough for the temporary file
** name. If it is not, return SQLITE_ERROR.
*/
if( (strlen(zDir) + 17) >= (size_t)nBuf ){
fossil_fatal("insufficient space for temporary filename");
}
do{
sqlite3_snprintf(nBuf-17, zBuf, "%s/", zDir);
j = (int)strlen(zBuf);
sqlite3_randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
}
zBuf[j] = 0;
}while( access(zBuf,0)==0 );
}
|
Changes to src/http.c.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 |
** non-zero if an error occurs.
*/
static int http_open_socket(void){
static struct sockaddr_in addr; /* The server address */
static int addrIsInit = 0; /* True once addr is initialized */
int s;
| | > | > < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
** non-zero if an error occurs.
*/
static int http_open_socket(void){
static struct sockaddr_in addr; /* The server address */
static int addrIsInit = 0; /* True once addr is initialized */
int s;
if( g.urlIsHttps ){
fossil_fatal("SSL/TLS is not yet implemented.");
}
ws_init();
if( !addrIsInit ){
addr.sin_family = AF_INET;
addr.sin_port = htons(g.urlPort);
*(int*)&addr.sin_addr = inet_addr(g.urlName);
if( -1 == *(int*)&addr.sin_addr ){
#ifndef FOSSIL_STATIC_LINK
struct hostent *pHost;
pHost = gethostbyname(g.urlName);
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 | FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */ int *aCommitFile; /* Array of files to be committed */ int urlIsFile; /* True if a "file:" url */ char *urlName; /* Hostname for http: or filename for file: */ char *urlHostname; /* The HOST: parameter on http headers */ | > > | > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */ int *aCommitFile; /* Array of files to be committed */ int urlIsFile; /* True if a "file:" url */ int urlIsHttps; /* True if a "https:" url */ char *urlName; /* Hostname for http: or filename for file: */ char *urlHostname; /* The HOST: parameter on http headers */ char *urlProtocol; /* "http" or "https" */ int urlPort; /* TCP port number for http: or https: */ int urlDfltPort; /* The default port for the given protocol */ char *urlPath; /* Pathname for http: */ char *urlUser; /* User id for http: */ char *urlPasswd; /* Password for http: */ char *urlCanonical; /* Canonical representation of the URL */ const char *zLogin; /* Login name. "" if not logged in. */ int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| ︙ | ︙ |
Changes to src/sync.c.
| ︙ | ︙ | |||
53 54 55 56 57 58 59 |
if( zUrl==0 ){
return; /* No default server */
}
url_parse(zUrl);
if( g.urlIsFile ){
return; /* Network sync only */
}
| | > | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
if( zUrl==0 ){
return; /* No default server */
}
url_parse(zUrl);
if( g.urlIsFile ){
return; /* Network sync only */
}
if( g.urlPort!=g.urlDfltPort ){
printf("Autosync: %s://%s:%d%s\n",
g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
}else{
printf("Autosync: %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
}
url_enable_proxy("via proxy: ");
client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0, 0, 0);
}
/*
** This routine processes the command-line argument for push, pull,
|
| ︙ | ︙ | |||
89 90 91 92 93 94 95 |
url_parse(zUrl);
if( g.urlIsFile ){
fossil_fatal("network sync only");
}
db_set("last-sync-url", zUrl, 0);
user_select();
if( g.argc==2 ){
| | > | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
url_parse(zUrl);
if( g.urlIsFile ){
fossil_fatal("network sync only");
}
db_set("last-sync-url", zUrl, 0);
user_select();
if( g.argc==2 ){
if( g.urlPort!=g.urlDfltPort ){
printf("Server: %s://%s:%d%s\n",
g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
}else{
printf("Server: %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
}
}
url_enable_proxy("via proxy: ");
}
/*
** COMMAND: pull
|
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
41 42 43 44 45 46 47 |
**
** http://userid:password@host:port/path?query#fragment
**
*/
void url_parse(const char *zUrl){
int i, j, c;
char *zFile = 0;
| | > > > > > > > > > > > > | | | | | | | > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
**
** http://userid:password@host:port/path?query#fragment
**
*/
void url_parse(const char *zUrl){
int i, j, c;
char *zFile = 0;
if( strncmp(zUrl, "http://", 7)==0 || strncmp(zUrl, "https://", 8)==0 ){
int iStart;
g.urlIsFile = 0;
if( zUrl[4]=='s' ){
g.urlIsHttps = 1;
g.urlProtocol = "https";
g.urlDfltPort = 443;
iStart = 8;
}else{
g.urlIsHttps = 0;
g.urlProtocol = "http";
g.urlDfltPort = 80;
iStart = 7;
}
for(i=iStart; (c=zUrl[i])!=0 && c!='/' && c!='@'; i++){}
if( c=='@' ){
for(j=iStart; j<i && zUrl[j]!=':'; j++){}
g.urlUser = mprintf("%.*s", j-iStart, &zUrl[iStart]);
if( j<i ){
g.urlPasswd = mprintf("%.*s", i-j-1, &zUrl[j+1]);
}
for(j=i+1; (c=zUrl[j])!=0 && c!='/' && c!=':'; j++){}
g.urlName = mprintf("%.*s", j-i-1, &zUrl[i+1]);
i = j;
}else{
for(i=iStart; (c=zUrl[i])!=0 && c!='/' && c!=':'; i++){}
g.urlName = mprintf("%.*s", i-iStart, &zUrl[iStart]);
}
for(j=0; g.urlName[j]; j++){ g.urlName[j] = tolower(g.urlName[j]); }
if( c==':' ){
g.urlPort = 0;
i++;
while( (c = zUrl[i])!=0 && isdigit(c) ){
g.urlPort = g.urlPort*10 + c - '0';
i++;
}
g.urlHostname = mprintf("%s:%d", g.urlName, g.urlPort);
}else{
g.urlPort = g.urlDfltPort;
g.urlHostname = g.urlName;
}
g.urlPath = mprintf(&zUrl[i]);
dehttpize(g.urlName);
dehttpize(g.urlPath);
g.urlCanonical = mprintf("%s://%T:%d%T",
g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
}else if( strncmp(zUrl, "file:", 5)==0 ){
g.urlIsFile = 1;
if( zUrl[5]=='/' && zUrl[6]=='/' ){
i = 7;
}else{
i = 5;
}
|
| ︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
url_proxy_options();
if( g.argc!=3 && g.argc!=4 ){
usage("URL");
}
url_parse(g.argv[2]);
for(i=0; i<2; i++){
printf("g.urlIsFile = %d\n", g.urlIsFile);
printf("g.urlName = %s\n", g.urlName);
printf("g.urlPort = %d\n", g.urlPort);
printf("g.urlHostname = %s\n", g.urlHostname);
printf("g.urlPath = %s\n", g.urlPath);
printf("g.urlUser = %s\n", g.urlUser);
printf("g.urlPasswd = %s\n", g.urlPasswd);
printf("g.urlCanonical = %s\n", g.urlCanonical);
if( i==0 ){
printf("********\n");
| > > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
url_proxy_options();
if( g.argc!=3 && g.argc!=4 ){
usage("URL");
}
url_parse(g.argv[2]);
for(i=0; i<2; i++){
printf("g.urlIsFile = %d\n", g.urlIsFile);
printf("g.urlIsHttps = %d\n", g.urlIsHttps);
printf("g.urlProtocol = %s\n", g.urlProtocol);
printf("g.urlName = %s\n", g.urlName);
printf("g.urlPort = %d\n", g.urlPort);
printf("g.urlDfltPort = %d\n", g.urlDfltPort);
printf("g.urlHostname = %s\n", g.urlHostname);
printf("g.urlPath = %s\n", g.urlPath);
printf("g.urlUser = %s\n", g.urlUser);
printf("g.urlPasswd = %s\n", g.urlPasswd);
printf("g.urlCanonical = %s\n", g.urlCanonical);
if( i==0 ){
printf("********\n");
|
| ︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
zProxyOpt = find_option("proxy", 0, 1);
if( find_option("nosync",0,0) ) g.fNoSync = 1;
}
/*
** If the "proxy" setting is defined, then change the URL to refer
** to the proxy server.
*/
void url_enable_proxy(const char *zMsg){
const char *zProxy;
zProxy = zProxyOpt;
if( zProxy==0 ){
zProxy = db_get("proxy", 0);
if( zProxy==0 || zProxy[0]==0 || is_truth(zProxy) ){
| > > > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
zProxyOpt = find_option("proxy", 0, 1);
if( find_option("nosync",0,0) ) g.fNoSync = 1;
}
/*
** If the "proxy" setting is defined, then change the URL to refer
** to the proxy server.
**
** If the protocol is "https://" then start stunnel to handle the SSL
** and make the url setting refer to stunnel rather than the original
** destination.
*/
void url_enable_proxy(const char *zMsg){
const char *zProxy;
zProxy = zProxyOpt;
if( zProxy==0 ){
zProxy = db_get("proxy", 0);
if( zProxy==0 || zProxy[0]==0 || is_truth(zProxy) ){
|
| ︙ | ︙ |