Skip to content
This repository was archived by the owner on Apr 16, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion c/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ int main(int argc, char **argv) {
srand(getpid());
{ /* Option parsing */
int opt;
while ((opt = getopt(argc, argv, "A:k:o:i:Vsqvu:C:KT:I:R:S:")) != -1) {
while ((opt = getopt(argc, argv, "A:k:o:i:Vsqvu:C:KT:I:R:S:H:")) != -1) {
switch (opt) {
case 'A': /* Authentication options for remote server */
{ /* Scan string as hostname=username:password */
Expand Down Expand Up @@ -519,6 +519,10 @@ int main(int argc, char **argv) {
/* Interface */
want_interface = strdup(optarg);
break;
case 'H':
/* Resolve Host */
resolve_host = strdup(optarg);
break;
}
}
}
Expand Down Expand Up @@ -731,6 +735,7 @@ int main(int argc, char **argv) {
printf("used %lld local, fetched %lld\n", local_used, http_down);
free(cacert);
free(want_interface);
free(resolve_host);
free(referer);
free(temp_file);
curl_global_cleanup();
Expand Down
4 changes: 4 additions & 0 deletions c/doc/zsync.1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Use the specified client-side certificate file when making https connections.
\fB\-S\fR \fIsslkey\fP
Use the specified client-side private key file when making https connections.
.TP
\fB\-H\fR \fIhost:port:ip\fP
Use the curl --resolve option to map a hostname to a different IP instead of doing a dns lookup.
Example curl usage: curl --resolve foo.example.com:443:127.0.0.1 https://foo.example.com:443/
.TP
\fB\-I\fR \fIinterface\fP
Attempt to use this interface name, IP address or hostname as the source of http connections.
.TP
Expand Down
18 changes: 18 additions & 0 deletions c/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ char *want_interface = NULL;
char *sslcert = NULL;
char *sslkey = NULL;

/* Should we tell curl to resolve a host to a particular ip? */
char *resolve_host = NULL;

/* Should we tell curl to ignore SSL peer verification? */
int be_insecure = 0;

Expand Down Expand Up @@ -163,6 +166,21 @@ CURL *make_curl_handle() {
fprintf(stderr, "--interface: %s\n", curl_easy_strerror(res));
}
}

/* Requires CURL ver 7.21.3 or newer. */
/* Equiv of --resolve in curl */
if(resolve_host) {
/* -H */
struct curl_slist *host = NULL;
host = curl_slist_append(NULL, resolve_host);
res = curl_easy_setopt( curl, CURLOPT_RESOLVE, host );
if( res != CURLE_OK ) {
/* Warn and continue. Let's try anyway even if this setopt fails */
fprintf(stderr, "--resolve: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
return NULL;
}
}

if(be_insecure) {
/* -K */
Expand Down
1 change: 1 addition & 0 deletions c/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern char *referer;

extern char *cacert;
extern char *want_interface;
extern char *resolve_host;
extern char *sslcert;
extern char *sslkey;
extern int be_insecure;
Expand Down