add a check for allowIncommingParents

add some extra information about parents
This commit is contained in:
cheatengine@gmail.com 2014-10-16 11:36:19 +00:00
parent c3643c7f08
commit 5ebd3995a0
5 changed files with 136 additions and 58 deletions

View File

@ -155,7 +155,6 @@ begin
else
if pictureformat=3 then
begin
fpi:=TFPMemoryImage.Create(0,0);
fpr:=TFPReaderPNG.create;
fpi.LoadFromStream(f, fpr);

View File

@ -87,6 +87,7 @@ type
childnodes: array of TPointerscanControllerChild;
parentUpdater: TAsyncTimer;
lastUpdateSent: integer;
lastPathCheck: qword; //last time the path check checked the queues
@ -380,6 +381,7 @@ type
function getTotalThreadCount: integer;
procedure getConnectingList(var l: TConnectEntryArray);
procedure getConnectionList(var l: TConnectionEntryArray);
procedure getParentData(var d: TPublicParentData);
procedure TerminateAndSaveState;
procedure execute; override;
@ -1178,6 +1180,16 @@ begin
setlength(l,0);
end;
procedure TPointerscanController.getParentData(var d: TPublicParentData);
begin
d.connected:=parent.socket<>nil;
d.ip:=parent.ip;
d.port:=parent.port;
d.lastupdatesent:=lastUpdateSent;
d.waitingforreconnect:=orphanedSince<>0;
end;
procedure TPointerscanController.appendDynamicPathQueueToOverflowQueue(paths: TDynPathQueue);
var oldstart: integer;
i: integer;
@ -2962,12 +2974,18 @@ begin
if connectiontype=0 then //parent
begin
if not allowIncomingParent then
raise exception.create('A parent tried to connect');
if parentpassword<>password then
raise TSocketException.create('Invalid parent password');
end
else
if connectiontype=1 then //child
begin
if not allowIncomingChildren then
raise exception.create('A child tried to connect');
if childpassword<>password then
raise TSocketException.create('Invalid child password');
end
@ -4022,6 +4040,8 @@ begin
parent.socket.WriteBuffer(updatemsg, sizeof(updatemsg));
parent.socket.flushWrites;
lastUpdateSent:=GetTickCount64;
HandleUpdateStatusReply;
end
else
@ -4692,6 +4712,7 @@ begin
else
begin
//this wants to be a parent
parentcs.Enter;
try
//add it to the queue
@ -4715,6 +4736,16 @@ begin
else
parentqueue[length(parentqueue)-1].iConnectedTo:=false;
len:=sizeof(ipname);
if getpeername(sockethandle, ipname, len)<>SOCKET_ERROR then
begin
parentqueue[length(parentqueue)-1].ip:=inttostr(byte(ipname.sin_addr.S_un_b.s_b1))+'.'+inttostr(byte(ipname.sin_addr.S_un_b.s_b2))+
inttostr(byte(ipname.sin_addr.S_un_b.s_b3))+'.'+inttostr(byte(ipname.sin_addr.S_un_b.s_b4));
parentqueue[length(parentqueue)-1].port:=ipname.sin_port;
end;
//you have a new daddy! Say hello to him

View File

@ -295,6 +295,12 @@ type
network: record
node: TTreenode; // + network
parent: TTreenode; //ip+port or disconnected
parentnodes: record
lastUpdateSent: TTreenode;
end;
connectingto: TTreenode;
connectingToNodes: array of record
data: TTreenode; //ip, port, trusted
@ -1227,7 +1233,7 @@ begin
staticscanner.Start;
pnlData.Visible:=true;
timer2.enabled:=true;
end;
@ -1594,6 +1600,7 @@ var i,j: integer;
connectinglist: TConnectEntryArray;
connectionlist: TConnectionEntryArray;
parentdata: TPublicParentData;
info: tstringlist;
@ -1744,28 +1751,26 @@ begin
infonodes.network.connectingToNodes[i].data.Free;
setlength(infonodes.network.connectingToNodes, length(connectinglist));
//connecting to:
if infonodes.network.connectingto=nil then
infonodes.network.connectingto:=tvInfo.Items.AddChild(infonodes.network.node,'Connecting to:');
if length(connectinglist)>0 then
for i:=0 to length(connectinglist)-1 do
begin
if infonodes.network.connectingto=nil then
infonodes.network.connectingto:=tvInfo.Items.AddChild(infonodes.network.node,'Connecting to:');
if infonodes.network.connectingToNodes[i].data=nil then //create a new one
infonodes.network.connectingToNodes[i].data:=tvinfo.Items.add(infonodes.network.connectingto,'');
s:=connectinglist[i].ip+':'+inttostr(connectinglist[i].port);
if connectinglist[i].becomeparent=false then
s:=s+BoolToStr(connectinglist[i].trusted, ' (Trusted)','');
for i:=0 to length(connectinglist)-1 do
begin
if infonodes.network.connectingToNodes[i].data=nil then //create a new one
infonodes.network.connectingToNodes[i].data:=tvinfo.Items.add(infonodes.network.connectingto,'');
s:=connectinglist[i].ip+':'+inttostr(connectinglist[i].port);
if connectinglist[i].becomeparent=false then
s:=s+BoolToStr(connectinglist[i].trusted, ' (Trusted)','');
infonodes.network.connectingToNodes[i].data.Text:=s;
end;
infonodes.network.connectingToNodes[i].data.Text:=s;
end;
staticscanner.getConnectionList(connectionlist);
for i:=length(infonodes.network.connectedToNodes)-1 downto length(connectionlist) do
@ -1774,63 +1779,96 @@ begin
setlength(infonodes.network.connectedToNodes, length(connectionlist));
if length(connectionlist)>0 then
//connected to:
if Staticscanner.initializer=false then
begin
if infonodes.network.connectedTo=nil then
infonodes.network.connectedTo:=tvInfo.Items.AddChild(infonodes.network.node,'Connected to:');
staticscanner.getParentData(parentdata);
for i:=0 to length(connectionlist)-1 do
if infonodes.network.parent=nil then
infonodes.network.parent:=tvInfo.Items.AddChild(infonodes.network.node,'Parent: ');
if parentdata.connected then
begin
if infonodes.network.connectedToNodes[i].node=nil then //create it
begin
infonodes.network.connectedToNodes[i].node:=tvInfo.Items.AddChild(infonodes.network.connectedTo, s);
tn:=infonodes.network.connectedToNodes[i].node;
infonodes.network.parent.Text:='Parent: '+parentdata.ip+':'+inttostr(parentdata.port);
with infonodes.network.connectedToNodes[i].data do
begin
trusted:=tvInfo.Items.AddChild(tn, '');
totalthreadcount:=tvInfo.Items.AddChild(tn, '');
resultsfound:=tvInfo.Items.AddChild(tn, '');
pathqueuesize:=tvInfo.Items.AddChild(tn, '');
totalpathquesize:=tvInfo.Items.AddChild(tn, '');
totalpathsEvaluated:=tvInfo.Items.AddChild(tn, '');
// pathspersecond:=tvInfo.Items.AddChild(tn, '');
end;
end;
if infonodes.network.parentnodes.lastUpdateSent=nil then
infonodes.network.parentnodes.lastUpdateSent:=tvInfo.Items.AddChild(infonodes.network.parent,'');
s:=connectionlist[i].ip+':'+inttostr(connectionlist[i].port);
if connectionlist[i].disconnected then
s:=s+' (Disconnected)'
infonodes.network.parentnodes.lastUpdateSent.Text:=inttostr(GetTickCount64-parentdata.lastupdatesent div 1000)+' seconds ago';
end
else
begin
//mark that it has no parent (yet/anymore)
if parentdata.waitingforreconnect then
infonodes.network.parent.Text:='Parent: <disconnected> (Waiting for reconnect)'
else
begin
if connectionlist[i].isidle=false then
s:=s+' (Active)'
else
s:=s+' (Idle)';
infonodes.network.parent.Text:='Parent: <none>';
if connectionlist[i].uploadingscandata then
s:=s+format(' (Uploading scandata: %d (%dK/sec)', [connectionlist[i].uploadscandataprogress, connectionlist[i].uploadscandataspeed]);
//if there are nodes, delete them
if infonodes.network.parentnodes.lastUpdateSent<>nil then
freeandnil(infonodes.network.parentnodes.lastUpdateSent);
end;
end;
if connectionlist[i].downloadingResuls then
s:=s+' (Downloading and handling results)';
end;
if infonodes.network.connectedTo=nil then
infonodes.network.connectedTo:=tvInfo.Items.AddChild(infonodes.network.node,'Children:');
infonodes.network.connectedToNodes[i].node.Text:=s;
for i:=0 to length(connectionlist)-1 do
begin
if infonodes.network.connectedToNodes[i].node=nil then //create it
begin
infonodes.network.connectedToNodes[i].node:=tvInfo.Items.AddChild(infonodes.network.connectedTo, s);
tn:=infonodes.network.connectedToNodes[i].node;
with infonodes.network.connectedToNodes[i].data do
begin
trusted.text:='Trusted: '+BoolToStr(connectionlist[i].trustedconnection, 'True', 'False');
totalthreadcount.text:='Total threadcount: '+IntToStr(connectionlist[i].threadcount);
resultsfound.text:='Results found: '+IntToStr(connectionlist[i].resultsfound);
pathqueuesize.text:='Queuesize: '+inttostr(connectionlist[i].pathquesize);
totalpathquesize.text:='Total Queuesize: '+inttostr(connectionlist[i].totalpathqueuesize);
totalpathsEvaluated.text:='Paths evaluated: '+inttostr(connectionlist[i].pathsevaluated);
//pathspersecond.text:='Paths/second: '+inttostr(connectionlist[i].pathspersecond);
trusted:=tvInfo.Items.AddChild(tn, '');
totalthreadcount:=tvInfo.Items.AddChild(tn, '');
resultsfound:=tvInfo.Items.AddChild(tn, '');
pathqueuesize:=tvInfo.Items.AddChild(tn, '');
totalpathquesize:=tvInfo.Items.AddChild(tn, '');
totalpathsEvaluated:=tvInfo.Items.AddChild(tn, '');
// pathspersecond:=tvInfo.Items.AddChild(tn, '');
end;
end;
s:=connectionlist[i].ip+':'+inttostr(connectionlist[i].port);
if connectionlist[i].disconnected then
s:=s+' (Disconnected)'
else
begin
if connectionlist[i].isidle=false then
s:=s+' (Active)'
else
s:=s+' (Idle)';
if connectionlist[i].uploadingscandata then
s:=s+format(' (Uploading scandata: %d (%dK/sec)', [connectionlist[i].uploadscandataprogress, connectionlist[i].uploadscandataspeed]);
if connectionlist[i].downloadingResuls then
s:=s+' (Downloading and handling results)';
end;
infonodes.network.connectedToNodes[i].node.Text:=s;
with infonodes.network.connectedToNodes[i].data do
begin
trusted.text:='Trusted: '+BoolToStr(connectionlist[i].trustedconnection, 'True', 'False');
totalthreadcount.text:='Total threadcount: '+IntToStr(connectionlist[i].threadcount);
resultsfound.text:='Results found: '+IntToStr(connectionlist[i].resultsfound);
pathqueuesize.text:='Queuesize: '+inttostr(connectionlist[i].pathquesize);
totalpathquesize.text:='Total Queuesize: '+inttostr(connectionlist[i].totalpathqueuesize);
totalpathsEvaluated.text:='Paths evaluated: '+inttostr(connectionlist[i].pathsevaluated);
//pathspersecond.text:='Paths/second: '+inttostr(connectionlist[i].pathspersecond);
end;
end;
end;
end;
except

View File

@ -12,6 +12,14 @@ uses
Classes, SysUtils;
type
TPublicParentData=record
connected: boolean;
ip: string;
port: word;
lastupdatesent: qword;
waitingforreconnect: boolean;
end;
TPublicConnectionEntry=record //information publicly available about children
parentconnectedto: boolean; //true if the parent connected to the child
ip: string;

View File

@ -37,6 +37,8 @@ type
port: word;
password: string;
end;
ip: string;
port: word;
trustsme: boolean;
end;