Commit Graph

141 Commits

Author SHA1 Message Date
Adam Rocska 4064df3762 Finished hacking. I hope I'll have time for this library in the close future. I want to make it great.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-11 11:09:57 +02:00
Adam Rocska 7b487ccc60 In its current state this hackery fits our needs.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-11 10:22:15 +02:00
Adam Rocska c9bee263df Massaaged out this netmasking thingy. I had to reverse engineer with running other libraries, but now it seems to work. I'll follow the route of reversing using the java, C#.net, and php libraries. PHP is the driver, because the whole maxmind "solution" smells php from a mile away...
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-10 22:44:18 +02:00
Adam Rocska 7ca52178dd Library starts to come into its place. I gotta go through the models & records once again, because de-phpification is pretty hard. Besides that it's all cool and usable so far.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-10 12:37:38 +02:00
Adam Rocska c4a0ce5960 Added the IpAddress netmask exposure. CIDR string my ass. This is no php.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-10 12:08:31 +02:00
Adam Rocska 7b85c3b56c Implemented bitwise operators for IpAddress. This will be handy if someone wants to go wild with Ip subnetting, masking, grouping, etc.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-09 23:01:21 +02:00
Adam Rocska 2f43056d0a IpAddress now has netmask initializers. There's no point in implementing a awhole ip range, or network or any other type, as technically at the end of the day, the maxmind php scripters only return a network mask as a new information in their CIDR voodoo.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-09 22:35:02 +02:00
Adam Rocska 6abcb9669a Made the IpAddress comparable, which is the front door to the type IpRange.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-07 21:33:46 +02:00
Adam Rocska d646b47877 System tests ready for execution. Before coverage I'll take another round in the php rat hole to make sure all models are ok.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-05 16:09:44 +02:00
Adam Rocska d662ad3d22 Until CLIon supports newer Swift, and Swift Package Manager versions, and SPM fixes https://bugs.swift.org/browse/SR-12912 I opt in to doing this hackery for test resources.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-05 13:45:28 +02:00
Adam Rocska 2cd55ef5ab Reorganized Tests
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-04 17:31:24 +02:00
Adam Rocska f5b45e7e69 Reader coverage.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-04 14:35:45 +02:00
Adam Rocska 62484d2cae Work in progress. A pretty neat pattern is emerging.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-04 13:47:18 +02:00
Adam Rocska e1a5976007 Committing the complete mess. I managed to trial&error on converting the php fantasy dictionaries into structs. Though some of the field types are mere blind guesses, so fingers crossed.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-02 16:38:44 +02:00
Adam Rocska 1bf6817aab Data can be read nicely. Next stop : Finish the API layer. Once done :
- clean up the tests
 - refactor parts of the source
 - find additional optimization opportunities. I don't like the slow init.
 - document
 - tell the world it's done

Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-01 14:29:02 +02:00
Adam Rocska aa6d2958c7 I couldn't let this whole repo go. Eventually I solved the slow index buildup with a lazy normalizataion & solved the one last blocker of properly querying the databases. From a functionality perspective I guess it's complete. Now I gotta:
- clean up the tests
 - refactor parts of the source
 - find additional optimization opportunities. I don't like the slow init.
 - document
 - tell the world it's done

Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-06-01 12:11:54 +02:00
Adam Rocska 4fe0745b4c Intentionally committing crap code.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 22:08:07 +02:00
Adam Rocska 7094fa0a5d Renamed the Index module to IndexReader in hope that it'll help me resolve this small generic issue I have here.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 20:34:28 +02:00
Adam Rocska 937587ed92 Simplified formatting.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 17:59:58 +02:00
Adam Rocska c073af2ec4 Renamed the Metadata internal module to MetadataReader. Hopefully it'll make imports a bit more comfortable.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 17:52:47 +02:00
Adam Rocska aa11b7c118 sonar scan trigger
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 17:02:25 +02:00
Adam Rocska 6cc0926362 Trying to get a grab on the bull's horn somehow.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 16:59:39 +02:00
Adam Rocska 9827635299 Added GeoLite DB files for testing purposes. Totally not cool for "unit" testing, but I gotta validate the concepts somehow. Tests will be refactored.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-30 16:54:59 +02:00
Adam Rocska 0e44b9422e Provided a few dumb tests for InMemoryReader and I just realized, that it's not even specific to "in memory-ness". It should work with anything.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-29 22:16:04 +02:00
Adam Rocska f2b8c48df5 Reader protocol and foundations for DBReader's testability.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-29 21:37:38 +02:00
Adam Rocska 1974c1744d Removed maxmind "branding" from repository wherever it was legally possible.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-28 15:49:56 +02:00
Adam Rocska f3b1e5ceaf Put a primitive assertion in place just to hold my ass until the library comes together. Will make the tests professional & sexy at a later point.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-28 15:41:26 +02:00
Adam Rocska c7c3ab44db Ok, the repo is somewhat exploded at this point. BUT IT WORKS! Now I only gotta provide proper tests instead of the trashy ones, put together the reader & serializer, and represent this maxmind php fantasy crap with some nice Structs. And then the saga is over for now.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-28 14:23:26 +02:00
Adam Rocska d7387c8845 Able to decode sequential types
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-27 20:07:25 +02:00
Adam Rocska 7b40c52c9d Found a bug. I was an unattentive prick & assumed some clean logic in the definition size resolution algorithm. I shouldn't have. Now it's cool.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-27 15:26:33 +02:00
Adam Rocska c645dd40c4 Created the intentional duplicate of interpretArray. Intenional duplicate, because I know nothing about this php and perl scripter mountebank fantasy data type.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-27 09:44:54 +02:00
Adam Rocska 3bd97a83f1 Array interpretation in place, the logic seems to work. Gotta duplicate the data cache container, because there's no word in the spec, nor guarantee that its array-like structure related assumptions are correct.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-27 08:58:55 +02:00
Adam Rocska 5bcd7ba700 This awful design seems to be able to tackle php scripter stupidity. The code sucks, but at least is testable and works so far. Now I just gotta reconstruct sequence types, and I finally can forget about this horror, and stop taking sedatives.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-26 16:43:56 +02:00
Adam Rocska 8bbcfb3d3b Data padding added. Necessary code to handle php retardnesss of having 32bit integers defined in 0, 1, 2, 3 bytes...
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-20 17:44:19 +02:00
Adam Rocska 13fdc79bf9 Attempting a different way of typeconversion in hope, that we can handle the php scripter style stupidifaction of 11bit integers, and God knows what other retarded concepts can arise.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-19 14:51:32 +02:00
Adam Rocska ac0abc8607 WIP. Total mess.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-18 13:48:36 +02:00
Adam Rocska f6ab2f4cac Attempting another different approach.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-18 00:26:10 +02:00
Adam Rocska 966928cfd2 Falling back to the original crap code that emerged from crap php scripters' logic. Too many edge cases and stupidities to bother with. Dumb design can't be made straight.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-17 19:49:15 +02:00
Adam Rocska ddd782925d DataType foundations re-implemented. Can guess from this convoluted unclear non-unequivocal php scripter's fantasy the type of the data.
I must say, that it's outrageously stupid, that with this control byte data type definition the scripters "designed" implicitly allows for two different ways of defining map types. One is [0b111X_XXXX] and the other is [0b000X_XXXX, 0b0000_0000], where both resolve to fantasy 7 with that fucking retarded logic, though are not equal.

Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-16 18:24:06 +02:00
Adam Rocska 2969e82f3f isExtendedType implemented for DataType enum value
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-16 16:44:12 +02:00
Adam Rocska f02cb01293 Gotta redesign the whole decoder layer. Managed to sketch a way to tackle with these php scripter fantasies in the MaxMind DB spec on the whiteboard.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-16 15:09:22 +02:00
Adam Rocska 057f29110a MaxMindPointer needs to also be castable to int. This whole typecasting crap should be fixed at some point, if I figure out how to de-phpify the spec.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 15:26:55 +02:00
Adam Rocska 2ec6980964 MaxMind Iterator now supports peek, an operation to seek control bytes, and binary data without modifying the pointer's state. Useful for MaaxMind's pointer lookup.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 13:19:26 +02:00
Adam Rocska 97407b3520 I figured out, that there's no case when Data would be nil.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 12:29:02 +02:00
Adam Rocska e98405eaf7 Provided a test for the control byte skipping case.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 11:46:57 +02:00
Adam Rocska 09c5d36736 Dummy code in place.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 10:38:36 +02:00
Adam Rocska 3d372ee48b Lookup edge cases.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 10:32:12 +02:00
Adam Rocska 24b51db462 Preparing the iterator for automatic pointer resolution.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-15 09:34:56 +02:00
Adam Rocska 52adc7d958 Any decoder extended to decode MaxMindPointer values.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-14 20:47:12 +02:00
Adam Rocska a67bb082c5 MaxMind Pointer Decoder somewhat implemented. But this whole spiel with control bytes & things is insane. Code is as inconsistent as the spec.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
2020-05-14 20:19:28 +02:00