Fossil

Check-in [676fdd088a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enable proxy support using the "fossil setting proxy" command. This check-in is made using a proxy.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 676fdd088ad1a95ef587a25fe5c64bd3e42787fd
User & Date: drh 2008-05-01 22:49:57.000
Context
2008-05-05
17:24
Add the ability to modify global settings (such as the proxy setting) even when there are no repositories defined. check-in: 4e683ef07b user: drh tags: trunk
2008-05-01
22:49
Enable proxy support using the "fossil setting proxy" command. This check-in is made using a proxy. check-in: 676fdd088a user: drh tags: trunk
18:42
On windows builds, understand both "C:/" and "C:\" as the beginning of an absolute pathname. check-in: becc24e4e9 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/clone.c.
70
71
72
73
74
75
76

77
78
79
80
81
    while( db_step(&q)==SQLITE_ROW ){
      const char *zTab = db_column_text(&q, 0);
      db_multi_exec("INSERT OR IGNORE INTO %Q SELECT * FROM orig.%Q",
                    zTab, zTab);
    }
    db_finalize(&q);
  }else{

    client_sync(0,0,1);
  }
  verify_cancel();
  db_end_transaction(0);
}







>





70
71
72
73
74
75
76
77
78
79
80
81
82
    while( db_step(&q)==SQLITE_ROW ){
      const char *zTab = db_column_text(&q, 0);
      db_multi_exec("INSERT OR IGNORE INTO %Q SELECT * FROM orig.%Q",
                    zTab, zTab);
    }
    db_finalize(&q);
  }else{
    url_enable_proxy(0);
    client_sync(0,0,1);
  }
  verify_cancel();
  db_end_transaction(0);
}
Changes to src/db.c.
891
892
893
894
895
896
897




















898
899
900
901
902
903
904
    );
    if( g.fSqlTrace ){
      sqlite3_trace(g.db, db_sql_trace, 0);
    }
    once = 0;
  }
}





















/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
  char *z = 0;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
    );
    if( g.fSqlTrace ){
      sqlite3_trace(g.db, db_sql_trace, 0);
    }
    once = 0;
  }
}

/*
** Return true if the string zVal represents "true" (or "false").
*/
int is_truth(const char *zVal){
  static const char *azOn[] = { "on", "yes", "true", "1" };
  int i;
  for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
    if( strcmp(zVal,azOn[i])==0 ) return 1;
  }
  return 0;
}
int is_false(const char *zVal){
  static const char *azOff[] = { "off", "no", "false", "0" };
  int i;
  for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
    if( strcmp(zVal,azOff[i])==0 ) return 1;
  }
  return 0;
}

