Open elazarg opened 2 months ago
We may need to use ordered maps instead of hash maps, so the lists of partitions are consistently ordered.
Added an elaborated README, and changed implementation of MultiMap to use HashSet.
BTW, I think the class ICMP is better named ICMPRule, and is a set. The file icmp.go in the netp package should only have functions that are related to ICMP proper. Such change would also solve the need to expose implementation details of the ICMP class to the ICMPSet class.
@adisos is there anything left for me to implement/document so this PR can be merged?
@adisos is there anything left for me to implement/document so this PR can be merged?
added few small comments, still reviewing the tests and some implementation details.
I've improved and fixed the documentation of interface.go. @adisos please re-review this part.
Additionally, I've improved the interval package.
interval:
intervalset:
I think it's better to make GenericInterval
and GenericCanonicalSet
as generic types (with integral constraints), so clients can choose whether or not to rely on things like Size()
being 64bit integer. interval.Interval
should be an alias to GenericInterval[int]
, and interval.Set should be an alias to GenericCanonicalSet[int]
.
Decompose the data structures into domain-specific and generic data structures.
The
ds
package has zero dependencies, and it knows nothing about numbers or network.Interfaces (all in
interfaces.go
):Implementations:
HashMap
- a simple adapter around a go map, allowingHashable
keys.HashSet
MultiMap
is a non-injective map. It gives a simple "inverse" on a HashMap.ProductLeft
and ProductRightis a map-based implementation of a cartesian product; it implementsProduct
as a one-to-one mapping from sets to sets, where each key-value pairs encodes the cross product of its two items.TripleSetLeft
andTripleSetRight
andTripleSetOuter
are right-, left- and outer-associative implementations ofTripleSet
.DisjointSum
is tagged-union of two sets. Go's generics place some limitations on the implementation; The empty element must always be explicitly passed to the constructor.UnitSet
is an idea - using sets of size 1 as the identity element of Product. It's probably not really helpful.The
interval
package hasinterval
andintervalset
. Nothing particularly new about them.netp
is unchanged.The
netset
package is where handles sets of network elements.ICMPSet
is largely the one proposed in #23.IPBlock
is adapted to implementSet
.TCPUDPSet
is aTripleSet
ofProtocolSet
xPortSet
xPortSet
TransportSet
is a disjoint union ofTCPUDPSet
+ICMPSet
ConnectionSet
is aTripleSet
ofIPBlock
xIPBlock
xTransportSet
The package
connection
now contains the state-aware connectionset (namedSet
), and its json-formatting. In my opinion it should be moved to the analyzer.Many tests are adapted.
but some data structures do not have dedicated tests.There is no implementation of a dynamically-bounded tuple, since I could not find the proper way to fit that into a generic datastructure with a well defined degenerate edge case.
The diff is probably not useful; it should be easier to read the code.