accurately test the rpc acl's ip address

This commit is contained in:
Mitchell Livingston
2008-06-04 17:25:51 +00:00
parent cf28aa878a
commit fa08470cfa
2 changed files with 13 additions and 16 deletions

View File

@@ -2282,7 +2282,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[[GroupsController groups] nameForIndex: groupIndex]];
}
//tiger doesn't have built-in image scaling in buttons
if (![NSApp isOnLeopardOrBetter])
{
icon = [[icon copy] autorelease];

View File

@@ -758,29 +758,26 @@
}
NSString * newIP = [newComponents componentsJoinedByString: @"."];
//revert if ip is not valid
#warning fix
if ([newComponents count] != 4)
if (!tr_sessionTestRPCACL(fHandle, [[@"+" stringByAppendingString: newIP] UTF8String], NULL))
{
NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP",
[oldDict objectForKey: @"Allow"], @"Allow", nil];
[fRPCAccessArray replaceObjectAtIndex: row withObject: newDict];
NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES selector: @selector(compareIP:)]
autorelease];
[fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
}
else
{
NSBeep();
if ([[oldDict objectForKey: @"IP"] isEqualToString: @""])
{
[fRPCAccessArray removeObjectAtIndex: row];
[fRPCAccessTable deselectAll: self];
[fRPCAccessTable reloadData];
}
return;
}
NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP",
[oldDict objectForKey: @"Allow"], @"Allow", nil];
[fRPCAccessArray replaceObjectAtIndex: row withObject: newDict];
NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES selector: @selector(compareIP:)]
autorelease];
[fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
[fRPCAccessTable deselectAll: self];
[fRPCAccessTable reloadData];
}