class ASNSchema1(metaclass=Schema): name = f'Schema: Netblock, IP, Country and ASN' Header = IPandASN SchemaIP = SchemaObject(IP, mapping={IP.IP: Header.ip}) SchemaNetBlock = SchemaObject( Netblock, mapping={Netblock.Netblock: Header.Announced_Prefix}) SchemaCountry = SchemaObject(Country, mapping={Country.Country: Header.Country}) SchemaCountry.set_properties( image_source=IPandASN.Country_flag.system_name) SchemaAutonomousSystem = SchemaObject( AutonomousSystem, mapping={AutonomousSystem.ASN: Header.ASN}) Connection = IPToNetblock.between(SchemaIP, SchemaNetBlock, {}, [ Condition(Header.ip, Operations.NotEqual, ''), Condition(Header.Announced_Prefix, Operations.NotEqual, '') ]) LinkNetblockToAutonomousSystem = NetblockToAutonomousSystem.between( SchemaNetBlock, SchemaAutonomousSystem, {}, [ Condition(Header.ip, Operations.NotEqual, ''), Condition(Header.ASN, Operations.NotEqual, '') ]) LinkAutonomousSystemToCountry = AutonomousSystemToCountry.between( SchemaAutonomousSystem, SchemaCountry, mapping={AutonomousSystemToCountry.Value: Header.ASN_Name})
class NamecoinDomainIPBlock(metaclass=Schema): name = 'Namecoin schema: Netblock, Domain and IP' Header = NamecoinDomainExplorer SchemaIP = SchemaObject(IP, mapping={IP.IP: Header.ip}) SchemaDomain = SchemaObject(Domain, mapping={Domain.Domain: Header.domain}) Block = Netblock.schematic(Header) Connection = IPToNetblock.between(SchemaIP, Block, {}, [ Condition(Header.ip, Operations.NotEqual, ''), Condition(Header.Netblock, Operations.NotEqual, '') ]) SchemaIPToDomain = IPToDomain.between( SchemaIP, SchemaDomain, mapping={IPToDomain.Resolved: Header.date_time}, conditions=[not_empty(Header.domain), not_empty(Header.ip)])
class NamecoinDomainIPBlock(metaclass=Schema): name = f'Namecoin schema: Netblock, IP {Constants.RIGHTWARDS_ARROW} Domain' Header = NamecoinDomainExplorer SchemaIP = SchemaObject(IP, mapping={IP.IP: Header.ip}) SchemaDomain = SchemaObject(Domain, mapping={Domain.Domain: Header.domain}) SchemaBlock = SchemaObject(Netblock, mapping={Netblock.Netblock: Header.Netblock}) Connection = IPToNetblock.between(SchemaIP, SchemaBlock, {}, [ Condition(Header.ip, Operations.NotEqual, ''), Condition(Header.Netblock, Operations.NotEqual, '') ]) SchemaIPToDomain = IPToDomain.between( SchemaIP, SchemaDomain, mapping={IPToDomain.Resolved: Header.date_time}, conditions=[not_empty(Header.domain), not_empty(Header.ip)])
class NamecoinDomainBlocksExtended(metaclass=Schema): name = f'Namecoin schema: Netblock, IP {Constants.RIGHTWARDS_ARROW} Domain (ext.)' Header = NamecoinDomainExplorer SchemaIP = SchemaObject(IP, mapping={IP.IP: Header.ip}) SchemaDomain = SchemaObject(Domain, mapping={Domain.Domain: Header.domain}) SchemaTxid = SchemaObject(NamecoinTXid, mapping={ NamecoinTXid.txid: Header.txid, NamecoinTXid.txid_short: Header.short_txid }) SchemaBlock = SchemaObject(Netblock, mapping={Netblock.Netblock: Header.Netblock}) Connection = IPToNetblock.between(SchemaIP, SchemaBlock, {}, [ Condition(Header.ip, Operations.NotEqual, ''), Condition(Header.Netblock, Operations.NotEqual, '') ]) SchemaIPToDomain = IPToDomain.between( SchemaIP, SchemaDomain, mapping={IPToDomain.Resolved: Header.date_time}, conditions=[not_empty(Header.domain), not_empty(Header.ip)]) SchemaTxidToDomain = NamecoinTXidToDomain.between( SchemaTxid, SchemaDomain, mapping={NamecoinTXidToDomain.DateTime: Header.date_time}, conditions=[not_empty(Header.domain)]) SchemaTxidToIP = NamecoinTXidToIP.between( SchemaTxid, SchemaIP, mapping={NamecoinTXidToIP.DateTime: Header.date_time}, conditions=[not_empty(Header.domain), not_empty(Header.ip)])
def not_empty(field: Field): return Condition(field, Operations.NotEqual, '')
def check_direction_2(field: Field): return Condition(field, Operations.Equals, 2)