From cc63aaf09086b739870d967f591f7f8604c6adeb Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 21 Jan 2005 07:54:15 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=5182 --- checkin_notes | 17 +++++++++++++++++ db/boinc_db.C | 5 +++-- db/boinc_db.h | 3 ++- db/schema.sql | 1 + html/ops/db_update.php | 4 ++++ sched/handle_request.C | 5 +++++ 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/checkin_notes b/checkin_notes index c2add45079..a9476c6814 100755 --- a/checkin_notes +++ b/checkin_notes @@ -23096,3 +23096,20 @@ Rom 20 Jan 2005 (boinc) - Tag for 4.60 release, all platforms boinc_core_release_4_60 +David 20 Jan 2005 + - Add external_ip_addr field to host table. + This is the REMOTE_ADDR reported by Apache + when the host contacts the scheduler. + May be different from the IP address reported by the host + (e.g. if the host is behind a NAT) + + NOTE: project must update their databases + (html/ops/db_update.php, update_1_20a_2005()) + to use this code. + + db/ + boinc_db.C,h + html/ops/ + db_update.php + sched/ + handle_request.C diff --git a/db/boinc_db.C b/db/boinc_db.C index 341b56dfa5..55deb832a3 100644 --- a/db/boinc_db.C +++ b/db/boinc_db.C @@ -359,7 +359,7 @@ void DB_HOST::db_print(char* buf){ "credit_per_cpu_sec=%.15e, " "venue='%s', nresults_today=%d, " "avg_turnaround=%f, " - "host_cpid='%s' ", + "host_cpid='%s', external_ip_addr='%s' ", create_time, userid, rpc_seqno, rpc_time, total_credit, expavg_credit, expavg_time, @@ -376,7 +376,7 @@ void DB_HOST::db_print(char* buf){ credit_per_cpu_sec, venue, nresults_today, avg_turnaround, - host_cpid + host_cpid, external_ip_addr ); UNESCAPE(domain_name); UNESCAPE(serialnum); @@ -430,6 +430,7 @@ void DB_HOST::db_parse(MYSQL_ROW &r) { nresults_today = atoi(r[i++]); avg_turnaround = atof(r[i++]); strcpy2(host_cpid, r[i++]); + strcpy2(external_ip_addr, r[i++]); } void DB_WORKUNIT::db_print(char* buf){ diff --git a/db/boinc_db.h b/db/boinc_db.h index 08f425040e..64f305f82e 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -214,7 +214,7 @@ struct HOST { int timezone; // hours difference from GMT char domain_name[256]; char serialnum[256]; - char last_ip_addr[256]; // IP address as of last RPC + char last_ip_addr[256]; // internal IP address as of last RPC int nsame_ip_addr; // # of RPCs with same IP address double on_frac; // Fraction of time (0-1) that BOINC is running @@ -262,6 +262,7 @@ struct HOST { int nresults_today; // results sent since midnight double avg_turnaround; // recent average result turnaround time char host_cpid[256]; // host cross-project ID + char external_ip_addr[256]; // IP address seen by scheduler int parse(FILE*); int parse_time_stats(FILE*); diff --git a/db/schema.sql b/db/schema.sql index 436bb03c44..b1d269d06a 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -168,6 +168,7 @@ create table host ( nresults_today integer not null, avg_turnaround double not null, host_cpid varchar(254), + external_ip_addr varchar(254), primary key (id) ) type=InnoDB; diff --git a/html/ops/db_update.php b/html/ops/db_update.php index 936919960a..8ebef7b02f 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -237,6 +237,10 @@ function update_1_20_2005() { mysql_query("alter table host add host_cpid varchar(254)"); } +function update_1_20a_2005() { + mysql_query("alter table host add external_ip_addr varchar(254)"); +} + //update_10_25_2004(); ?> diff --git a/sched/handle_request.C b/sched/handle_request.C index 95cadbab85..5ae11aafab 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -265,6 +265,11 @@ static int update_host_record(HOST& xhost, USER& user) { sprintf(buf, "%s%s", host.host_cpid, user.email_addr); md5_block((const unsigned char*)buf, strlen(buf), host.host_cpid); } + + char* p = getenv("REMOTE_ADDR"); + if (p) { + strlcpy(host.external_ip_addr, p, sizeof(host.external_ip_addr)); + } retval = host.update(); if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "host.update() failed: %d\n", retval);