/*
** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the
** repository and local databases.
*/
char *db_get(const char *zName, char *zDefault){
  char *z = 0;
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
                globalFlag ? "global_" : "", zName, value);
  if( globalFlag && g.repositoryOpen ){
    db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
  }
  db_end_transaction(0);
}
int db_get_boolean(const char *zName, int dflt){
  static const char *azOn[] = { "on", "yes", "true", "1" };
  static const char *azOff[] = { "off", "no", "false", "0" };
  int i;
  char *zVal = db_get(zName, dflt ? "on" : "off");
  for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
    if( strcmp(zVal,azOn[i])==0 ) return 1;
  }
  for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
    if( strcmp(zVal,azOff[i])==0 ) return 0;
  }
  return dflt;
}
char *db_lget(const char *zName, char *zDefault){
  return db_text((char*)zDefault,
                 "SELECT value FROM vvar WHERE name=%Q", zName);
}
void db_lset(const char *zName, const char *zValue){







<
<
<

<
|
<
<
|
<







974
975
976
977
978
979
980



981

982


983

984
985
986
987
988
989
990
                globalFlag ? "global_" : "", zName, value);
  if( globalFlag && g.repositoryOpen ){
    db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
  }
  db_end_transaction(0);
}
int db_get_boolean(const char *zName, int dflt){



  char *zVal = db_get(zName, dflt ? "on" : "off");

  if( is_truth(zVal) ) return 1;


  if( is_false(zVal) ) return 0;

  return dflt;
}
char *db_lget(const char *zName, char *zDefault){
  return db_text((char*)zDefault,
                 "SELECT value FROM vvar WHERE name=%Q", zName);
}
void db_lset(const char *zName, const char *zValue){
1061
1062
1063
1064
1065
1066
1067


1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081

1082
1083
1084
1085
1086
1087
1088
**    localauth        If enabled, require that HTTP connections from
**                     127.0.0.1 be authenticated by password.  If
**                     false, all HTTP requests from localhost have
**                     unrestricted access to the repository.
**
**    omitsign         When enabled, fossil will not attempt to sign any
**                     commit with gpg. All commits will be unsigned.


**
**    diff-command     External command to run when performing a diff.
**                     If undefined, the internal text diff will be used.
**
**    gdiff-command    External command to run when performing a graphical
**                     diff. If undefined, text diff will be used.
*/
void setting_cmd(void){
  static const char *azName[] = {
    "autosync",
    "pgp-command",
    "editor",
    "localauth",
    "omitsign",

    "diff-command",
    "gdiff-command",
  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;
  db_find_and_open_repository();
  if( g.argc==2 ){







>
>














>







1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
**    localauth        If enabled, require that HTTP connections from
**                     127.0.0.1 be authenticated by password.  If
**                     false, all HTTP requests from localhost have
**                     unrestricted access to the repository.
**
**    omitsign         When enabled, fossil will not attempt to sign any
**                     commit with gpg. All commits will be unsigned.
**
**    proxy            URL of the HTTP proxy to use
**
**    diff-command     External command to run when performing a diff.
**                     If undefined, the internal text diff will be used.
**
**    gdiff-command    External command to run when performing a graphical
**                     diff. If undefined, text diff will be used.
*/
void setting_cmd(void){
  static const char *azName[] = {
    "autosync",
    "pgp-command",
    "editor",
    "localauth",
    "omitsign",
    "proxy",
    "diff-command",
    "gdiff-command",
  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;
  db_find_and_open_repository();
  if( g.argc==2 ){
Changes to src/sync.c.
56
57
58
59
60
61
62

63
64
65
66
67
68
69
    return 0;  /* Network sync only */
  }
  if( g.urlPort!=80 ){
    printf("Autosync:  http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
  }else{
    printf("Autosync:  http://%s%s\n", g.urlName, g.urlPath);
  }

  client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0);
  return 1;
}

/*
** This routine processes the command-line argument for push, pull,
** and sync.  If a command-line argument is given, that is the URL







>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    return 0;  /* Network sync only */
  }
  if( g.urlPort!=80 ){
    printf("Autosync:  http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
  }else{
    printf("Autosync:  http://%s%s\n", g.urlName, g.urlPath);
  }
  url_enable_proxy("via proxy: ");
  client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0);
  return 1;
}

/*
** This routine processes the command-line argument for push, pull,
** and sync.  If a command-line argument is given, that is the URL
90
91
92
93
94
95
96

97
98
99
100
101
102
103
  if( g.argc==2 ){
    if( g.urlPort!=80 ){
      printf("Server:    http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
    }else{
      printf("Server:    http://%s%s\n", g.urlName, g.urlPath);
    }
  }

}

/*
** COMMAND: pull
**
** Usage: %fossil pull ?URL? ?-R|--respository REPOSITORY?
**







>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  if( g.argc==2 ){
    if( g.urlPort!=80 ){
      printf("Server:    http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
    }else{
      printf("Server:    http://%s%s\n", g.urlName, g.urlPath);
    }
  }
  url_enable_proxy("via proxy: ");
}

/*
** COMMAND: pull
**
** Usage: %fossil pull ?URL? ?-R|--respository REPOSITORY?
**
Changes to src/url.c.
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127














  }
}

/*
** COMMAND: test-urlparser
*/
void cmd_test_urlparser(void){
  if( g.argc!=3 ){
    usage("URL");
  }
  url_parse(g.argv[2]);
  printf("g.urlIsFile    = %d\n", g.urlIsFile);
  printf("g.urlName      = %s\n", g.urlName);
  printf("g.urlPort      = %d\n", g.urlPort);
  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);
}





















|











>
>
>
>
>
>
>
>
>
>
>
>
>
>
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  }
}

/*
** COMMAND: test-urlparser
*/
void cmd_test_urlparser(void){
  if( g.argc!=3 && g.argc!=4 ){
    usage("URL");
  }
  url_parse(g.argv[2]);
  printf("g.urlIsFile    = %d\n", g.urlIsFile);
  printf("g.urlName      = %s\n", g.urlName);
  printf("g.urlPort      = %d\n", g.urlPort);
  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 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 = db_get("proxy", 0);
  if( zProxy && zProxy[0] && !is_false(zProxy) ){
    char *zOriginalUrl = g.urlCanonical;
    if( zMsg ) printf("%s%s\n", zMsg, zProxy);
    url_parse(zProxy);
    g.urlPath = zOriginalUrl;
  }
}