[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2931: Silly bug.. forgot to test an edge case on binary search! Al (vidalia/branches/exit-country/src/vidalia/config)
Author: cviecco
Date: 2008-08-04 09:34:58 -0400 (Mon, 04 Aug 2008)
New Revision: 2931
Modified:
vidalia/branches/exit-country/src/vidalia/config/filegeoipresolver.cpp
vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp
vidalia/branches/exit-country/src/vidalia/config/networksettings.cpp
Log:
Silly bug.. forgot to test an edge case on binary search!
Also make on setting local
Modified: vidalia/branches/exit-country/src/vidalia/config/filegeoipresolver.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/filegeoipresolver.cpp 2008-08-04 02:54:18 UTC (rev 2930)
+++ vidalia/branches/exit-country/src/vidalia/config/filegeoipresolver.cpp 2008-08-04 13:34:58 UTC (rev 2931)
@@ -43,10 +43,8 @@
ready=false;
FileGeoIpResolverGeoLocation newlocation;
FileGeoIpResolverIpRange newrange;
-
start=time(NULL);
-
//start by attempting to read the user geoip file
FILE* file2;
file2=fopen(GEOIP_FILENAME.toAscii(),"r");
@@ -56,6 +54,7 @@
int block_count=0;
char *tok;
+
if(NULL!=file2){
//fprintf(stderr,"fopen, open!\n");
while (fgets(tmpline, 255, file2) != NULL) {
@@ -166,7 +165,6 @@
end=time(NULL);
ready=true;
-
}
@@ -208,7 +206,7 @@
//new code.. combo binary search + linear (linear on near found)
low=0;
high=ipRange.size();
- while(low+1<high){
+ while(low+2<high){
//now compare with middle!
mid=(low+high)/2;
if(ipRange[mid].low_net>ip.toIPv4Address()){
@@ -218,13 +216,14 @@
low=mid;
}
}
- for(i=low;i<high+1;i++){
+ for(i=low;i<high+1 && i<ipRange.size();i++){
if(ipRange[i].low_net<=ip.toIPv4Address() &&
ipRange[i].high_net>=ip.toIPv4Address() ){
found=i;
break;
}
}
+
if(-1==found){
//fprintf(stderr,"not found!\n");
return invalid;
Modified: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp 2008-08-04 02:54:18 UTC (rev 2930)
+++ vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp 2008-08-04 13:34:58 UTC (rev 2931)
@@ -167,8 +167,11 @@
QString uniqueRouterName;
quint32 torVersion = Vidalia::torControl()->getTorVersion();
+
//initialize the window.. just in case it has not been initialized yet.
load();
+
+
/*Fill up the internal structure*/
//by_country_exit_nodes.clear();
@@ -179,12 +182,12 @@
//Get the country!
ip_addr=router.ipAddress().toString();
//short_country_name=_torControl->getIPCountry(ip_addr);
-
+
//test with file!
short_country_name=_geoIpResolver->get_country(router.ipAddress()).toLower();
-
+
- /*Only continue if the router is running,valid,isexit and is NOT badexit*/
+ //Only continue if the router is running,valid,isexit and is NOT badexit
if (!router.isRunning())
continue;
if (!router.isValid())
@@ -194,7 +197,7 @@
if((router.Exit) !=((router.Exit | router.BadExit) & flags) )
continue;
- /*Get a unique name, if unnamed use the full descriptor id*/
+ //Get a unique name, if unnamed use the full descriptor id
uniqueRouterName=router.name();
//display names only for registered nodes, this to avoid warnings
@@ -216,8 +219,9 @@
by_country_exit_nodes2.insert(short_country_name,QList<RouterStatus>()<<router);
}
}
+ return;
+
-
//* now fill the combo boxes!*/
QListWidgetItem *countryListItem;
int itemcount=0;
@@ -290,6 +294,7 @@
copyExitCountryToText();
applyTorSettings();
}
+ fprintf(stderr,"networout on authenticated, done!\n");
}
Modified: vidalia/branches/exit-country/src/vidalia/config/networksettings.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/networksettings.cpp 2008-08-04 02:54:18 UTC (rev 2930)
+++ vidalia/branches/exit-country/src/vidalia/config/networksettings.cpp 2008-08-04 13:34:58 UTC (rev 2931)
@@ -351,7 +351,8 @@
bool
NetworkSettings::getUseExcludeNodePolicy(){
- return value(SETTING_USE_EXCLUDE_NODE_POLICY).toBool();
+ //return value(SETTING_USE_EXCLUDE_NODE_POLICY).toBool();
+ return localValue(SETTING_USE_EXCLUDE_NODE_POLICY).toBool();
}
/** Sets to <b>useNodePolicy</b> whether Tor should try