Skip to content

Commit f8dbe6d

Browse files
authored
Merge pull request #6175 from BOINC/dpa_www
client: strip leading www. from master URLs
2 parents 53ad4a5 + 081a004 commit f8dbe6d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/url.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ void escape_url_readable(char *in, char* out) {
201201

202202

203203
// Canonicalize a master url.
204-
// - Convert the first part of a URL (before the "://") to http://,
205-
// or prepend it
204+
// - Prepend http:// if protocol missing
206205
// - Remove double slashes in the rest
206+
// - strip leading 'www.'
207207
// - Add a trailing slash if necessary
208-
// - Convert all alphabet characters to lower case
208+
// - Convert all alphabetic characters to lower case
209209
//
210210
void canonicalize_master_url(char* url, int len) {
211211
char buf[1024];
@@ -219,6 +219,12 @@ void canonicalize_master_url(char* url, int len) {
219219
} else {
220220
strlcpy(buf, url, sizeof(buf));
221221
}
222+
223+
// strip leading www.
224+
//
225+
if (strstr(buf, "www.") == buf) {
226+
strcpy(buf, buf+4);
227+
}
222228
while (1) {
223229
p = strstr(buf, "//");
224230
if (!p) break;

sched/handle_request.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ inline static const char* get_remote_addr() {
583583
static int modify_host_struct(HOST& host) {
584584
host.timezone = g_request->host.timezone;
585585
strlcpy(host.domain_name, g_request->host.domain_name, sizeof(host.domain_name));
586+
587+
// assemble a string with info about BOINC client, GPUs, VBox, and Docker
588+
// store it in host.serialnum
589+
//
586590
char buf[1024], buf2[1024];
587591
sprintf(buf, "[BOINC|%d.%d.%d",
588592
g_request->core_client_major_version,
@@ -594,8 +598,8 @@ static int modify_host_struct(HOST& host) {
594598
strcat(buf, g_request->client_brand);
595599
}
596600
strcat(buf, "]");
597-
g_request->coprocs.summary_string(buf2, sizeof(buf2));
598601
strlcpy(host.serialnum, buf, sizeof(host.serialnum));
602+
g_request->coprocs.summary_string(buf2, sizeof(buf2));
599603
strlcat(host.serialnum, buf2, sizeof(host.serialnum));
600604
if (strlen(g_request->host.virtualbox_version)) {
601605
sprintf(buf2, "[vbox|%s|%d|%d]",
@@ -605,6 +609,7 @@ static int modify_host_struct(HOST& host) {
605609
);
606610
strlcat(host.serialnum, buf2, sizeof(host.serialnum));
607611
}
612+
608613
if (strcmp(host.last_ip_addr, g_request->host.last_ip_addr)) {
609614
strlcpy(
610615
host.last_ip_addr, g_request->host.last_ip_addr,

0 commit comments

Comments
 (0)