Fossil SCM

Add the --proxy command-line option that can be used to enable or disable an http proxy on a case by case basis.

drh 2008-05-06 12:24 trunk
Commit f652599003d139cada15dffdbb6c8587db4a1eef
--- src/clone.c
+++ src/clone.c
@@ -36,10 +36,11 @@
3636
**
3737
** Make a clone of a repository specified by URL in the local
3838
** file named FILENAME.
3939
*/
4040
void clone_cmd(void){
41
+ url_proxy_options();
4142
if( g.argc!=4 ){
4243
usage("FILE-OR-URL NEW-REPOSITORY");
4344
}
4445
db_open_config();
4546
if( file_size(g.argv[3])>0 ){
4647
--- src/clone.c
+++ src/clone.c
@@ -36,10 +36,11 @@
36 **
37 ** Make a clone of a repository specified by URL in the local
38 ** file named FILENAME.
39 */
40 void clone_cmd(void){
 
41 if( g.argc!=4 ){
42 usage("FILE-OR-URL NEW-REPOSITORY");
43 }
44 db_open_config();
45 if( file_size(g.argv[3])>0 ){
46
--- src/clone.c
+++ src/clone.c
@@ -36,10 +36,11 @@
36 **
37 ** Make a clone of a repository specified by URL in the local
38 ** file named FILENAME.
39 */
40 void clone_cmd(void){
41 url_proxy_options();
42 if( g.argc!=4 ){
43 usage("FILE-OR-URL NEW-REPOSITORY");
44 }
45 db_open_config();
46 if( file_size(g.argv[3])>0 ){
47
+1
--- src/sync.c
+++ src/sync.c
@@ -71,10 +71,11 @@
7171
** of a server to sync against. If no argument is given, use the
7272
** most recently synced URL. Remember the current URL for next time.
7373
*/
7474
static void process_sync_args(void){
7575
const char *zUrl = 0;
76
+ url_proxy_options();
7677
db_find_and_open_repository(1);
7778
if( g.argc==2 ){
7879
zUrl = db_get("last-sync-url", 0);
7980
}else if( g.argc==3 ){
8081
zUrl = g.argv[2];
8182
--- src/sync.c
+++ src/sync.c
@@ -71,10 +71,11 @@
71 ** of a server to sync against. If no argument is given, use the
72 ** most recently synced URL. Remember the current URL for next time.
73 */
74 static void process_sync_args(void){
75 const char *zUrl = 0;
 
76 db_find_and_open_repository(1);
77 if( g.argc==2 ){
78 zUrl = db_get("last-sync-url", 0);
79 }else if( g.argc==3 ){
80 zUrl = g.argv[2];
81
--- src/sync.c
+++ src/sync.c
@@ -71,10 +71,11 @@
71 ** of a server to sync against. If no argument is given, use the
72 ** most recently synced URL. Remember the current URL for next time.
73 */
74 static void process_sync_args(void){
75 const char *zUrl = 0;
76 url_proxy_options();
77 db_find_and_open_repository(1);
78 if( g.argc==2 ){
79 zUrl = db_get("last-sync-url", 0);
80 }else if( g.argc==3 ){
81 zUrl = g.argv[2];
82
+23 -3
--- src/url.c
+++ src/url.c
@@ -114,10 +114,11 @@
114114
/*
115115
** COMMAND: test-urlparser
116116
*/
117117
void cmd_test_urlparser(void){
118118
int i;
119
+ url_proxy_options();
119120
if( g.argc!=3 && g.argc!=4 ){
120121
usage("URL");
121122
}
122123
url_parse(g.argv[2]);
123124
for(i=0; i<2; i++){
@@ -133,19 +134,38 @@
133134
printf("********\n");
134135
url_enable_proxy("Using proxy: ");
135136
}
136137
}
137138
}
139
+
140
+/*
141
+** Proxy specified on the command-line.
142
+*/
143
+static const char *zProxyOpt = 0;
144
+
145
+/*
146
+** Extra any proxy options from the command-line.
147
+**
148
+** --proxy URL|off
149
+**
150
+*/
151
+void url_proxy_options(void){
152
+ zProxyOpt = find_option("proxy", 0, 1);
153
+}
138154
139155
/*
140156
** If the "proxy" setting is defined, then change the URL to refer
141157
** to the proxy server.
142158
*/
143159
void url_enable_proxy(const char *zMsg){
144
- const char *zProxy = db_get("proxy", 0);
145
- if( zProxy==0 || zProxy[0] || is_false(zProxy) ){
146
- zProxy = getenv("http_proxy");
160
+ const char *zProxy;
161
+ zProxy = zProxyOpt;
162
+ if( zProxy==0 ){
163
+ zProxy = db_get("proxy", 0);
164
+ if( zProxy==0 || zProxy[0] || is_false(zProxy) ){
165
+ zProxy = getenv("http_proxy");
166
+ }
147167
}
148168
if( zProxy && zProxy[0] && !is_false(zProxy) ){
149169
char *zOriginalUrl = g.urlCanonical;
150170
char *zOriginalHost = g.urlHostname;
151171
if( zMsg ) printf("%s%s\n", zMsg, zProxy);
152172
--- src/url.c
+++ src/url.c
@@ -114,10 +114,11 @@
114 /*
115 ** COMMAND: test-urlparser
116 */
117 void cmd_test_urlparser(void){
118 int i;
 
119 if( g.argc!=3 && g.argc!=4 ){
120 usage("URL");
121 }
122 url_parse(g.argv[2]);
123 for(i=0; i<2; i++){
@@ -133,19 +134,38 @@
133 printf("********\n");
134 url_enable_proxy("Using proxy: ");
135 }
136 }
137 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
139 /*
140 ** If the "proxy" setting is defined, then change the URL to refer
141 ** to the proxy server.
142 */
143 void url_enable_proxy(const char *zMsg){
144 const char *zProxy = db_get("proxy", 0);
145 if( zProxy==0 || zProxy[0] || is_false(zProxy) ){
146 zProxy = getenv("http_proxy");
 
 
 
 
147 }
148 if( zProxy && zProxy[0] && !is_false(zProxy) ){
149 char *zOriginalUrl = g.urlCanonical;
150 char *zOriginalHost = g.urlHostname;
151 if( zMsg ) printf("%s%s\n", zMsg, zProxy);
152
--- src/url.c
+++ src/url.c
@@ -114,10 +114,11 @@
114 /*
115 ** COMMAND: test-urlparser
116 */
117 void cmd_test_urlparser(void){
118 int i;
119 url_proxy_options();
120 if( g.argc!=3 && g.argc!=4 ){
121 usage("URL");
122 }
123 url_parse(g.argv[2]);
124 for(i=0; i<2; i++){
@@ -133,19 +134,38 @@
134 printf("********\n");
135 url_enable_proxy("Using proxy: ");
136 }
137 }
138 }
139
140 /*
141 ** Proxy specified on the command-line.
142 */
143 static const char *zProxyOpt = 0;
144
145 /*
146 ** Extra any proxy options from the command-line.
147 **
148 ** --proxy URL|off
149 **
150 */
151 void url_proxy_options(void){
152 zProxyOpt = find_option("proxy", 0, 1);
153 }
154
155 /*
156 ** If the "proxy" setting is defined, then change the URL to refer
157 ** to the proxy server.
158 */
159 void url_enable_proxy(const char *zMsg){
160 const char *zProxy;
161 zProxy = zProxyOpt;
162 if( zProxy==0 ){
163 zProxy = db_get("proxy", 0);
164 if( zProxy==0 || zProxy[0] || is_false(zProxy) ){
165 zProxy = getenv("http_proxy");
166 }
167 }
168 if( zProxy && zProxy[0] && !is_false(zProxy) ){
169 char *zOriginalUrl = g.urlCanonical;
170 char *zOriginalHost = g.urlHostname;
171 if( zMsg ) printf("%s%s\n", zMsg, zProxy);
172
--- www/quickstart.html
+++ www/quickstart.html
@@ -223,11 +223,21 @@
223223
224224
</blockquote><a name="proxy"></a><h2>HTTP Proxies</h2><blockquote>
225225
226226
<p>If you are behind a restrictive firewall that requires you to use
227227
an HTTP proxy to reach the internet, then you can configure the proxy
228
- in one of two ways. You can tell fossil about your proxy like this:<p>
228
+ in three different ways. You can tell fossil about your proxy using
229
+ a command-line option on commands that use the network,
230
+ <b>sync</b>, <b>clone</b>, <b>push</b>, and <b>pull</b>.</p>
231
+
232
+ <blockquote>
233
+ <b>fossil clone </b><i>URL</i> <b>--proxy</b> <i>Proxy-URL</i>
234
+ </blockquote>
235
+
236
+ <p>It is annoying to have to type in the proxy URL every time you
237
+ sync your project, though, so you can make the proxy configuration
238
+ persistent using the <b>setting</b> command:</p>
229239
230240
<blockquote>
231241
<b>fossil setting proxy </b><i>Proxy-URL</i>
232242
</blockquote>
233243
@@ -242,11 +252,19 @@
242252
<blockquote>
243253
<b>fossil setting proxy off</b>
244254
</blockquote>
245255
246256
<p>Or unset the environment variable. The fossil setting for the
247
- HTTP proxy takes precedence over the environment variable.</p>
257
+ HTTP proxy takes precedence over the environment variable and the
258
+ command-line option overrides both. If you have an persistent
259
+ proxy setting that you want to override for a one-time sync, that
260
+ is easily done on the command-line. For example, to sync with
261
+ a co-workers repository on your LAN, you might type:</p>
262
+
263
+ <blockquote>
264
+ <b>fossil sync http://192.168.1.36:8080/ --proxy off</b>
265
+ </blockquote>
248266
249267
</blockquote><h2>More Hints</h2><blockquote>
250268
251269
<p>Try these commands:</p>
252270
253271
--- www/quickstart.html
+++ www/quickstart.html
@@ -223,11 +223,21 @@
223
224 </blockquote><a name="proxy"></a><h2>HTTP Proxies</h2><blockquote>
225
226 <p>If you are behind a restrictive firewall that requires you to use
227 an HTTP proxy to reach the internet, then you can configure the proxy
228 in one of two ways. You can tell fossil about your proxy like this:<p>
 
 
 
 
 
 
 
 
 
 
229
230 <blockquote>
231 <b>fossil setting proxy </b><i>Proxy-URL</i>
232 </blockquote>
233
@@ -242,11 +252,19 @@
242 <blockquote>
243 <b>fossil setting proxy off</b>
244 </blockquote>
245
246 <p>Or unset the environment variable. The fossil setting for the
247 HTTP proxy takes precedence over the environment variable.</p>
 
 
 
 
 
 
 
 
248
249 </blockquote><h2>More Hints</h2><blockquote>
250
251 <p>Try these commands:</p>
252
253
--- www/quickstart.html
+++ www/quickstart.html
@@ -223,11 +223,21 @@
223
224 </blockquote><a name="proxy"></a><h2>HTTP Proxies</h2><blockquote>
225
226 <p>If you are behind a restrictive firewall that requires you to use
227 an HTTP proxy to reach the internet, then you can configure the proxy
228 in three different ways. You can tell fossil about your proxy using
229 a command-line option on commands that use the network,
230 <b>sync</b>, <b>clone</b>, <b>push</b>, and <b>pull</b>.</p>
231
232 <blockquote>
233 <b>fossil clone </b><i>URL</i> <b>--proxy</b> <i>Proxy-URL</i>
234 </blockquote>
235
236 <p>It is annoying to have to type in the proxy URL every time you
237 sync your project, though, so you can make the proxy configuration
238 persistent using the <b>setting</b> command:</p>
239
240 <blockquote>
241 <b>fossil setting proxy </b><i>Proxy-URL</i>
242 </blockquote>
243
@@ -242,11 +252,19 @@
252 <blockquote>
253 <b>fossil setting proxy off</b>
254 </blockquote>
255
256 <p>Or unset the environment variable. The fossil setting for the
257 HTTP proxy takes precedence over the environment variable and the
258 command-line option overrides both. If you have an persistent
259 proxy setting that you want to override for a one-time sync, that
260 is easily done on the command-line. For example, to sync with
261 a co-workers repository on your LAN, you might type:</p>
262
263 <blockquote>
264 <b>fossil sync http://192.168.1.36:8080/ --proxy off</b>
265 </blockquote>
266
267 </blockquote><h2>More Hints</h2><blockquote>
268
269 <p>Try these commands:</p>
270
271

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button