diff --git a/conntrackt/models.py b/conntrackt/models.py --- a/conntrackt/models.py +++ b/conntrackt/models.py @@ -301,3 +301,31 @@ class Communication(models.Model): """ return "Edit" + + def source_representation(self): + """ + Produces string representation of communication that includes only the + source interface information. + + The method is useful where the destination context is well known. + + Returns: + Communication representation that includes only information about + the source interface. + """ + + return "%s - %s: %d" % (self.source, self.protocol, self.port) + + def destination_representation(self): + """ + Produces string representation of communication that includes only the + destination interface information. + + The method is useful where the source context is well known. + + Returns: + Communication representation that includes only information about + the destination interface. + """ + + return "%s - %s: %d" % (self.destination, self.protocol, self.port)