Thread: SF.net SVN: fclient: [81] trunk/sandbox/fcp/fcp2_0_consts.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <ju...@us...> - 2008-01-28 11:21:40
|
Revision: 81 http://fclient.svn.sourceforge.net/fclient/?rev=81&view=rev Author: jurner Date: 2008-01-28 03:21:45 -0800 (Mon, 28 Jan 2008) Log Message: ----------- a few more consts Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-28 11:20:59 UTC (rev 80) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-28 11:21:45 UTC (rev 81) @@ -149,6 +149,7 @@ Shutdown = 1 SocketDied = 2 ConnectingFailed = 3 + DuplicateConnectionName = 4 class FilenameCollision: @@ -172,7 +173,7 @@ MessageSend = 'sending message' MessageReceived = 'received message' - KeyboardInterrupt = 'keyboard interrupt' + KeyboardInterrupt = 'keyboard interrupt' # kick out SocketDied = 'socket died' @@ -219,12 +220,22 @@ Nothing = 'none' +class UploadFrom: + Direct = 'direct' + Disk = 'disk' + Redirect = 'redirect' + + class Verbosity: ReportCompletion = '0' ReportProgress = '1' + ReportProgressAndCompression = '513' # 1 | 512 # ClientPut only + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-01-29 11:27:05
|
Revision: 83 http://fclient.svn.sourceforge.net/fclient/?rev=83&view=rev Author: jurner Date: 2008-01-29 03:27:08 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Started implementing python <--> fcp value type mapping Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-28 11:22:27 UTC (rev 82) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-29 11:27:08 UTC (rev 83) @@ -1,6 +1,6 @@ -"""Freennet Client Protocol consts""" +"""Freennet Client Protocol consts and type mappings""" - +import base64 import logging #************************************************************************ # @@ -24,34 +24,34 @@ ) def __str__(self): return self.value - MaxArchiveRecursionExceeded = '1' - UnknownSplitfileMetadata = '2' - UnknownMetadata = '3' - InvalidMetadata = '4' - ArchiveFailure = '5' - BlockDecodeError = '6' - MaxMetadataLevelsExceeded = '7' - MaxArchiveRestartsExceeded = '8' - MaxRecursionLevelExceeded = '9' - NotAnArchve = '10' - TooManyMetastrings = '11' - BucketError = '12' - DataNotFound = '13' - RouteNotFound = '14' - RejectedOverload = '15' - TooManyRedirects = '16' - InternalError = '17' - TransferFailed = '18' - SplitfileError = '19' - InvalidUri = '20' + MaxArchiveRecursionExceeded = 1 + UnknownSplitfileMetadata = 2 + UnknownMetadata = 3 + InvalidMetadata = 4 + ArchiveFailure = 5 + BlockDecodeError = 6 + MaxMetadataLevelsExceeded = 7 + MaxArchiveRestartsExceeded = 8 + MaxRecursionLevelExceeded = 9 + NotAnArchve = 10 + TooManyMetastrings = 11 + BucketError = 12 + DataNotFound = 13 + RouteNotFound = 14 + RejectedOverload = 15 + TooManyRedirects = 16 + InternalError = 17 + TransferFailed = 18 + SplitfileError = 19 + InvalidUri = 20 TooBig = '21' - MetadataTooBig = '22' - TooManyBlocks = '23' - NotEnoughMetastrings = '24' - Canceled = '25' - ArchiveRestart = '26' - PermanentRedirect = '27' - NotAllDataFound = '28' + MetadataTooBig = 22 + TooManyBlocks = 23 + NotEnoughMetastrings = 24 + Canceled = 25 + ArchiveRestart = 26 + PermanentRedirect = 27 + NotAllDataFound = 28 class InsertError(Exception): @@ -68,14 +68,14 @@ ) def __str__(self): return self.value - InvalidUri = '1' - BucketError = '2' - InternalError = '3' - RejectedOverload = '4' - RouteNotFound = '5' - FatalErrorInBlocks = '6' - TooManyRetriesInBlock = '7' - RouteReallyNotFound = '8' + InvalidUri = 1 + BucketError = 2 + InternalError = 3 + RejectedOverload = 4 + RouteNotFound = 5 + FatalErrorInBlocks = 6 + TooManyRetriesInBlock = 7 + RouteReallyNotFound = 8 Collision = '9' Canceled = '10' @@ -94,37 +94,37 @@ ) def __str__(self): return self.value - ClientHelloMustBeFirst = '1' - NoLateClientHellos = '2' - MessageParseError = '3' - UriParseError = '4' - MissingField = '5' - ErrorParsingNumber = '6' - InvalidMessage = '7' - InvalidField = '8' - FileNotFound = '9' - DiskTargetExists = '10' # handled: - SameDirectoryExpected = '11' - CouldNotCreateFile = '12' - CouldNotWriteFile = '13' - CouldNotRenameFile = '14' - NoSuchIdentifier = '15' - NotSupported = '16' - InternalError = '17' - ShuttingDown = '18' # handled: - NoSuchNodeIdentifier = '19' # Unused since 995 - UrlParseError = '20' - ReferenceParseError = '21' - FileParseError = '22' - NotAFile = '23' - AccessDenied = '24' - DDADenied = '25' # handled: - CouldNotReadFile = '26' - ReferenceSignature = '27' - CanNotPeerWithSelf = '28' + ClientHelloMustBeFirst = 1 + NoLateClientHellos = 2 + MessageParseError = 3 + UriParseError = 4 + MissingField = 5 + ErrorParsingNumber = 6 + InvalidMessage = 7 + InvalidField = 8 + FileNotFound = 9 + DiskTargetExists = 10 # handled: + SameDirectoryExpected = 11 + CouldNotCreateFile = 12 + CouldNotWriteFile = 13 + CouldNotRenameFile = 14 + NoSuchIdentifier = 15 + NotSupported = 16 + InternalError = 17 + ShuttingDown = 18 # handled: + NoSuchNodeIdentifier = 19 # Unused since 995 + UrlParseError = 20 + ReferenceParseError = 21 + FileParseError = 22 + NotAFile = 23 + AccessDenied = 24 + DDADenied = 25 # handled: + CouldNotReadFile = 26 + ReferenceSignature = 27 + CanNotPeerWithSelf = 28 PeerExists = '29' - OpennetDisabled = '30' - DarknetPeerOnly = '31' + OpennetDisabled = 30 + DarknetPeerOnly = 31 # others @@ -227,15 +227,320 @@ class Verbosity: - ReportCompletion = '0' - ReportProgress = '1' - ReportProgressAndCompression = '513' # 1 | 512 # ClientPut only + ReportCompletion = 0x0 + ReportProgress = 0x1 + ReportCompression = 0x200 +#************************************************************************************* +# python <--> fcp value mappings +#************************************************************************************* +#TODO: reqork Clss.validateFcpValue +FcpTrue = 'true' +FcpFalse = 'false' +class FcpTypeBool(object): + + @classmethod + def pythonToFcp(clss, value): + return FcpTrue if value else FcpFalse + + @classmethod + def fcpToPython(clss, value): + return value == FcpTrue + + @classmethod + def validateFcpValue(clss, value): + if value in ('true', 'false'): + return str(value) + return None +class FcpTypeInt(object): + + @classmethod + def pythonToFcp(clss, value): + return str(value) + + @classmethod + def fcpToPython(clss, value): + return int(value) + + @classmethod + def validateFcpValue(clss, value): + try: + return int(value) + except ValueError: + return None + +# GetFailed sets the ExpectedDataLenght field to '' (empty string). Fix this to show up as -1 +class FcpTypeInt_GetFailed_ExpectedDataLenght(object): + + @classmethod + def pythonToFcp(clss, value): + return str(value) + + @classmethod + def fcpToPython(clss, value): + if value == '': + return -1 + return int(value) + + @classmethod + def validateFcpValue(clss, value): + if value == '': + return -1 + try: + return int(value) + except ValueError: + return None + + +class FcpTypeIntWithBounds(object): + + def __init__(self, lowerBound, upperBound): + self.lowerBound = lowerBound + self.upperBound = upperBound + + def pythonToFcp(self, value): + return str(value) + + def fcpToPython(self, value): + return int(value) + + def validateFcpValue(self, value): + try: + n = int(value) + except ValueError: + return None + + if self.lowerBound is not None: + if n >= self.lowerBound: + return n + if self.upperBound is not None: + if n <= self.upperBound: + return n + + return None + + + +class FcpTypeBase64EncodedString(object): + + @classmethod + def pythonToFcp(clss, value): + return base64.encode(value) + + @classmethod + def fcpToPython(clss, value): + return base64.decode(value) + + @classmethod + def validateFcpValue(clss, value): + pass + #TODO: no idea + + # we add a few private params... + ParamPrefixPrivate = 'Fc' + + + +class FcpTypeTime(object): + + @classmethod + def pythonToFcp(clss, value): + return str(value * 1000) + + @classmethod + def fcpToPython(clss, value): + return int(value) / 1000 + + @classmethod + def validateFcpValue(clss, value): + try: + return self.fcpToPython(value) + except ValueEror: + return none + +#*************************************************************************************** +# +# Mapping from message params to param types +# +# ...being lazy here, only types that are not strings are declared +# +#*************************************************************************************** +MessageParamTypes = { + + # client messages + + 'ListPeers': { + 'WithMetadata': FcpTypeBool, + 'WithVolantile': FcpTypeBool, + }, + + #'AddPeer': {}, # ??? check + + 'ModifyPeer': { + 'AllowLocalAddresses': FcpTypeBool, + 'IsDisabled': FcpTypeBool, + 'ListenOnly': FcpTypeBool, + }, + + 'ModifyPeerNote': { + 'NoteText': FcpTypeBase64EncodedString, + }, + + 'GetNode': { + 'GiveOpennetRef': FcpTypeBool, + 'WithPrivate': FcpTypeBool, + 'WithVolatile': FcpTypeBool, + }, + 'GetConfig': { + 'WithCurrent': FcpTypeBool, + 'WithDefaults': FcpTypeBool, + 'WithSortOrder': FcpTypeBool, + 'WithExpertFlag': FcpTypeBool, + 'WithForceWriteFlag': FcpTypeBool, + 'WithShortDescription': FcpTypeBool, + 'WithLongDescription': FcpTypeBool, + }, + + #'ModifyConfig': # ??? check + + 'TestDDARequest': { + 'WantReadDirectory': FcpTypeBool, + 'WantWriteDirectory': FcpTypeBool, + }, + 'ClientPut': { + 'BinaryBlob': FcpTypeBool, + 'DontCompress': FcpTypeBool, + 'EarlyEncode': FcpTypeBool, + 'GetCHKOnly': FcpTypeBool, + 'Global': FcpTypeBool, + 'MaxRetries': FcpTypeInt, + 'Verbosity': FcpTypeInt, + }, + 'ClientGet': { + 'BinaryBlob': FcpTypeBool, + 'Global': FcpTypeBool, + 'IgnoreDS': FcpTypeBool, + 'DSOnly': FcpTypeBool, + 'MaxSize': FcpTypeInt, + 'MaxTempSize': FcpTypeInt, + 'Verbosity': FcpTypeInt, + }, + 'SubscribeUSK': { + 'DontPoll': FcpTypeBool, + }, + 'WatchGlobal': { + 'Enabled': FcpTypeBool, + 'VerbosityMask': FcpTypeInt, + }, + 'GetRequestStatus': { + 'Global': FcpTypeBool, + 'OnlyData': FcpTypeBool, + }, + 'RemopvePersistentRequest': { + 'Global': FcpTypeBool, + }, + 'ModifyPersistentRequest': { + 'Global': FcpTypeBool, + }, + + + # node messages + + 'NodeHello': { + 'CompressionCodecs': FcpTypeInt, + 'Testnet': FcpTypeBool, + + #TODO: ExtBuild et al. ??? + + }, + + #'Peer': {}, # ??? check + + 'PeerNote': { + 'NoteText': FcpTypeBase64EncodedString, + }, + + + #'NodeData': {}, # ??? check + #'ConfigData': {}, # ??? check + + 'TestDDAComplete': { + 'ReadDirectoryAllowed': FcpTypeBool, + 'WriteDirectoryAllowed': FcpTypeBool, + }, + 'PutFetchable': { + 'Global': FcpTypeBool, + }, + 'DataFound': { + 'Global': FcpTypeBool, + 'DataLength': FcpTypeInt, + }, + 'AllData': { + 'Global': FcpTypeBool, + #NOTE: we ignore startup and completion time here, as long as it is not passed in all messages + + }, + 'FinishedCompression': { + 'OriginalSize': FcpTypeInt, + 'CompressedSize': FcpTypeInt, + }, + 'SimpleProgress': { + 'Total': FcpTypeInt, + 'Required': FcpTypeInt, + 'Failed': FcpTypeInt, + 'FatalyFailed': FcpTypeInt, + 'Succeeded': FcpTypeInt, + 'Finalized': FcpTypeBool, + }, + 'PersistentRequestRemoved': { + 'Global': FcpTypeBool, + }, + 'PersistentRequestModified': { + 'Global': FcpTypeBool, + }, + 'PutFailed': { + 'Global': FcpTypeBool, + 'Code': FcpTypeInt, + }, + 'GetFailed': { + 'Code': FcpTypeInt, + 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght, + 'Fatal': FcpTypeBool, + 'FinalizedExpected': FcpTypeBool, + 'Global': FcpTypeBool, + }, + 'ProtocolError': { + 'Code': FcpTypeInt, + 'Global': FcpTypeBool, + }, + + 'IdentifierCollision': { + 'Global': FcpTypeBool, + }, + 'SubscribedUSKUpdate': { + 'Edition': FcpTypeInt, + }, + + + + } + +MessageParamTypes['ClientPutDiskDir'] = MessageParamTypes['ClientPut'] +MessageParamTypes['ClientComplexDir'] = MessageParamTypes['ClientPut'] + +# TODO: "Started" param? Think we simply ignore it +MessageParamTypes['PersistentGet'] = MessageParamTypes['ClientGet'] +MessageParamTypes['PersistentPut'] = MessageParamTypes['ClientPut'] + + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-02 11:25:21
|
Revision: 110 http://fclient.svn.sourceforge.net/fclient/?rev=110&view=rev Author: jurner Date: 2008-02-02 03:25:23 -0800 (Sat, 02 Feb 2008) Log Message: ----------- refactor Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-02 11:24:50 UTC (rev 109) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-02 11:25:23 UTC (rev 110) @@ -208,76 +208,89 @@ class Message: """Fcp messages""" - # client s + # client --> node + AddPeer = 'AddPeer' ClientHello = 'ClientHello' + ClientGet = 'ClientGet' + ClientPut = 'ClientPut' + ClientPutDiskDir = 'ClientPutDiskDir' + ClientPutComplexDir = 'ClientPutComplexDir' + FCPPlugin = 'FCPPlugin' + GenerateSSK = 'GenerateSSK' + GetConfig = 'GetConfig' # (since 1027) + GetNode = 'GetNode' + GetPluginInfo = 'GetPluginInfo' + GetRequestStatus = 'GetRequestStatus' ListPeer = 'ListPeer' # (since 1045) ListPeers = 'ListPeers' ListPeerNotes = 'ListPeerNotes' - AddPeer = 'AddPeer' + ListPersistentRequests = 'ListPersistentRequests' + ModifyConfig = 'ModifyConfig' # (since 1027) ModifyPeer = 'ModifyPeer' ModifyPeerNote = 'ModifyPeerNote' + ModifyPersistentRequest = 'ModifyPersistentRequest' RemovePeer = 'RemovePeer' - GetNode = 'GetNode' - GetConfig = 'GetConfig' # (since 1027) - ModifyConfig = 'ModifyConfig' # (since 1027) + RemovePersistentRequest = 'RemovePersistentRequest' + Shutdown = 'Shutdown' + SubscribeUSK = 'SubscribeUSK' TestDDARequest = 'TestDDARequest' # (since 1027) TestDDAResponse = 'TestDDAResponse' # (since 1027) - GenerateSSK = 'GenerateSSK' - ClientPut = 'ClientPut' - ClientPutDiskDir = 'ClientPutDiskDir' - ClientPutComplexDir = 'ClientPutComplexDir' - ClientGet = 'ClientGet' - GetPluginInfo = 'GetPluginInfo' - FCPPlugin = 'FCPPlugin' - SubscribeUSK = 'SubscribeUSK' WatchGlobal = 'WatchGlobal' - GetRequestStatus = 'GetRequestStatus' - ListPersistentRequests = 'ListPersistentRequests' - RemovePersistentRequest = 'RemovePersistentRequest' - ModifyPersistentRequest = 'ModifyPersistentRequest' - Shutdown = 'Shutdown' - - # node s + + # node --> client + AllData = 'AllData' + CloseConnectionDuplicateClientName = 'CloseConnectionDuplicateClientName' + ConfigData = 'ConfigData' # (since 1027) + DataFound = 'DataFound' + EndListPeers = 'EndListPeers' + EndListPeerNotes = 'EndListPeerNotes' + EndListPersistentRequests = 'EndListPersistentRequests' + FCPPluginReply = 'FCPPluginReply' + FinishedCompression = 'FinishedCompression' + GetFailed = 'GetFailed' + IdentifierCollision = 'IdentifierCollision' + NodeData = 'NodeData' NodeHello = 'NodeHello' - CloseConnectionDuplicateClientName = 'CloseConnectionDuplicateClientName' Peer = 'Peer' PeerNote = 'PeerNote' - EndListPeers = 'EndListPeers' - EndListPeerNotes = 'EndListPeerNotes' PeerRemoved = 'PeerRemoved' - NodeData = 'NodeData' - ConfigData = 'ConfigData' # (since 1027) - TestDDAReply = 'TestDDAReply' # (since 1027) - TestDDAComplete = 'TestDDAComplete' # (since 1027) - SSKKeypair = 'SSKKeypair' PersistentGet = 'PersistentGet' PersistentPut = 'PersistentPut' PersistentPutDir = 'PersistentPutDir' - URIGenerated = 'URIGenerated' + PersistentRequestModified = 'PersistentRequestModified' # (since 1016) + PersistentRequestRemoved = 'PersistentRequestRemoved' # (since 1016) + PluginInfo = 'PluginInfo' + ProtocolError = 'ProtocolError' + PutFailed = 'PutFailed' + PutFetchable = 'PutFetchable' PutSuccessful = 'PutSuccessful' - PutFetchable = 'PutFetchable' - DataFound = 'DataFound' - AllData = 'AllData' + SimpleProgress = 'SimpleProgress' + SSKKeypair = 'SSKKeypair' StartedCompression = 'StartedCompression' - FinishedCompression = 'FinishedCompression' - SimpleProgress = 'SimpleProgress' - EndListPersistentRequests = 'EndListPersistentRequests' - PersistentRequestRemoved = 'PersistentRequestRemoved' # (since 1016) - PersistentRequestModified = 'PersistentRequestModified' # (since 1016) - PutFailed = 'PutFailed' - GetFailed = 'GetFailed' - ProtocolError = 'ProtocolError' - IdentifierCollision = 'IdentifierCollision' + SubscribedUSKUpdate = 'SubscribedUSKUpdate' + TestDDAComplete = 'TestDDAComplete' # (since 1027) + TestDDAReply = 'TestDDAReply' # (since 1027) UnknownNodeIdentifier = 'UnknownNodeIdentifier' UnknownPeerNoteType = 'UnknownPeerNoteType' - SubscribedUSKUpdate = 'SubscribedUSKUpdate' - PluginInfo = 'PluginInfo' - FCPPluginReply = 'FCPPluginReply' - + URIGenerated = 'URIGenerated' + + # client s (internal use only) ClientSocketTimeout = 1 ClientSocketDied = 2 ClientDisconnected = 3 + + ClientRequestMessages = ( + ClientGet, + ClientPut, + ClientPutDiskDir, + ClientPutComplexDir, + ) + ClientPluginMessages = ( + GetPluginInfo, + FCPPlugin, + ) + class MessageStatus: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-03 13:13:21
|
Revision: 124 http://fclient.svn.sourceforge.net/fclient/?rev=124&view=rev Author: jurner Date: 2008-02-03 05:13:25 -0800 (Sun, 03 Feb 2008) Log Message: ----------- fix Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-02 18:30:56 UTC (rev 123) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-03 13:13:25 UTC (rev 124) @@ -45,7 +45,7 @@ TransferFailed = 18 SplitfileError = 19 InvalidUri = 20 - TooBig = '21' + TooBig = 21 MetadataTooBig = 22 TooManyBlocks = 23 NotEnoughMetastrings = 24 @@ -148,15 +148,17 @@ class DisconnectReason: """Reasons for client disconnect + @cvar ConnectingFailed: connection could not be established + @cvar DuplicateClientName: another client opend a connection with the same connection name @cvar Shutdown: regular shutdown of the connection @cvar SocketDied: connection to the node died unexpectingly - @cvar ConnectFailed: connection could not be established + @cvar VersionMissmatch: node or Fcp version did not match """ - Shutdown = 1 - SocketDied = 2 - ConnectingFailed = 3 - DuplicateConnectionName = 4 - VersionMismatch = 5 #TODO: implement??? + ConnectingFailed = 1 + DuplicateClientName = 2 + Shutdown = 3 + SocketDied = 4 + VersionMissmatch = 5 #TODO: implement??? class FilenameCollision: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-05 12:10:03
|
Revision: 143 http://fclient.svn.sourceforge.net/fclient/?rev=143&view=rev Author: jurner Date: 2008-02-05 04:10:05 -0800 (Tue, 05 Feb 2008) Log Message: ----------- beautifications Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 12:09:32 UTC (rev 142) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 12:10:05 UTC (rev 143) @@ -204,7 +204,7 @@ KeyboardInterrupt = 'keyboard interrupt' # kick out SocketDied = 'socket died' - + AllRequestsCompleted = 'All requests completed' class Message: @@ -295,7 +295,7 @@ -class MessageStatus: +class RequestStatus: Null = 0x0 Pending = 0x1 Compressing = 0x2 @@ -306,7 +306,7 @@ RestoreFailed = 0x40 -class MessageSubType: +class RequestSubType: """Consts indicating the subtype of a message""" # some additional consts This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-05 12:26:08
|
Revision: 146 http://fclient.svn.sourceforge.net/fclient/?rev=146&view=rev Author: jurner Date: 2008-02-05 04:26:13 -0800 (Tue, 05 Feb 2008) Log Message: ----------- ... Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 12:11:06 UTC (rev 145) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 12:26:13 UTC (rev 146) @@ -363,6 +363,7 @@ @cvar PersistentUserData: thepersistent user data has been modified @cvar PriorityClass: the priority class has been modified """ + Null = 0x0 Filename = 0x8 Identifier = 0x4 PersistentUserData = 0x1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-05 15:19:27
|
Revision: 149 http://fclient.svn.sourceforge.net/fclient/?rev=149&view=rev Author: jurner Date: 2008-02-05 07:19:28 -0800 (Tue, 05 Feb 2008) Log Message: ----------- docs Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 12:27:53 UTC (rev 148) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 15:19:28 UTC (rev 149) @@ -296,20 +296,31 @@ class RequestStatus: + """Request status flags + @cvar Null: no status + @cvar Pending: the request is not started yet + @cvar Compressing: the request is about to be compressed + @cvar Compressed: compressing is completed + @cvar Complete: the request is completed + @cvar Error: an error occured while processing ther request + @cvar Removed: the request is no longer present in the client (and on the nodes queue) + + @note: the FcStatus member of the params dict of a request should contain one or more + of the bitflags it picked up while running through the client. + """ Null = 0x0 Pending = 0x1 Compressing = 0x2 - Started = 0x4 - Complete = 0x8 - Error = 0x10 - Removed = 0x20 - RestoreFailed = 0x40 + Compressed = 0x4 + Started = 0x8 + Complete = 0x10 + Error = 0x20 + Removed = 0x40 + - class RequestSubType: """Consts indicating the subtype of a message""" - # some additional consts Null = 0 GetData = 1 GetFile = 2 @@ -362,6 +373,9 @@ @cvar Identifier: the identifier has been moodified @cvar PersistentUserData: thepersistent user data has been modified @cvar PriorityClass: the priority class has been modified + + @note: the FcModified member of the params dict of a request may contain + one or more of the bitflags """ Null = 0x0 Filename = 0x8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-05 15:59:43
|
Revision: 153 http://fclient.svn.sourceforge.net/fclient/?rev=153&view=rev Author: jurner Date: 2008-02-05 07:59:49 -0800 (Tue, 05 Feb 2008) Log Message: ----------- adapt to request status flag changes Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 15:58:32 UTC (rev 152) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 15:59:49 UTC (rev 153) @@ -166,7 +166,7 @@ @cvar HandleNever: don't handle filename collisions @cvar HandleRename: rename file on collisions @cvar MaskHandle: bitmask indicating if collisions are hadled or not - @cvar CollisonHandled: if this bit is set, a collision has been handled + @cvar CollisonHandled: if this bit is set, a collision has actually been handled """ HandleNever = 0x0 HandleRename = 0x1 @@ -187,8 +187,6 @@ TypesAll = (SSK, KSK, CHK, USK, SVK) - - class LogMessages: """Strings used for log infos""" @@ -275,14 +273,13 @@ UnknownNodeIdentifier = 'UnknownNodeIdentifier' UnknownPeerNoteType = 'UnknownPeerNoteType' URIGenerated = 'URIGenerated' - - + # client s (internal use only) ClientSocketTimeout = 1 ClientSocketDied = 2 ClientDisconnected = 3 - ClientRequestMessages = ( + ClientKeyRequestMessages = ( ClientGet, ClientPut, ClientPutDiskDir, @@ -294,30 +291,35 @@ ) - class RequestStatus: """Request status flags @cvar Null: no status @cvar Pending: the request is not started yet + @cvar Started: the request has started @cvar Compressing: the request is about to be compressed @cvar Compressed: compressing is completed - @cvar Complete: the request is completed - @cvar Error: an error occured while processing ther request + @cvar Complete: the request has completed successfuly + @cvar Error: the request has completed with an error @cvar Removed: the request is no longer present in the client (and on the nodes queue) + @cvar MaskProcessed: bitmask checking if a request is completely processed (either + successfuly completed or completed with an error or removed) + @note: the FcStatus member of the params dict of a request should contain one or more of the bitflags it picked up while running through the client. """ Null = 0x0 Pending = 0x1 - Compressing = 0x2 - Compressed = 0x4 - Started = 0x8 + Started = 0x2 + Compressing = 0x4 + Compressed = 0x8 Complete = 0x10 Error = 0x20 Removed = 0x40 - + + MaskProcessed = Complete | Error | Removed + class RequestSubType: """Consts indicating the subtype of a message""" @@ -330,7 +332,6 @@ PutComplexDir = 6 - #TODO: no idea how fcp handles strings as in <Peer volatile.status=CONNECTED> # all I could find in the sources where these constants as in PEER_NODE_STATUS_CONNECTED # in --> freenet/node/PeerManager.java @@ -349,10 +350,12 @@ ConnError = 12 Disconnecting = 13 + class PeerNoteType: """All known peer note types""" Private = '1' + class Persistence: Connection = 'connection' Reboot = 'reboot' @@ -384,7 +387,6 @@ PriorityClass = 0x2 - class ReturnType: Direct = 'direct' Disk = 'disk' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-06 10:52:03
|
Revision: 156 http://fclient.svn.sourceforge.net/fclient/?rev=156&view=rev Author: jurner Date: 2008-02-06 02:52:05 -0800 (Wed, 06 Feb 2008) Log Message: ----------- more fine grained status and type flags for requests Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-05 16:00:48 UTC (rev 155) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-06 10:52:05 UTC (rev 156) @@ -298,9 +298,11 @@ @cvar Started: the request has started @cvar Compressing: the request is about to be compressed @cvar Compressed: compressing is completed - @cvar Complete: the request has completed successfuly + @cvar Success: the request has completed successfuly @cvar Error: the request has completed with an error - @cvar Removed: the request is no longer present in the client (and on the nodes queue) + @cvar Completed: processing of the request is completed + @cvar Removed: the request is no longer present in the nodes queue. The client will remove the request + from its own queue as soon as all event listeners have been notified. @cvar MaskProcessed: bitmask checking if a request is completely processed (either successfuly completed or completed with an error or removed) @@ -313,25 +315,31 @@ Started = 0x2 Compressing = 0x4 Compressed = 0x8 - Complete = 0x10 + Success = 0x10 Error = 0x20 - Removed = 0x40 - - MaskProcessed = Complete | Error | Removed + + Completed =0x10000000 + Removed = 0x2000000 + - -class RequestSubType: - """Consts indicating the subtype of a message""" +class RequestType: + """Consts indicating the type of a request""" Null = 0 - GetData = 1 - GetFile = 2 - GetKeyInfo = 3 - Put = 4 - PutDiskDir = 5 - PutComplexDir = 6 + GetData = 0x1 + GetFile = 0x2 + GetKeyInfo = 0x4 + Put = 0x8 + PutDiskDir = 0x10 + PutComplexDir = 0x20 + GenerateSSKKeypair = GenerateKeypair = 0x1000 + GenerateUSKKeypair = 0x2000 + + PluginInfo = 0x2000000 + PluginMessage = 0x4000000 + #TODO: no idea how fcp handles strings as in <Peer volatile.status=CONNECTED> # all I could find in the sources where these constants as in PEER_NODE_STATUS_CONNECTED # in --> freenet/node/PeerManager.java This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-06 14:57:07
|
Revision: 165 http://fclient.svn.sourceforge.net/fclient/?rev=165&view=rev Author: jurner Date: 2008-02-06 06:57:08 -0800 (Wed, 06 Feb 2008) Log Message: ----------- distinguish Removed from RemovedFromQueue Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-06 14:57:01 UTC (rev 164) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-06 14:57:08 UTC (rev 165) @@ -289,8 +289,8 @@ GetPluginInfo, FCPPlugin, ) - + class RequestStatus: """Request status flags @cvar Null: no status @@ -300,8 +300,10 @@ @cvar Compressed: compressing is completed @cvar Success: the request has completed successfuly @cvar Error: the request has completed with an error + @cvar Removed: the request is completed because it will be or has been removed + @cvar Completed: processing of the request is completed - @cvar Removed: the request is no longer present in the nodes queue. The client will remove the request + @cvar RemovedFromQueue: the request is no longer present in the nodes queue. The client will remove the request from its own queue as soon as all event listeners have been notified. @cvar MaskProcessed: bitmask checking if a request is completely processed (either @@ -317,9 +319,10 @@ Compressed = 0x8 Success = 0x10 Error = 0x20 + Removed = 0x40 Completed =0x10000000 - Removed = 0x2000000 + RemovedFromQueue = 0x2000000 class RequestType: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-07 23:48:24
|
Revision: 168 http://fclient.svn.sourceforge.net/fclient/?rev=168&view=rev Author: jurner Date: 2008-02-07 15:48:25 -0800 (Thu, 07 Feb 2008) Log Message: ----------- some more consts Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-07 23:47:22 UTC (rev 167) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-07 23:48:25 UTC (rev 168) @@ -341,6 +341,13 @@ PluginInfo = 0x2000000 PluginMessage = 0x4000000 + + SubscribeUSK = 0x10000000000 + + MaskGet = GetData | GetFile | GetKeyInfo + MaskGenerateKeypair = GenerateSSKKeypair | GenerateUSKKeypair + MaskPlugin = PluginInfo | PluginMessage + MaskPut = Put | PutDiskDir | PutComplexDir #TODO: no idea how fcp handles strings as in <Peer volatile.status=CONNECTED> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-08 08:37:40
|
Revision: 174 http://fclient.svn.sourceforge.net/fclient/?rev=174&view=rev Author: jurner Date: 2008-02-08 00:37:46 -0800 (Fri, 08 Feb 2008) Log Message: ----------- removed ReequestStatus.Started Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 08:37:27 UTC (rev 173) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 08:37:46 UTC (rev 174) @@ -295,7 +295,6 @@ """Request status flags @cvar Null: no status @cvar Pending: the request is not started yet - @cvar Started: the request has started @cvar Compressing: the request is about to be compressed @cvar Compressed: compressing is completed @cvar Success: the request has completed successfuly @@ -314,12 +313,11 @@ """ Null = 0x0 Pending = 0x1 - Started = 0x2 - Compressing = 0x4 - Compressed = 0x8 - Success = 0x10 - Error = 0x20 - Removed = 0x40 + Compressing = 0x2 + Compressed = 0x4 + Success = 0x8 + Error = 0x10 + Removed = 0x20 Completed =0x10000000 RemovedFromQueue = 0x2000000 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-08 23:41:06
|
Revision: 192 http://fclient.svn.sourceforge.net/fclient/?rev=192&view=rev Author: jurner Date: 2008-02-08 15:41:00 -0800 (Fri, 08 Feb 2008) Log Message: ----------- minor fixes Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 23:40:33 UTC (rev 191) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 23:41:00 UTC (rev 192) @@ -77,8 +77,8 @@ FatalErrorInBlocks = 6 TooManyRetriesInBlock = 7 RouteReallyNotFound = 8 - Collision = '9' - Canceled = '10' + Collision = 9 + Canceled = 10 class ProtocolError(Exception): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-09 09:36:13
|
Revision: 197 http://fclient.svn.sourceforge.net/fclient/?rev=197&view=rev Author: jurner Date: 2008-02-09 01:36:15 -0800 (Sat, 09 Feb 2008) Log Message: ----------- some fixes and a debug helper for bitflags Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-09 09:35:22 UTC (rev 196) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-09 09:36:15 UTC (rev 197) @@ -6,6 +6,31 @@ #************************************************************************ # #************************************************************************ +class BaseBitFlags(object): + """Base class for classes containing bitflags (bitflags only that is)""" + + @classmethod + def humanReadable(clss, flags): + """Returns a list containing human readable names of bitflags as + defined in the class + @param flags: bit flags to translate into human readables + @return: (list) + + @note: use this for debugging for example + """ + out = [] + for name in dir(clss): + if name[0].isupper(): + const = getattr(clss, name) + if isinstance(const, (int, long)): + if flags & const: + out.append(name) + return out + +#************************************************************************ +# +#************************************************************************ + FcpTrue = 'true' FcpFalse = 'false' @@ -146,7 +171,7 @@ Warning = logging.WARNING -class DisconnectReason: +class DisconnectReason(BaseBitFlags): """Reasons for client disconnect @cvar ConnectingFailed: connection could not be established @cvar DuplicateClientName: another client opend a connection with the same connection name @@ -154,14 +179,14 @@ @cvar SocketDied: connection to the node died unexpectingly @cvar VersionMissmatch: node or Fcp version did not match """ - ConnectingFailed = 1 - DuplicateClientName = 2 - Shutdown = 3 - SocketDied = 4 - VersionMissmatch = 5 #TODO: implement??? + ConnectingFailed = 0x1 + DuplicateClientName = 0x2 + Shutdown = 0x4 + SocketDied = 0x8 + VersionMissmatch = 0x10 #TODO: implement??? -class FilenameCollision: +class FilenameCollision(BaseBitFlags): """Filename collision flags @cvar HandleNever: don't handle filename collisions @cvar HandleRename: rename file on collisions @@ -215,7 +240,7 @@ ClientPut = 'ClientPut' ClientPutDiskDir = 'ClientPutDiskDir' ClientPutComplexDir = 'ClientPutComplexDir' - FCPPlugin = 'FCPPlugin' + FCPPluginMessage = 'FCPPluginMessage' GenerateSSK = 'GenerateSSK' GetConfig = 'GetConfig' # (since 1027) GetNode = 'GetNode' @@ -279,19 +304,8 @@ ClientSocketDied = 2 ClientDisconnected = 3 - ClientKeyRequestMessages = ( - ClientGet, - ClientPut, - ClientPutDiskDir, - ClientPutComplexDir, - ) - ClientPluginMessages = ( - GetPluginInfo, - FCPPlugin, - ) - -class RequestStatus: +class RequestStatus(BaseBitFlags): """Request status flags @cvar Null: no status @cvar Restored: the request was restored when the client was started @@ -318,9 +332,9 @@ Completed =0x10000000 RemovedFromQueue = 0x2000000 - - -class RequestType: + + +class RequestType(BaseBitFlags): """Consts indicating the type of a request""" Null = 0 @@ -383,7 +397,7 @@ Low = '4' -class RequestModified: +class RequestModified(BaseBitFlags): """Flags indicating what of a request has been modified @cvar Filename: the filename has been modified @cvar Identifier: the identifier has been moodified @@ -412,7 +426,7 @@ Redirect = 'redirect' -class Verbosity: +class Verbosity(BaseBitFlags): ReportCompletion = 0x0 ReportProgress = 0x1 ReportCompression = 0x200 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-17 09:20:10
|
Revision: 222 http://fclient.svn.sourceforge.net/fclient/?rev=222&view=rev Author: jurner Date: 2008-02-17 01:20:13 -0800 (Sun, 17 Feb 2008) Log Message: ----------- better logger names Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-17 09:19:52 UTC (rev 221) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-17 09:20:13 UTC (rev 222) @@ -217,9 +217,9 @@ class LoggerNames: """Logger names""" - Fcp = '' - Client = 'Client' - Config = 'Config' + Fcp = 'Fcp' + Client = 'Fcp.Client' + Config = 'Fcp.Config' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-18 00:32:43
|
Revision: 227 http://fclient.svn.sourceforge.net/fclient/?rev=227&view=rev Author: jurner Date: 2008-02-17 16:32:46 -0800 (Sun, 17 Feb 2008) Log Message: ----------- minor changes Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-18 00:31:32 UTC (rev 226) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-18 00:32:46 UTC (rev 227) @@ -148,7 +148,7 @@ CouldNotReadFile = 26 ReferenceSignature = 27 CanNotPeerWithSelf = 28 - PeerExists = '29' + PeerExists = 29 OpennetDisabled = 30 DarknetPeerOnly = 31 NoSuchPlugin = 32 @@ -186,7 +186,7 @@ DuplicateClientName = 0x2 Shutdown = 0x4 SocketDied = 0x8 - VersionMissmatch = 0x10 #TODO: implement??? + VersionMissmatch = 0x10 class FilenameCollision(BaseBitFlags): @@ -216,12 +216,11 @@ class LoggerNames: - """Logger names""" + """Logger names used by the client""" Fcp = 'Fcp' - Client = 'Fcp.Client' - Config = 'Fcp.Config' + Client = Fcp + '.Client' + Config = Fcp + '.Config' - class LogMessages: """Strings used for log infos""" @@ -241,7 +240,6 @@ AllRequestsCompleted = 'All requests completed' EventTriggered = 'Event Triggered: ' - class Message: @@ -365,7 +363,6 @@ Disconnecting = 'DISCONNECTING' Unknown = 'UNKNOWN STATUS' - class RequestType(BaseBitFlags): """Consts indicating the type of a request""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-18 13:28:39
|
Revision: 228 http://fclient.svn.sourceforge.net/fclient/?rev=228&view=rev Author: jurner Date: 2008-02-18 05:28:30 -0800 (Mon, 18 Feb 2008) Log Message: ----------- added aome more loggers Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-18 00:32:46 UTC (rev 227) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-18 13:28:30 UTC (rev 228) @@ -216,9 +216,21 @@ class LoggerNames: - """Logger names used by the client""" + """Logger names used by the the package + + @cvar Fcp: root logger for the packsge + @cvar Client: root logger for the client + @cvar ClientEvents: logs events the client emits + @cvar ClientMessages: logs messages the client sends and receives + @cvar ClientRuntime: logs runtime information + + @cvar Config: logs config related information + """ Fcp = 'Fcp' Client = Fcp + '.Client' + ClientEvents = Client + '.Events' + ClientMessages = Client + '.Messages' + ClientRuntime = Client + '.Runtime' Config = Fcp + '.Config' @@ -232,14 +244,14 @@ ClientClose = 'closing client' - MessageSend = 'sending message' - MessageReceived = 'received message' + MessageSend = 'send' + MessageReceived = 'received' KeyboardInterrupt = 'keyboard interrupt' # kick out SocketDied = 'socket died' AllRequestsCompleted = 'All requests completed' - EventTriggered = 'Event Triggered: ' + EventTriggered = 'triggered: ' class Message: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-01-30 13:21:51
|
Revision: 88 http://fclient.svn.sourceforge.net/fclient/?rev=88&view=rev Author: jurner Date: 2008-01-30 05:21:55 -0800 (Wed, 30 Jan 2008) Log Message: ----------- continued working on type conversions Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-30 13:21:04 UTC (rev 87) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-30 13:21:55 UTC (rev 88) @@ -231,17 +231,48 @@ ReportProgress = 0x1 ReportCompression = 0x200 - #************************************************************************************* # python <--> fcp value mappings #************************************************************************************* #TODO: reqork Clss.validateFcpValue +class FcpType(object): + + # consts for validation + ValidatesInvalid = 0x0 + ValidatesValid = 0x1 + ValidatesIncomlete = 0x2 + + @classmethod + def pythonToFcp(clss, value): + return value + + @classmethod + def fcpToPython(clss, value): + return value + + @classmethod + def validateFcpValue(clss, value): + return clss.ValidatesValid + + +class FcpTypeString(FcpType): + + @classmethod + def pythonToFcp(clss, value): + return str(value) #TODO: ??? unicode ??? + + @classmethod + def fcpToPython(clss, value): + return value + + @classmethod + def validateFcpValue(clss, value): + return clss.ValidatesValid -FcpTrue = 'true' -FcpFalse = 'false' -class FcpTypeBool(object): + +class FcpTypeBool(FcpType): @classmethod def pythonToFcp(clss, value): @@ -254,11 +285,11 @@ @classmethod def validateFcpValue(clss, value): if value in ('true', 'false'): - return str(value) - return None + return self.ValidatesValid + return self.ValidatesInvalid -class FcpTypeInt(object): +class FcpTypeInt(FcpType): @classmethod def pythonToFcp(clss, value): @@ -276,8 +307,27 @@ return None +class FcpTypeFloat(FcpType): + + @classmethod + def pythonToFcp(clss, value): + return str(value) + + @classmethod + def fcpToPython(clss, value): + return float(value) + + @classmethod + def validateFcpValue(clss, value): + try: + return float(value) + except ValueError: + return None + + + # GetFailed sets the ExpectedDataLenght field to '' (empty string). Fix this to show up as -1 -class FcpTypeInt_GetFailed_ExpectedDataLenght(object): +class FcpTypeInt_GetFailed_ExpectedDataLenght(FcpType): @classmethod def pythonToFcp(clss, value): @@ -300,7 +350,7 @@ -class FcpTypeIntWithBounds(object): +class FcpTypeIntWithBounds(FcpType): def __init__(self, lowerBound, upperBound): self.lowerBound = lowerBound @@ -329,27 +379,25 @@ -class FcpTypeBase64EncodedString(object): +class FcpTypeBase64EncodedString(FcpType): @classmethod def pythonToFcp(clss, value): - return base64.encode(value) + return base64.b64encode(value) @classmethod def fcpToPython(clss, value): - return base64.decode(value) + return base64.b64decode(value) @classmethod def validateFcpValue(clss, value): pass #TODO: no idea - # we add a few private params... - ParamPrefixPrivate = 'Fc' + - -class FcpTypeTime(object): +class FcpTypeTime(FcpType): @classmethod def pythonToFcp(clss, value): @@ -362,12 +410,452 @@ @classmethod def validateFcpValue(clss, value): try: - return self.fcpToPython(value) + return clss.fcpToPython(value) except ValueEror: return none + +class FcpTypeIP(FcpType): + pass + +#TODO: check if comma separated or colon separated +class FcpTypeIPList(FcpType): + pass + +class FcpTypeIPort(FcpType): + pass + +class FcpTypeStringList(FcpType): + pass + +class FcpTypeDirname(FcpType): + pass + +class FcpTypeFilename(FcpType): + pass + + +class FcpTypeNumBytes(FcpType): + pass + +class FcpTypePercent(FcpTypeFloat): + pass + + +class FcpTypeUri(FcpType): + pass + + +# special choice types for config message + + +class FcpTypeChoiceFProxyCss(FcpType): + Clean = 'Clean' + Boxed = 'boxed' + GrayAndBlue = 'grayandblue' + Sky = 'sky' + + ChoicesAll = (Clean, Boxed, GrayAndBlue, Sky) + ChoicesAllowMultiple = False + +class FcpTypeChoiceLoggerPriority(FcpType): + Error = 'ERROR' + Normal = 'NORMAL' + Minor = 'MINOR' + Debug = 'DEBUG' + + ChoicesAll = (Error, Normal, Minor, Debug) + ChoicesAllowMultiple = False + +class FcpTypeChoiceNodeDownloadAllowedDirs(FcpType): + All = 'all' + Downloads = 'downloads' + Nowhere = '' + + ChoicesAll = (All, Downloads, Nowhere) + ChoicesAllowMultiple = False + +class FcpTypeChoiceNodeUploadAllowedDirs(FcpType): + All = 'all' + Nowhere = '' + ChoicesAll = (All, Nowhere) + ChoicesAllowMultiple = False + +class FcpTypeChoicePriorityPolicy(FcpType): + Hard = 'HARD' + Soft = 'SOFT' + + ChoicesAll = (Hard, Soft) + ChoicesAllowMultiple = False + + +class FcpTypeChoiceSSLVersion(FcpType): + Stl = 'STL' + SslV3 = 'SSLV3' + TlsV1 = 'TLSv1' + + ChoicesAll = (Stl, SslV3, TlsV1) + ChoicesAllowMultiple = False + + #*************************************************************************************** # +# param types for config message +# +# ..bit more efford here, cos we need types for user input checking +# ...a slpoppy implementation of a dict should be enough +# +#*************************************************************************************** +class ConfigMessageParams(object): + + ComponentsSep = '.' + + + # first component of a config message param is always the param class + + ParamClassCurrent = 'current' + ParamClassDefault = 'default' + ParamClassExpertFlag = 'expertFlag' + ParamClassForceWriteFlag = 'forceWriteFlag' + ParamClassShortDescription = 'shortDescription' + ParamClassLongDescription = 'longDescription' + ParamClassSortOrder = 'sortOrder' + + ParamClasses = ( + ParamClassCurrent, + ParamClassDefault, + ParamClassExpertFlag, + ParamClassForceWriteFlag, + ParamClassShortDescription, + ParamClassLongDescription, + ) + + + + # all known config keys (param class stripped) + Params = { + + 'console.allowedHosts': FcpTypeIPList, # host names, single IPs CIDR-maskip IPs likee 192.168.0.0/24 + 'console.bindTo': FcpTypeIPList, + 'console.directEnabled': FcpTypeBool, + 'console.enabled': FcpTypeBool, + 'console.port': FcpTypeIPort, + 'console.ssl': FcpTypeBool, + + + 'fcp.allowedHosts': FcpTypeIPList, + 'fcp.allowedHostsFullAccess': FcpTypeIPList, + 'fcp.assumeDownloadDDAIsAllowed': FcpTypeBool, + 'fcp.assumeUploadDDAIsAllowed': FcpTypeBool, + 'fcp.bindTo': FcpTypeIP, + 'fcp.enabled': FcpTypeBool, + 'fcp.persistentDownloadsEnabled': FcpTypeBool, + 'fcp.persistentDownloadsFile': FcpTypeFilename, + 'fcp.persistentDownloadsInterval': FcpTypeIntWithBounds(0, None), + 'fcp.port': FcpTypeIPort, + 'fcp.ssl': FcpTypeBool, + + + 'fproxy.CSSOverride': FcpTypeBool, + 'fproxy.advancedModeEnabled': FcpTypeBool, + 'fproxy.allowedHosts': FcpTypeIPList, + 'fproxy.allowedHostsFullAccess': FcpTypeIPList, + 'fproxy.bindTo': FcpTypeIPList, + 'fproxy.css': FcpTypeChoiceFProxyCss, + 'fproxy.doRobots': FcpTypeBool, + 'fproxy.enabled': FcpTypeBool, + 'fproxy.javascriptEnabled': FcpTypeBool, + 'fproxy.port': FcpTypeIPort, + 'fproxy.showPanicButton': FcpTypeBool, + 'fproxy.ssl': FcpTypeBool, + + + 'logger.dirname': FcpTypeDirname, + 'logger.enabled': FcpTypeBool, + 'logger.interval': FcpType, # ??? 1HOUR ?? + 'logger.maxCachedBytes': FcpTypeNumBytes, + 'logger.maxCachedLines': FcpTypeIntWithBounds(0, None), # ??? + 'logger.maxZippedLogsSize': FcpTypeNumBytes, # ??? + 'logger.priority': FcpTypeChoiceLoggerPriority, + 'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ??? + + + 'node.alwaysAllowLocalAddresses': FcpTypeBool, + 'node.assumeNATed': FcpTypeBool, + 'node.bindTo': FcpTypeIP, + 'node.clientThrottleFile': FcpTypeFilename, + 'node.databaseMaxMemory': FcpTypeNumBytes, + 'node.disableHangCheckers': FcpTypeBool, + 'node.disableProbabilisticHTLs': FcpTypeBool, + 'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs, + 'node.downloadsDir': FcpTypeDirname, + 'node.extraPeerDataDir': FcpTypeDirname, + 'node.includeLocalAddressesInNoderefs': FcpTypeBool, + 'node.inputBandwidthLimit': FcpTypeNumBytes, # -1 is possible as value aswell + 'node.ipAddressOverride': FcpTypeIP, + 'node.l10n': FcpType, # ??? + 'node.lazyResume': FcpTypeBool, + 'node.listenPort': FcpTypeIPort, + 'node.maxBackgroundUSKFetchers': FcpTypeIntWithBounds(0, None), + 'node.maxHTL': FcpTypeIntWithBounds(0, None), + 'node.name': FcpTypeString, + 'node.nodeDir': FcpTypeDirname, + 'node.oneConnectionPerIP': FcpTypeBool, + 'node.outputBandwidthLimit': FcpTypeNumBytes, + 'node.passOpennetPeersThroughDarknet': FcpTypeBool, + 'node.persistentTempDir': FcpTypeDirname, + 'node.storeDir': FcpTypeDirname, + 'node.storeForceBigShrinks': FcpTypeBool, + 'node.storeSize': FcpTypeNumBytes, + 'node.tempDir': FcpTypeDirname, + 'node.tempIPAddressHint': FcpTypeIP, # ??? + 'node.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None), + 'node.uploadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs, + + + 'node.testnet.enabled': FcpTypeBool, + + + 'node.load.aggressiveGC': FcpType, # ??? + 'node.load.freeHeapBytesThreshold': FcpTypeNumBytes, + 'node.load.freeHeapPercentThreshold': FcpTypePercent, + 'node.load.memoryChecker': FcpTypeBool, + 'node.load.nodeThrottleFile': FcpTypeFilename, + 'node.load.threadLimit': FcpTypeIntWithBounds(0, None), + + + 'node.opennet.acceptSeedConnections': FcpTypeBool, + 'node.opennet.alwaysAllowLocalAddresses': FcpTypeBool, + 'node.opennet.assumeNATed': FcpTypeBool, + 'node.opennet.bindTo': FcpTypeIP, + 'node.opennet.enabled': FcpTypeBool, + 'node.opennet.listenPort': FcpTypeIPort, + 'node.opennet.maxOpennetPeers': FcpTypeIntWithBounds(0, None), + 'node.opennet.oneConnectionPerIP': FcpTypeBool, + 'node.opennet.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None), + + 'node.scheduler.CHKinserter_priority_policy': FcpTypeChoicePriorityPolicy, + 'node.scheduler.CHKrequester_priority_policy': FcpTypeChoicePriorityPolicy, + 'node.scheduler.SSKinserter_priority_policy': FcpTypeChoicePriorityPolicy, + 'node.scheduler.SSKrequester_priority_policy': FcpTypeChoicePriorityPolicy, + + 'node.updater.URI': FcpTypeUri, + 'node.updater.autoupdate': FcpTypeBool, + 'node.updater.enabled': FcpTypeBool, + 'node.updater.extURI': FcpTypeUri, + 'node.updater.revocationURI': FcpTypeUri, + + + 'pluginmanager.loadplugin': FcpTypeStringList, + 'pluginmanager2.loadedPlugins': FcpTypeStringList, + + + 'ssl.sslEnable': FcpTypeBool, + 'ssl.sslKeyPass': FcpTypeString, + 'ssl.sslKeyStore': FcpTypeFilename, + 'ssl.sslKeyStorePass': FcpTypeString, + 'ssl.sslVersion': FcpTypeChoiceSSLVersion, + + 'toadletsymlinker.symlinks': FcpTypeStringList, + + } + + + def splitAll(self, paramName): + return paramName.split(self.ComponentsSep) + + def splitParamClass(self, paramName): + return paramName.split(self.ComponentsSep, 1) + + def __getitem__(self, paramName): + paramClass, paramKey = self.splitParamClass(paramName) + if paramClass == self.ParamClassCurrent: + return self.Params[paramName] + elif paramClass == self.ParamClassDefault: + return self.Params[paramName] + elif paramClass == ParamClassExpertFlag: + return FcpTypeBool + elif paramClass == ParamClassForceWriteFlag: + return FcpTypeBool + elif paramClass == ParamClassShortDescription: + return FcpTypeString + elif paramClass == ParamClassLongDescription: + return FcpTypeString + elif paramClass == ParamClassSortOrder: + return FcpTypeInt + else: + raise ValueError('Unkinown param class in: %r' % paramName) + +#*************************************************************************************** +# +# param types for peer message +# +# ..need to do a bit more here, cos it may be needed to validate user input +# +#*************************************************************************************** +PeerMessageParams = { + 'ark.number': FcpTypeInt, + 'auth.negTypes': FcpTypeInt, + + + 'location': FcpTypeFloat, + 'opennet': FcpTypeBool, + 'testnet': FcpTypeBool, + + 'metadata.timeLastConnected': FcpTypeTime, + 'metadata.timeLastReceivedPacket': FcpTypeTime, + 'metadata.timeLastRoutable': FcpTypeTime, + 'metadata.timeLastSuccess': FcpTypeTime, + 'metadata.routableConnectionCheckCount': FcpTypeInt, + 'metadata.hadRoutableConnectionCount': FcpTypeInt, + + 'volatile.averagePingTime': FcpTypeFloat, + 'volatile.overloadProbability': FcpTypePercent, + 'volatile.routingBackoff': FcpTypeInt, + 'volatile.routingBackoffPercent': FcpTypePercent, + 'volatile.totalBytesIn': FcpTypeInt, + 'volatile.totalBytesOut': FcpTypeInt, + 'volatile.routingBackoffLength': FcpTypeInt, + } + +'''all other Peer message params here.... + +>> identity=YIrE.................. +>> lastGoodVersion=Fred,0.7,1.0,1106 +>> physical.udp=00.000.000.000:00000 +>> version=Fred,0.7,1.0,1107 +>> dsaGroup.q=ALFDN............... +>> dsaGroup.p=AIYIrE.................. +>> dsaPubKey.y=YSlb............ +>> dsaGroup.g=UaRa............... +>> ark.pubURI=SSK@...................... +>> +>> metadata.detected.udp=000.000.000.000:00000 + +>> volatile.lastRoutingBackoffReason=ForwardRejectedOverload +>> volatile.percentTimeRoutableConnection=99.4735................. +>> volatile.status=CONNECTED + +''' + +#*************************************************************************************** +# +# param types for node message +# +#*************************************************************************************** +NodeMessageParams = { + 'ark.number': FcpTypeInt, + 'auth.negTypes': FcpTypeInt, + 'location': FcpTypeFloat, + 'opennet': FcpTypeBool, + 'testnet': FcpTypeBool, + + + 'volatile.allocatedJavaMemory': FcpTypeInt, + 'volatile.availableCPUs': FcpTypeInt, + 'volatile.averagePingTime': FcpTypeFloat, + 'volatile.avgStoreAccessRate': FcpTypePercent, + 'volatile.backedOffPercent': FcpTypePercent, + 'volatile.bwlimitDelayTime': FcpTypeFloat, + 'volatile.cacheAccess': FcpTypeInt, + 'volatile.cachedKeys': FcpTypeInt, + 'volatile.cachedSize': FcpTypeInt, + 'volatile.cachedStoreHits': FcpTypeInt, + 'volatile.cachedStoreMisses': FcpTypeInt, + 'volatile.freeJavaMemory': FcpTypeInt, + 'volatile.isUsingWrapper': FcpTypeBool, + 'volatile.locationChangePerMinute': FcpTypeFloat, + 'volatile.locationChangePerSession': FcpTypeFloat, + 'volatile.locationChangePerSwap': FcpTypeFloat, + 'volatile.maximumJavaMemory': FcpTypeInt, + 'volatile.maxOverallKeys': FcpTypeInt, + 'volatile.maxOverallSize': FcpTypeInt, + 'volatile.networkSizeEstimate24hourRecent': FcpTypeInt, + 'volatile.networkSizeEstimate48hourRecent': FcpTypeInt, + 'volatile.networkSizeEstimateSession': FcpTypeInt, + 'volatile.noSwaps': FcpTypeFloat, + 'volatile.noSwapsPerMinute': FcpTypeFloat, + 'volatile.numberOfARKFetchers': FcpTypeInt, + 'volatile.numberOfBursting': FcpTypeInt, + 'volatile.numberOfConnected': FcpTypeInt, + 'volatile.numberOfDisabled': FcpTypeInt, + 'volatile.numberOfDisconnected': FcpTypeInt, + 'volatile.numberOfInsertSenders': FcpTypeInt, + 'volatile.numberOfListening': FcpTypeInt, + 'volatile.numberOfListenOnly': FcpTypeInt, + 'volatile.numberOfNeverConnected': FcpTypeInt, + 'volatile.numberOfNotConnected': FcpTypeInt, + 'volatile.numberOfRemotePeerLocationsSeenInSwaps': FcpTypeFloat, + 'volatile.numberOfRequestSenders': FcpTypeInt, + 'volatile.numberOfRoutingBackedOff': FcpTypeInt, + 'volatile.numberOfSimpleConnected': FcpTypeInt, + 'volatile.numberOfTooNew': FcpTypeInt, + 'volatile.numberOfTooOld': FcpTypeInt, + 'volatile.numberOfTransferringRequestSenders': FcpTypeInt, + 'volatile.numberWithRoutingBackoffReasons.ForwardRejectedOverload': FcpTypeInt, + 'volatile.overallAccesses': FcpTypeInt, + 'volatile.overallKeys': FcpTypeInt, + 'volatile.overallSize': FcpTypeInt, + 'volatile.percentCachedStoreHitsOfAccesses': FcpTypePercent, + 'volatile.percentOverallKeysOfMax': FcpTypePercent, + 'volatile.percentStoreHitsOfAccesses': FcpTypePercent, + 'volatile.pInstantReject': FcpTypeFloat, # or percent? + 'volatile.recentInputRate': FcpTypeFloat, + 'volatile.recentOutputRate': FcpTypeFloat, + 'volatile.routingMissDistance': FcpTypeFloat, + 'volatile.runningThreadCount': FcpTypeInt, + 'volatile.startedSwaps': FcpTypeInt, + 'volatile.startupTime': FcpTypeTime, + 'volatile.storeAccesses': FcpTypeInt, + 'volatile.storeHits': FcpTypeInt, + 'volatile.storeKeys': FcpTypeInt, + 'volatile.storeMisses': FcpTypeInt, + 'volatile.storeSize': FcpTypeInt, + 'volatile.swaps': FcpTypeFloat, + 'volatile.swapsPerMinute': FcpTypeFloat, + 'volatile.swapsPerNoSwaps': FcpTypeFloat, + 'volatile.swapsRejectedAlreadyLocked': FcpTypeInt, + 'volatile.swapsRejectedLoop': FcpTypeInt, + 'volatile.swapsRejectedNowhereToGo': FcpTypeInt, + 'volatile.swapsRejectedRateLimit': FcpTypeInt, + 'volatile.swapsRejectedRecognizedID': FcpTypeInt, + 'volatile.totalInputBytes': FcpTypeInt, + 'volatile.totalInputRate': FcpTypeInt, + 'volatile.totalOutputBytes': FcpTypeInt, + 'volatile.totalOutputRate': FcpTypeInt, + 'volatile.totalPayloadOutputBytes': FcpTypeInt, + 'volatile.totalPayloadOutputPercent': FcpTypePercent, + 'volatile.totalPayloadOutputRate': FcpTypeInt, + 'volatile.unclaimedFIFOSize': FcpTypeInt, + 'volatile.uptimeSeconds': FcpTypeInt, + 'volatile.usedJavaMemory': FcpTypeInt, + } + + +''' +>>all other NodeData message params here.... +>> +>> physical.udp=000.000.000.000:00000 +>> dsaPubKey.y=GgrpsNUK9m................................................. +>> version=Fred,0.7,1.0,1107 +>> myName=whatever +>> ark.pubURI=SSK@............... + +>> dsaGroup.q=ALFDNoq..... +>> dsaGroup.p=AIYIrE9VNhM3............. +>> volatile.avgConnectedPeersPerNode=15.35................ +>> dsaGroup.g=UaRa............. +>> dsaPrivKey.x=Pwam.................. +>> ark.privURI=SSK@................. +>> lastGoodVersion=Fred,0.7,1.0,1106 +>> sig=691f............ +>> identity=vMQa~.................. + +''' + + +#*************************************************************************************** +# # Mapping from message params to param types # # ...being lazy here, only types that are not strings are declared @@ -377,12 +865,17 @@ # client messages + 'ListPeer': { + 'WithMetadata': FcpTypeBool, + 'WithVolantile': FcpTypeBool, + }, + 'ListPeers': { 'WithMetadata': FcpTypeBool, 'WithVolantile': FcpTypeBool, }, - #'AddPeer': {}, # ??? check + #'AddPeer': # added later as PeerMessageParams 'ModifyPeer': { 'AllowLocalAddresses': FcpTypeBool, @@ -409,7 +902,7 @@ 'WithLongDescription': FcpTypeBool, }, - #'ModifyConfig': # ??? check + #'ModifyConfig': # added later as ConfigMessageParams() 'TestDDARequest': { 'WantReadDirectory': FcpTypeBool, @@ -462,15 +955,15 @@ }, - #'Peer': {}, # ??? check + #'Peer': # added later as PeerMessageParams 'PeerNote': { 'NoteText': FcpTypeBase64EncodedString, }, - #'NodeData': {}, # ??? check - #'ConfigData': {}, # ??? check + #'NodeData': # added later as NodeMessageParams + #'ConfigData': # added later as ConfigMessageParams() 'TestDDAComplete': { 'ReadDirectoryAllowed': FcpTypeBool, @@ -485,7 +978,7 @@ }, 'AllData': { 'Global': FcpTypeBool, - #NOTE: we ignore startup and completion time here, as long as it is not passed in all messages + #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages }, 'FinishedCompression': { @@ -529,8 +1022,6 @@ 'Edition': FcpTypeInt, }, - - } MessageParamTypes['ClientPutDiskDir'] = MessageParamTypes['ClientPut'] @@ -541,6 +1032,19 @@ MessageParamTypes['PersistentPut'] = MessageParamTypes['ClientPut'] +MessageParamTypes['ModifyConfig'] = MessageParamTypes['ConfigData'] = ConfigMessageParams() - +MessageParamTypes['Peer'] = MessageParamTypes['AddPeer'] = PeerMessageParams + + + + + + + + + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-01-30 14:35:28
|
Revision: 91 http://fclient.svn.sourceforge.net/fclient/?rev=91&view=rev Author: jurner Date: 2008-01-30 06:35:33 -0800 (Wed, 30 Jan 2008) Log Message: ----------- fixes Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-30 13:23:25 UTC (rev 90) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-01-30 14:35:33 UTC (rev 91) @@ -574,7 +574,7 @@ 'logger.enabled': FcpTypeBool, 'logger.interval': FcpType, # ??? 1HOUR ?? 'logger.maxCachedBytes': FcpTypeNumBytes, - 'logger.maxCachedLines': FcpTypeIntWithBounds(0, None), # ??? + 'logger.maxCachedLines': FcpTypeNumBytes, # ??? 'logger.maxZippedLogsSize': FcpTypeNumBytes, # ??? 'logger.priority': FcpTypeChoiceLoggerPriority, 'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ??? @@ -661,30 +661,42 @@ } + def __init__(self): + pass + + def splitAll(self, paramName): return paramName.split(self.ComponentsSep) def splitParamClass(self, paramName): return paramName.split(self.ComponentsSep, 1) + + def get(self, paramName, default=None): + try: + return self[paramName] + except KeyError: + return default + + def __getitem__(self, paramName): paramClass, paramKey = self.splitParamClass(paramName) if paramClass == self.ParamClassCurrent: - return self.Params[paramName] + return self.Params[paramKey] elif paramClass == self.ParamClassDefault: - return self.Params[paramName] - elif paramClass == ParamClassExpertFlag: + return self.Params[paramKey] + elif paramClass == self.ParamClassExpertFlag: return FcpTypeBool - elif paramClass == ParamClassForceWriteFlag: + elif paramClass == self.ParamClassForceWriteFlag: return FcpTypeBool - elif paramClass == ParamClassShortDescription: + elif paramClass == self.ParamClassShortDescription: return FcpTypeString - elif paramClass == ParamClassLongDescription: + elif paramClass == self.ParamClassLongDescription: return FcpTypeString - elif paramClass == ParamClassSortOrder: + elif paramClass == self.ParamClassSortOrder: return FcpTypeInt else: - raise ValueError('Unkinown param class in: %r' % paramName) + raise ValueError('Unknown param class in: %r' % paramName) #*************************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-01 14:44:41
|
Revision: 100 http://fclient.svn.sourceforge.net/fclient/?rev=100&view=rev Author: jurner Date: 2008-02-01 06:44:41 -0800 (Fri, 01 Feb 2008) Log Message: ----------- refactor a bit and a few more messages Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-01 14:43:34 UTC (rev 99) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-01 14:44:41 UTC (rev 100) @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + """Freennet Client Protocol consts and type mappings""" import base64 @@ -125,8 +127,8 @@ PeerExists = '29' OpennetDisabled = 30 DarknetPeerOnly = 31 + NoSuchPlugin = 32 - # others class ConnectReason: @@ -150,6 +152,7 @@ SocketDied = 2 ConnectingFailed = 3 DuplicateConnectionName = 4 + VersionMismatch = 5 #TODO: implement??? class FilenameCollision: @@ -161,6 +164,18 @@ CollisionHandled = 0x10000000 # a filename collision has already been handled +class KeyType: + SSK = 'SSK@' + KSK = 'KSK@' + CHK = 'CHK@' + USK = 'USK@' + SVK = 'SVK@' + Invalid = '' + TypesAll = (SSK, KSK, CHK, USK, SVK) + + + + class LogMessages: """Message strings used for log infos""" Connecting = 'connecting to node...' @@ -234,15 +249,8 @@ #************************************************************************************* # python <--> fcp value mappings #************************************************************************************* -#TODO: reqork Clss.validateFcpValue - class FcpType(object): - # consts for validation - ValidatesInvalid = 0x0 - ValidatesValid = 0x1 - ValidatesIncomlete = 0x2 - @classmethod def pythonToFcp(clss, value): return value @@ -250,28 +258,19 @@ @classmethod def fcpToPython(clss, value): return value - - @classmethod - def validateFcpValue(clss, value): - return clss.ValidatesValid - - + + class FcpTypeString(FcpType): @classmethod def pythonToFcp(clss, value): - return str(value) #TODO: ??? unicode ??? + return str(value) #TODO: unicode ??? @classmethod def fcpToPython(clss, value): return value - - @classmethod - def validateFcpValue(clss, value): - return clss.ValidatesValid - class FcpTypeBool(FcpType): @classmethod @@ -282,12 +281,6 @@ def fcpToPython(clss, value): return value == FcpTrue - @classmethod - def validateFcpValue(clss, value): - if value in ('true', 'false'): - return self.ValidatesValid - return self.ValidatesInvalid - class FcpTypeInt(FcpType): @@ -299,13 +292,6 @@ def fcpToPython(clss, value): return int(value) - @classmethod - def validateFcpValue(clss, value): - try: - return int(value) - except ValueError: - return None - class FcpTypeFloat(FcpType): @@ -317,15 +303,7 @@ def fcpToPython(clss, value): return float(value) - @classmethod - def validateFcpValue(clss, value): - try: - return float(value) - except ValueError: - return None - - # GetFailed sets the ExpectedDataLenght field to '' (empty string). Fix this to show up as -1 class FcpTypeInt_GetFailed_ExpectedDataLenght(FcpType): @@ -339,17 +317,7 @@ return -1 return int(value) - @classmethod - def validateFcpValue(clss, value): - if value == '': - return -1 - try: - return int(value) - except ValueError: - return None - - class FcpTypeIntWithBounds(FcpType): def __init__(self, lowerBound, upperBound): @@ -362,23 +330,7 @@ def fcpToPython(self, value): return int(value) - def validateFcpValue(self, value): - try: - n = int(value) - except ValueError: - return None - - if self.lowerBound is not None: - if n >= self.lowerBound: - return n - if self.upperBound is not None: - if n <= self.upperBound: - return n - - return None - - class FcpTypeBase64EncodedString(FcpType): @classmethod @@ -389,13 +341,6 @@ def fcpToPython(clss, value): return base64.b64decode(value) - @classmethod - def validateFcpValue(clss, value): - pass - #TODO: no idea - - - class FcpTypeTime(FcpType): @@ -407,45 +352,19 @@ def fcpToPython(clss, value): return int(value) / 1000 - @classmethod - def validateFcpValue(clss, value): - try: - return clss.fcpToPython(value) - except ValueEror: - return none -class FcpTypeIP(FcpType): - pass +class FcpTypeIP(FcpType): pass +class FcpTypeIPList(FcpType): pass +class FcpTypeIPort(FcpType): pass +class FcpTypeStringList(FcpType): pass +class FcpTypeDirname(FcpType): pass +class FcpTypeFilename(FcpType): pass +class FcpTypeNumBytes(FcpType): pass +class FcpTypePercent(FcpTypeFloat): pass +class FcpTypeUri(FcpType): pass -#TODO: check if comma separated or colon separated -class FcpTypeIPList(FcpType): - pass - -class FcpTypeIPort(FcpType): - pass -class FcpTypeStringList(FcpType): - pass - -class FcpTypeDirname(FcpType): - pass - -class FcpTypeFilename(FcpType): - pass - - -class FcpTypeNumBytes(FcpType): - pass - -class FcpTypePercent(FcpTypeFloat): - pass - - -class FcpTypeUri(FcpType): - pass - - # special choice types for config message @@ -864,8 +783,6 @@ >> identity=vMQa~.................. ''' - - #*************************************************************************************** # # Mapping from message params to param types @@ -955,16 +872,21 @@ 'ModifyPersistentRequest': { 'Global': FcpTypeBool, }, + 'GetPluginInfo': { + 'Detailed': FcpTypeBool, + }, + # node messages 'NodeHello': { + 'Build': FcpTypeInt, 'CompressionCodecs': FcpTypeInt, + 'ExtBuild': FcpTypeInt, + 'ExtRevision': FcpTypeInt, + 'FcpVersion': FcpTypeFloat, 'Testnet': FcpTypeBool, - - #TODO: ExtBuild et al. ??? - }, #'Peer': # added later as PeerMessageParams @@ -1032,7 +954,10 @@ }, 'SubscribedUSKUpdate': { 'Edition': FcpTypeInt, - }, + }, + 'GetPluginInfo': { + 'Started': FcpTypeBool, + }, } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-02 05:12:45
|
Revision: 105 http://fclient.svn.sourceforge.net/fclient/?rev=105&view=rev Author: jurner Date: 2008-02-01 21:12:51 -0800 (Fri, 01 Feb 2008) Log Message: ----------- moved types to types module Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-02 05:12:17 UTC (rev 104) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-02 05:12:51 UTC (rev 105) @@ -2,7 +2,6 @@ """Freennet Client Protocol consts and type mappings""" -import base64 import logging #************************************************************************ # @@ -132,11 +131,16 @@ # others class ConnectReason: + """Reason for connecting to the node + @cvar Connect: reason is a regualr connect + @cvar Reconnect: reason is a reconnect + """ Connect = 1 Reconnect = 2 class DebugVerbosity: + """Consts indicating the verbosity level for debugging""" Debug = logging.DEBUG Info = logging.INFO Warning = logging.WARNING @@ -156,6 +160,12 @@ class FilenameCollision: + """Filename collision flags + @cvar HandleNever: don't handle filename collisions + @cvar HandleRename: rename file on collisions + @cvar MaskHandle: bitmask indicating if collisions are hadled or not + @cvar CollisonHandled: if this bit is set, a collision has been handled + """ HandleNever = 0x0 HandleRename = 0x1 @@ -165,6 +175,7 @@ class KeyType: + """Supported key types""" SSK = 'SSK@' KSK = 'KSK@' CHK = 'CHK@' @@ -177,7 +188,8 @@ class LogMessages: - """Message strings used for log infos""" + """Strings used for log infos""" + Connecting = 'connecting to node...' Connected = 'connected to node' ConnectionRetry = 'connecting to node failed... retrying' @@ -193,6 +205,105 @@ +class Message: + """Fcp messages""" + + # client s + ClientHello = 'ClientHello' + ListPeer = 'ListPeer' # (since 1045) + ListPeers = 'ListPeers' + ListPeerNotes = 'ListPeerNotes' + AddPeer = 'AddPeer' + ModifyPeer = 'ModifyPeer' + ModifyPeerNote = 'ModifyPeerNote' + RemovePeer = 'RemovePeer' + GetNode = 'GetNode' + GetConfig = 'GetConfig' # (since 1027) + ModifyConfig = 'ModifyConfig' # (since 1027) + TestDDARequest = 'TestDDARequest' # (since 1027) + TestDDAResponse = 'TestDDAResponse' # (since 1027) + GenerateSSK = 'GenerateSSK' + ClientPut = 'ClientPut' + ClientPutDiskDir = 'ClientPutDiskDir' + ClientPutComplexDir = 'ClientPutComplexDir' + ClientGet = 'ClientGet' + GetPluginInfo = 'GetPluginInfo' + FCPPlugin = 'FCPPlugin' + SubscribeUSK = 'SubscribeUSK' + WatchGlobal = 'WatchGlobal' + GetRequestStatus = 'GetRequestStatus' + ListPersistentRequests = 'ListPersistentRequests' + RemovePersistentRequest = 'RemovePersistentRequest' + ModifyPersistentRequest = 'ModifyPersistentRequest' + Shutdown = 'Shutdown' + + # node s + NodeHello = 'NodeHello' + CloseConnectionDuplicateClientName = 'CloseConnectionDuplicateClientName' + Peer = 'Peer' + PeerNote = 'PeerNote' + EndListPeers = 'EndListPeers' + EndListPeerNotes = 'EndListPeerNotes' + PeerRemoved = 'PeerRemoved' + NodeData = 'NodeData' + ConfigData = 'ConfigData' # (since 1027) + TestDDAReply = 'TestDDAReply' # (since 1027) + TestDDAComplete = 'TestDDAComplete' # (since 1027) + SSKKeypair = 'SSKKeypair' + PersistentGet = 'PersistentGet' + PersistentPut = 'PersistentPut' + PersistentPutDir = 'PersistentPutDir' + URIGenerated = 'URIGenerated' + PutSuccessful = 'PutSuccessful' + PutFetchable = 'PutFetchable' + DataFound = 'DataFound' + AllData = 'AllData' + StartedCompression = 'StartedCompression' + FinishedCompression = 'FinishedCompression' + SimpleProgress = 'SimpleProgress' + EndListPersistentRequests = 'EndListPersistentRequests' + PersistentRequestRemoved = 'PersistentRequestRemoved' # (since 1016) + PersistentRequestModified = 'PersistentRequestModified' # (since 1016) + PutFailed = 'PutFailed' + GetFailed = 'GetFailed' + ProtocolError = 'ProtocolError' + IdentifierCollision = 'IdentifierCollision' + UnknownNodeIdentifier = 'UnknownNodeIdentifier' + UnknownPeerNoteType = 'UnknownPeerNoteType' + SubscribedUSKUpdate = 'SubscribedUSKUpdate' + PluginInfo = 'PluginInfo' + FCPPluginReply = 'FCPPluginReply' + + # client s (internal use only) + ClientSocketTimeout = 1 + ClientSocketDied = 2 + ClientDisconnected = 3 + + +class MessageStatus: + Pending = 0x1 + Compressing = 0x2 + Started = 0x4 + Complete = 0x8 + Error = 0x10 + Removed = 0x20 + RestoreFailed = 0x40 + + +class MessageSubType: + """Consts indicating the subtype of a message""" + + # some additional consts + Null = 0 + GetData = 1 + GetFile = 2 + GetKeyInfo = 3 + Put = 4 + PutDiskDir = 5 + PutComplexDir = 6 + + + #TODO: no idea how fcp handles strings as in <Peer volatile.status=CONNECTED> # all I could find in the sources where these constants as in PEER_NODE_STATUS_CONNECTED # in --> freenet/node/PeerManager.java @@ -229,6 +340,20 @@ Low = '4' +class RequestModified: + """Flags indicating what of a request has been modified + @cvar Filename: the filename has been modified + @cvar Identifier: the identifier has been moodified + @cvar PersistentUserData: thepersistent user data has been modified + @cvar PriorityClass: the priority class has been modified + """ + Filename = 0x8 + Identifier = 0x4 + PersistentUserData = 0x1 + PriorityClass = 0x2 + + + class ReturnType: Direct = 'direct' Disk = 'disk' @@ -246,742 +371,3 @@ ReportProgress = 0x1 ReportCompression = 0x200 -#************************************************************************************* -# python <--> fcp value mappings -#************************************************************************************* -class FcpType(object): - - @classmethod - def pythonToFcp(clss, value): - return value - - @classmethod - def fcpToPython(clss, value): - return value - - -class FcpTypeString(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return str(value) #TODO: unicode ??? - - @classmethod - def fcpToPython(clss, value): - return value - - -class FcpTypeBool(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return FcpTrue if value else FcpFalse - - @classmethod - def fcpToPython(clss, value): - return value == FcpTrue - - -class FcpTypeInt(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return str(value) - - @classmethod - def fcpToPython(clss, value): - return int(value) - - -class FcpTypeFloat(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return str(value) - - @classmethod - def fcpToPython(clss, value): - return float(value) - - -# GetFailed sets the ExpectedDataLenght field to '' (empty string). Fix this to show up as -1 -class FcpTypeInt_GetFailed_ExpectedDataLenght(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return str(value) - - @classmethod - def fcpToPython(clss, value): - if value == '': - return -1 - return int(value) - - -class FcpTypeIntWithBounds(FcpType): - - def __init__(self, lowerBound, upperBound): - self.lowerBound = lowerBound - self.upperBound = upperBound - - def pythonToFcp(self, value): - return str(value) - - def fcpToPython(self, value): - return int(value) - - -class FcpTypeBase64EncodedString(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return base64.b64encode(value) - - @classmethod - def fcpToPython(clss, value): - return base64.b64decode(value) - - -class FcpTypeTime(FcpType): - - @classmethod - def pythonToFcp(clss, value): - return str(value * 1000) - - @classmethod - def fcpToPython(clss, value): - return int(value) / 1000 - - - -class FcpTypeIP(FcpType): pass -class FcpTypeIPList(FcpType): pass -class FcpTypeIPort(FcpType): pass -class FcpTypeStringList(FcpType): pass -class FcpTypeDirname(FcpType): pass -class FcpTypeFilename(FcpType): pass -class FcpTypeNumBytes(FcpType): pass -class FcpTypePercent(FcpTypeFloat): pass -class FcpTypeUri(FcpType): pass - - -# special choice types for config message - - -class FcpTypeChoiceFProxyCss(FcpType): - Clean = 'Clean' - Boxed = 'boxed' - GrayAndBlue = 'grayandblue' - Sky = 'sky' - - ChoicesAll = (Clean, Boxed, GrayAndBlue, Sky) - ChoicesAllowMultiple = False - -class FcpTypeChoiceLoggerPriority(FcpType): - Error = 'ERROR' - Normal = 'NORMAL' - Minor = 'MINOR' - Debug = 'DEBUG' - - ChoicesAll = (Error, Normal, Minor, Debug) - ChoicesAllowMultiple = False - -class FcpTypeChoiceNodeDownloadAllowedDirs(FcpType): - All = 'all' - Downloads = 'downloads' - Nowhere = '' - - ChoicesAll = (All, Downloads, Nowhere) - ChoicesAllowMultiple = False - -class FcpTypeChoiceNodeUploadAllowedDirs(FcpType): - All = 'all' - Nowhere = '' - ChoicesAll = (All, Nowhere) - ChoicesAllowMultiple = False - -class FcpTypeChoicePriorityPolicy(FcpType): - Hard = 'HARD' - Soft = 'SOFT' - - ChoicesAll = (Hard, Soft) - ChoicesAllowMultiple = False - - -class FcpTypeChoiceSSLVersion(FcpType): - Stl = 'STL' - SslV3 = 'SSLV3' - TlsV1 = 'TLSv1' - - ChoicesAll = (Stl, SslV3, TlsV1) - ChoicesAllowMultiple = False - - -#*************************************************************************************** -# -# param types for config message -# -# ..bit more efford here, cos we need types for user input checking -# ...a slpoppy implementation of a dict should be enough -# -#*************************************************************************************** -class ConfigMessageParams(object): - - ComponentsSep = '.' - - - # first component of a config message param is always the param class - - ParamClassCurrent = 'current' - ParamClassDefault = 'default' - ParamClassExpertFlag = 'expertFlag' - ParamClassForceWriteFlag = 'forceWriteFlag' - ParamClassShortDescription = 'shortDescription' - ParamClassLongDescription = 'longDescription' - ParamClassSortOrder = 'sortOrder' - - ParamClasses = ( - ParamClassCurrent, - ParamClassDefault, - ParamClassExpertFlag, - ParamClassForceWriteFlag, - ParamClassShortDescription, - ParamClassLongDescription, - ) - - - - # all known config keys (param class stripped) - Params = { - - 'console.allowedHosts': FcpTypeIPList, # host names, single IPs CIDR-maskip IPs likee 192.168.0.0/24 - 'console.bindTo': FcpTypeIPList, - 'console.directEnabled': FcpTypeBool, - 'console.enabled': FcpTypeBool, - 'console.port': FcpTypeIPort, - 'console.ssl': FcpTypeBool, - - - 'fcp.allowedHosts': FcpTypeIPList, - 'fcp.allowedHostsFullAccess': FcpTypeIPList, - 'fcp.assumeDownloadDDAIsAllowed': FcpTypeBool, - 'fcp.assumeUploadDDAIsAllowed': FcpTypeBool, - 'fcp.bindTo': FcpTypeIP, - 'fcp.enabled': FcpTypeBool, - 'fcp.persistentDownloadsEnabled': FcpTypeBool, - 'fcp.persistentDownloadsFile': FcpTypeFilename, - 'fcp.persistentDownloadsInterval': FcpTypeIntWithBounds(0, None), - 'fcp.port': FcpTypeIPort, - 'fcp.ssl': FcpTypeBool, - - - 'fproxy.CSSOverride': FcpTypeBool, - 'fproxy.advancedModeEnabled': FcpTypeBool, - 'fproxy.allowedHosts': FcpTypeIPList, - 'fproxy.allowedHostsFullAccess': FcpTypeIPList, - 'fproxy.bindTo': FcpTypeIPList, - 'fproxy.css': FcpTypeChoiceFProxyCss, - 'fproxy.doRobots': FcpTypeBool, - 'fproxy.enabled': FcpTypeBool, - 'fproxy.javascriptEnabled': FcpTypeBool, - 'fproxy.port': FcpTypeIPort, - 'fproxy.showPanicButton': FcpTypeBool, - 'fproxy.ssl': FcpTypeBool, - - - 'logger.dirname': FcpTypeDirname, - 'logger.enabled': FcpTypeBool, - 'logger.interval': FcpType, # ??? 1HOUR ?? - 'logger.maxCachedBytes': FcpTypeNumBytes, - 'logger.maxCachedLines': FcpTypeNumBytes, # ??? - 'logger.maxZippedLogsSize': FcpTypeNumBytes, # ??? - 'logger.priority': FcpTypeChoiceLoggerPriority, - 'logger.priorityDetail': FcpType, # ???? is it Detailed priority thresholds ??? - - - 'node.alwaysAllowLocalAddresses': FcpTypeBool, - 'node.assumeNATed': FcpTypeBool, - 'node.bindTo': FcpTypeIP, - 'node.clientThrottleFile': FcpTypeFilename, - 'node.databaseMaxMemory': FcpTypeNumBytes, - 'node.disableHangCheckers': FcpTypeBool, - 'node.disableProbabilisticHTLs': FcpTypeBool, - 'node.downloadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs, - 'node.downloadsDir': FcpTypeDirname, - 'node.extraPeerDataDir': FcpTypeDirname, - 'node.includeLocalAddressesInNoderefs': FcpTypeBool, - 'node.inputBandwidthLimit': FcpTypeNumBytes, # -1 is possible as value aswell - 'node.ipAddressOverride': FcpTypeIP, - 'node.l10n': FcpType, # ??? - 'node.lazyResume': FcpTypeBool, - 'node.listenPort': FcpTypeIPort, - 'node.maxBackgroundUSKFetchers': FcpTypeIntWithBounds(0, None), - 'node.maxHTL': FcpTypeIntWithBounds(0, None), - 'node.name': FcpTypeString, - 'node.nodeDir': FcpTypeDirname, - 'node.oneConnectionPerIP': FcpTypeBool, - 'node.outputBandwidthLimit': FcpTypeNumBytes, - 'node.passOpennetPeersThroughDarknet': FcpTypeBool, - 'node.persistentTempDir': FcpTypeDirname, - 'node.storeDir': FcpTypeDirname, - 'node.storeForceBigShrinks': FcpTypeBool, - 'node.storeSize': FcpTypeNumBytes, - 'node.tempDir': FcpTypeDirname, - 'node.tempIPAddressHint': FcpTypeIP, # ??? - 'node.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None), - 'node.uploadAllowedDirs': FcpTypeChoiceNodeDownloadAllowedDirs, - - - 'node.testnet.enabled': FcpTypeBool, - - - 'node.load.aggressiveGC': FcpType, # ??? - 'node.load.freeHeapBytesThreshold': FcpTypeNumBytes, - 'node.load.freeHeapPercentThreshold': FcpTypePercent, - 'node.load.memoryChecker': FcpTypeBool, - 'node.load.nodeThrottleFile': FcpTypeFilename, - 'node.load.threadLimit': FcpTypeIntWithBounds(0, None), - - - 'node.opennet.acceptSeedConnections': FcpTypeBool, - 'node.opennet.alwaysAllowLocalAddresses': FcpTypeBool, - 'node.opennet.assumeNATed': FcpTypeBool, - 'node.opennet.bindTo': FcpTypeIP, - 'node.opennet.enabled': FcpTypeBool, - 'node.opennet.listenPort': FcpTypeIPort, - 'node.opennet.maxOpennetPeers': FcpTypeIntWithBounds(0, None), - 'node.opennet.oneConnectionPerIP': FcpTypeBool, - 'node.opennet.testingDropPacketsEvery': FcpTypeIntWithBounds(0, None), - - 'node.scheduler.CHKinserter_priority_policy': FcpTypeChoicePriorityPolicy, - 'node.scheduler.CHKrequester_priority_policy': FcpTypeChoicePriorityPolicy, - 'node.scheduler.SSKinserter_priority_policy': FcpTypeChoicePriorityPolicy, - 'node.scheduler.SSKrequester_priority_policy': FcpTypeChoicePriorityPolicy, - - 'node.updater.URI': FcpTypeUri, - 'node.updater.autoupdate': FcpTypeBool, - 'node.updater.enabled': FcpTypeBool, - 'node.updater.extURI': FcpTypeUri, - 'node.updater.revocationURI': FcpTypeUri, - - - 'pluginmanager.loadplugin': FcpTypeStringList, - 'pluginmanager2.loadedPlugins': FcpTypeStringList, - - - 'ssl.sslEnable': FcpTypeBool, - 'ssl.sslKeyPass': FcpTypeString, - 'ssl.sslKeyStore': FcpTypeFilename, - 'ssl.sslKeyStorePass': FcpTypeString, - 'ssl.sslVersion': FcpTypeChoiceSSLVersion, - - 'toadletsymlinker.symlinks': FcpTypeStringList, - - } - - - def __init__(self): - pass - - - def splitAll(self, paramName): - return paramName.split(self.ComponentsSep) - - def splitParamClass(self, paramName): - return paramName.split(self.ComponentsSep, 1) - - - def get(self, paramName, default=None): - try: - return self[paramName] - except KeyError: - return default - - - def __getitem__(self, paramName): - paramClass, paramKey = self.splitParamClass(paramName) - if paramClass == self.ParamClassCurrent: - return self.Params[paramKey] - elif paramClass == self.ParamClassDefault: - return self.Params[paramKey] - elif paramClass == self.ParamClassExpertFlag: - return FcpTypeBool - elif paramClass == self.ParamClassForceWriteFlag: - return FcpTypeBool - elif paramClass == self.ParamClassShortDescription: - return FcpTypeString - elif paramClass == self.ParamClassLongDescription: - return FcpTypeString - elif paramClass == self.ParamClassSortOrder: - return FcpTypeInt - else: - raise ValueError('Unknown param class in: %r' % paramName) - -#*************************************************************************************** -# -# param types for peer message -# -# ..need to do a bit more here, cos it may be needed to validate user input -# -#*************************************************************************************** -PeerMessageParams = { - 'ark.number': FcpTypeInt, - 'auth.negTypes': FcpTypeInt, - - - 'location': FcpTypeFloat, - 'opennet': FcpTypeBool, - 'testnet': FcpTypeBool, - - 'metadata.timeLastConnected': FcpTypeTime, - 'metadata.timeLastReceivedPacket': FcpTypeTime, - 'metadata.timeLastRoutable': FcpTypeTime, - 'metadata.timeLastSuccess': FcpTypeTime, - 'metadata.routableConnectionCheckCount': FcpTypeInt, - 'metadata.hadRoutableConnectionCount': FcpTypeInt, - - 'volatile.averagePingTime': FcpTypeFloat, - 'volatile.overloadProbability': FcpTypePercent, - 'volatile.routingBackoff': FcpTypeInt, - 'volatile.routingBackoffPercent': FcpTypePercent, - 'volatile.totalBytesIn': FcpTypeInt, - 'volatile.totalBytesOut': FcpTypeInt, - 'volatile.routingBackoffLength': FcpTypeInt, - } - -'''all other Peer message params here.... - ->> identity=YIrE.................. ->> lastGoodVersion=Fred,0.7,1.0,1106 ->> physical.udp=00.000.000.000:00000 ->> version=Fred,0.7,1.0,1107 ->> dsaGroup.q=ALFDN............... ->> dsaGroup.p=AIYIrE.................. ->> dsaPubKey.y=YSlb............ ->> dsaGroup.g=UaRa............... ->> ark.pubURI=SSK@...................... ->> ->> metadata.detected.udp=000.000.000.000:00000 - ->> volatile.lastRoutingBackoffReason=ForwardRejectedOverload ->> volatile.percentTimeRoutableConnection=99.4735................. ->> volatile.status=CONNECTED - -''' - -#*************************************************************************************** -# -# param types for node message -# -#*************************************************************************************** -NodeMessageParams = { - 'ark.number': FcpTypeInt, - 'auth.negTypes': FcpTypeInt, - 'location': FcpTypeFloat, - 'opennet': FcpTypeBool, - 'testnet': FcpTypeBool, - - - 'volatile.allocatedJavaMemory': FcpTypeInt, - 'volatile.availableCPUs': FcpTypeInt, - 'volatile.averagePingTime': FcpTypeFloat, - 'volatile.avgStoreAccessRate': FcpTypePercent, - 'volatile.backedOffPercent': FcpTypePercent, - 'volatile.bwlimitDelayTime': FcpTypeFloat, - 'volatile.cacheAccess': FcpTypeInt, - 'volatile.cachedKeys': FcpTypeInt, - 'volatile.cachedSize': FcpTypeInt, - 'volatile.cachedStoreHits': FcpTypeInt, - 'volatile.cachedStoreMisses': FcpTypeInt, - 'volatile.freeJavaMemory': FcpTypeInt, - 'volatile.isUsingWrapper': FcpTypeBool, - 'volatile.locationChangePerMinute': FcpTypeFloat, - 'volatile.locationChangePerSession': FcpTypeFloat, - 'volatile.locationChangePerSwap': FcpTypeFloat, - 'volatile.maximumJavaMemory': FcpTypeInt, - 'volatile.maxOverallKeys': FcpTypeInt, - 'volatile.maxOverallSize': FcpTypeInt, - 'volatile.networkSizeEstimate24hourRecent': FcpTypeInt, - 'volatile.networkSizeEstimate48hourRecent': FcpTypeInt, - 'volatile.networkSizeEstimateSession': FcpTypeInt, - 'volatile.noSwaps': FcpTypeFloat, - 'volatile.noSwapsPerMinute': FcpTypeFloat, - 'volatile.numberOfARKFetchers': FcpTypeInt, - 'volatile.numberOfBursting': FcpTypeInt, - 'volatile.numberOfConnected': FcpTypeInt, - 'volatile.numberOfDisabled': FcpTypeInt, - 'volatile.numberOfDisconnected': FcpTypeInt, - 'volatile.numberOfInsertSenders': FcpTypeInt, - 'volatile.numberOfListening': FcpTypeInt, - 'volatile.numberOfListenOnly': FcpTypeInt, - 'volatile.numberOfNeverConnected': FcpTypeInt, - 'volatile.numberOfNotConnected': FcpTypeInt, - 'volatile.numberOfRemotePeerLocationsSeenInSwaps': FcpTypeFloat, - 'volatile.numberOfRequestSenders': FcpTypeInt, - 'volatile.numberOfRoutingBackedOff': FcpTypeInt, - 'volatile.numberOfSimpleConnected': FcpTypeInt, - 'volatile.numberOfTooNew': FcpTypeInt, - 'volatile.numberOfTooOld': FcpTypeInt, - 'volatile.numberOfTransferringRequestSenders': FcpTypeInt, - 'volatile.numberWithRoutingBackoffReasons.ForwardRejectedOverload': FcpTypeInt, - 'volatile.overallAccesses': FcpTypeInt, - 'volatile.overallKeys': FcpTypeInt, - 'volatile.overallSize': FcpTypeInt, - 'volatile.percentCachedStoreHitsOfAccesses': FcpTypePercent, - 'volatile.percentOverallKeysOfMax': FcpTypePercent, - 'volatile.percentStoreHitsOfAccesses': FcpTypePercent, - 'volatile.pInstantReject': FcpTypeFloat, # or percent? - 'volatile.recentInputRate': FcpTypeFloat, - 'volatile.recentOutputRate': FcpTypeFloat, - 'volatile.routingMissDistance': FcpTypeFloat, - 'volatile.runningThreadCount': FcpTypeInt, - 'volatile.startedSwaps': FcpTypeInt, - 'volatile.startupTime': FcpTypeTime, - 'volatile.storeAccesses': FcpTypeInt, - 'volatile.storeHits': FcpTypeInt, - 'volatile.storeKeys': FcpTypeInt, - 'volatile.storeMisses': FcpTypeInt, - 'volatile.storeSize': FcpTypeInt, - 'volatile.swaps': FcpTypeFloat, - 'volatile.swapsPerMinute': FcpTypeFloat, - 'volatile.swapsPerNoSwaps': FcpTypeFloat, - 'volatile.swapsRejectedAlreadyLocked': FcpTypeInt, - 'volatile.swapsRejectedLoop': FcpTypeInt, - 'volatile.swapsRejectedNowhereToGo': FcpTypeInt, - 'volatile.swapsRejectedRateLimit': FcpTypeInt, - 'volatile.swapsRejectedRecognizedID': FcpTypeInt, - 'volatile.totalInputBytes': FcpTypeInt, - 'volatile.totalInputRate': FcpTypeInt, - 'volatile.totalOutputBytes': FcpTypeInt, - 'volatile.totalOutputRate': FcpTypeInt, - 'volatile.totalPayloadOutputBytes': FcpTypeInt, - 'volatile.totalPayloadOutputPercent': FcpTypePercent, - 'volatile.totalPayloadOutputRate': FcpTypeInt, - 'volatile.unclaimedFIFOSize': FcpTypeInt, - 'volatile.uptimeSeconds': FcpTypeInt, - 'volatile.usedJavaMemory': FcpTypeInt, - } - - -''' ->>all other NodeData message params here.... ->> ->> physical.udp=000.000.000.000:00000 ->> dsaPubKey.y=GgrpsNUK9m................................................. ->> version=Fred,0.7,1.0,1107 ->> myName=whatever ->> ark.pubURI=SSK@............... - ->> dsaGroup.q=ALFDNoq..... ->> dsaGroup.p=AIYIrE9VNhM3............. ->> volatile.avgConnectedPeersPerNode=15.35................ ->> dsaGroup.g=UaRa............. ->> dsaPrivKey.x=Pwam.................. ->> ark.privURI=SSK@................. ->> lastGoodVersion=Fred,0.7,1.0,1106 ->> sig=691f............ ->> identity=vMQa~.................. - -''' -#*************************************************************************************** -# -# Mapping from message params to param types -# -# ...being lazy here, only types that are not strings are declared -# -#*************************************************************************************** -MessageParamTypes = { - - # client messages - - 'ListPeer': { - 'WithMetadata': FcpTypeBool, - 'WithVolantile': FcpTypeBool, - }, - - 'ListPeers': { - 'WithMetadata': FcpTypeBool, - 'WithVolantile': FcpTypeBool, - }, - - #'AddPeer': # added later as PeerMessageParams - - 'ModifyPeer': { - 'AllowLocalAddresses': FcpTypeBool, - 'IsDisabled': FcpTypeBool, - 'ListenOnly': FcpTypeBool, - }, - - 'ModifyPeerNote': { - 'NoteText': FcpTypeBase64EncodedString, - }, - - 'GetNode': { - 'GiveOpennetRef': FcpTypeBool, - 'WithPrivate': FcpTypeBool, - 'WithVolatile': FcpTypeBool, - }, - 'GetConfig': { - 'WithCurrent': FcpTypeBool, - 'WithDefaults': FcpTypeBool, - 'WithSortOrder': FcpTypeBool, - 'WithExpertFlag': FcpTypeBool, - 'WithForceWriteFlag': FcpTypeBool, - 'WithShortDescription': FcpTypeBool, - 'WithLongDescription': FcpTypeBool, - }, - - #'ModifyConfig': # added later as ConfigMessageParams() - - 'TestDDARequest': { - 'WantReadDirectory': FcpTypeBool, - 'WantWriteDirectory': FcpTypeBool, - }, - 'ClientPut': { - 'BinaryBlob': FcpTypeBool, - 'DontCompress': FcpTypeBool, - 'EarlyEncode': FcpTypeBool, - 'GetCHKOnly': FcpTypeBool, - 'Global': FcpTypeBool, - 'MaxRetries': FcpTypeInt, - 'Verbosity': FcpTypeInt, - }, - 'ClientGet': { - 'BinaryBlob': FcpTypeBool, - 'Global': FcpTypeBool, - 'IgnoreDS': FcpTypeBool, - 'DSOnly': FcpTypeBool, - 'MaxSize': FcpTypeInt, - 'MaxTempSize': FcpTypeInt, - 'Verbosity': FcpTypeInt, - }, - 'SubscribeUSK': { - 'DontPoll': FcpTypeBool, - }, - 'WatchGlobal': { - 'Enabled': FcpTypeBool, - 'VerbosityMask': FcpTypeInt, - }, - 'GetRequestStatus': { - 'Global': FcpTypeBool, - 'OnlyData': FcpTypeBool, - }, - 'RemopvePersistentRequest': { - 'Global': FcpTypeBool, - }, - 'ModifyPersistentRequest': { - 'Global': FcpTypeBool, - }, - 'GetPluginInfo': { - 'Detailed': FcpTypeBool, - }, - - - - # node messages - - 'NodeHello': { - 'Build': FcpTypeInt, - 'CompressionCodecs': FcpTypeInt, - 'ExtBuild': FcpTypeInt, - 'ExtRevision': FcpTypeInt, - 'FcpVersion': FcpTypeFloat, - 'Testnet': FcpTypeBool, - }, - - #'Peer': # added later as PeerMessageParams - - 'PeerNote': { - 'NoteText': FcpTypeBase64EncodedString, - }, - - - #'NodeData': # added later as NodeMessageParams - #'ConfigData': # added later as ConfigMessageParams() - - 'TestDDAComplete': { - 'ReadDirectoryAllowed': FcpTypeBool, - 'WriteDirectoryAllowed': FcpTypeBool, - }, - 'PutFetchable': { - 'Global': FcpTypeBool, - }, - 'DataFound': { - 'Global': FcpTypeBool, - 'DataLength': FcpTypeInt, - }, - 'AllData': { - 'Global': FcpTypeBool, - #NOTE: we ignore startup and completion time here as long as it is not passed in all related messages - - }, - 'FinishedCompression': { - 'OriginalSize': FcpTypeInt, - 'CompressedSize': FcpTypeInt, - }, - 'SimpleProgress': { - 'Total': FcpTypeInt, - 'Required': FcpTypeInt, - 'Failed': FcpTypeInt, - 'FatalyFailed': FcpTypeInt, - 'Succeeded': FcpTypeInt, - 'Finalized': FcpTypeBool, - }, - 'PersistentRequestRemoved': { - 'Global': FcpTypeBool, - }, - 'PersistentRequestModified': { - 'Global': FcpTypeBool, - }, - 'PutFailed': { - 'Global': FcpTypeBool, - 'Code': FcpTypeInt, - }, - 'GetFailed': { - 'Code': FcpTypeInt, - 'ExpectedDataLength': FcpTypeInt_GetFailed_ExpectedDataLenght, - 'Fatal': FcpTypeBool, - 'FinalizedExpected': FcpTypeBool, - 'Global': FcpTypeBool, - }, - 'ProtocolError': { - 'Code': FcpTypeInt, - 'Global': FcpTypeBool, - }, - - 'IdentifierCollision': { - 'Global': FcpTypeBool, - }, - 'SubscribedUSKUpdate': { - 'Edition': FcpTypeInt, - }, - 'GetPluginInfo': { - 'Started': FcpTypeBool, - }, - - } - -MessageParamTypes['ClientPutDiskDir'] = MessageParamTypes['ClientPut'] -MessageParamTypes['ClientComplexDir'] = MessageParamTypes['ClientPut'] - -# TODO: "Started" param? Think we simply ignore it -MessageParamTypes['PersistentGet'] = MessageParamTypes['ClientGet'] -MessageParamTypes['PersistentPut'] = MessageParamTypes['ClientPut'] - - -MessageParamTypes['ModifyConfig'] = MessageParamTypes['ConfigData'] = ConfigMessageParams() - -MessageParamTypes['Peer'] = MessageParamTypes['AddPeer'] = PeerMessageParams - - - - - - - - - - - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-04 03:14:45
|
Revision: 130 http://fclient.svn.sourceforge.net/fclient/?rev=130&view=rev Author: jurner Date: 2008-02-03 19:14:49 -0800 (Sun, 03 Feb 2008) Log Message: ----------- added cosnst Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-04 03:14:24 UTC (rev 129) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-04 03:14:49 UTC (rev 130) @@ -296,6 +296,7 @@ class MessageStatus: + Null = 0x0 Pending = 0x1 Compressing = 0x2 Started = 0x4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-06 11:13:23
|
Revision: 162 http://fclient.svn.sourceforge.net/fclient/?rev=162&view=rev Author: jurner Date: 2008-02-06 03:13:27 -0800 (Wed, 06 Feb 2008) Log Message: ----------- adapt Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-06 11:13:03 UTC (rev 161) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-06 11:13:27 UTC (rev 162) @@ -333,7 +333,7 @@ PutDiskDir = 0x10 PutComplexDir = 0x20 - GenerateSSKKeypair = GenerateKeypair = 0x1000 + GenerateSSKKeypair = 0x1000 GenerateUSKKeypair = 0x2000 PluginInfo = 0x2000000 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-08 13:35:05
|
Revision: 183 http://fclient.svn.sourceforge.net/fclient/?rev=183&view=rev Author: jurner Date: 2008-02-08 05:35:03 -0800 (Fri, 08 Feb 2008) Log Message: ----------- docs Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 13:34:41 UTC (rev 182) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 13:35:03 UTC (rev 183) @@ -294,7 +294,7 @@ class RequestStatus: """Request status flags @cvar Null: no status - @cvar Pending: the request is not started yet + @cvar Pending: the request was fed to the client (not set for restored requests) @cvar Compressing: the request is about to be compressed @cvar Compressed: compressing is completed @cvar Success: the request has completed successfuly This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2008-02-08 18:53:29
|
Revision: 189 http://fclient.svn.sourceforge.net/fclient/?rev=189&view=rev Author: jurner Date: 2008-02-08 10:53:33 -0800 (Fri, 08 Feb 2008) Log Message: ----------- fix Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_consts.py Modified: trunk/sandbox/fcp/fcp2_0_consts.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 18:53:10 UTC (rev 188) +++ trunk/sandbox/fcp/fcp2_0_consts.py 2008-02-08 18:53:33 UTC (rev 189) @@ -294,7 +294,7 @@ class RequestStatus: """Request status flags @cvar Null: no status - @cvar Pending: the request was fed to the client (not set for restored requests) + @cvar Restored: the request was restored when the client was started @cvar Compressing: the request is about to be compressed @cvar Compressed: compressing is completed @cvar Success: the request has completed successfuly @@ -305,14 +305,11 @@ @cvar RemovedFromQueue: the request is no longer present in the nodes queue. The client will remove the request from its own queue as soon as all event listeners have been notified. - @cvar MaskProcessed: bitmask checking if a request is completely processed (either - successfuly completed or completed with an error or removed) - @note: the FcStatus member of the params dict of a request should contain one or more of the bitflags it picked up while running through the client. """ Null = 0x0 - Pending = 0x1 + Restored = 0x1 Compressing = 0x2 Compressed = 0x4 Success = 0x8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |