{"id":196,"date":"2021-01-11T21:33:00","date_gmt":"2021-01-12T02:33:00","guid":{"rendered":"http:\/\/sycured.127.0.0.1.sslip.io\/?p=196"},"modified":"2024-01-13T19:57:48","modified_gmt":"2024-01-14T00:57:48","slug":"rbl-checker-refacto","status":"publish","type":"post","link":"http:\/\/10.42.0.68:8080\/blog\/rbl-checker-refacto","title":{"rendered":"RBL-Checker: details on the refactorization"},"content":{"rendered":"\n
A long time ago, I wrote RBL-Checker<\/a>, a tool to check if a range IP is blacklisted or not.<\/p>\n\n\n\n I continue to use it but need a lot more complete and that integrate better in my use case.<\/p>\n\n\n\n In this post, you’ll learn:<\/p>\n\n\n\n I wrote the first version at home when I worked for a hosting provider. This company never sees the ROI to build this style of little software.<\/p>\n\n\n\n I can’t tell you that I liked this manager when I needed to debug one email server with a very high queue with nothing about metrology, detection of a blacklist, exclusively reading the log without an ELK or similar.<\/p>\n\n\n\n Right now, I continue to have my email servers so I use my software but also for any clients that need to monitor and alert on them.<\/p>\n\n\n\n My future use case can be for a non-profit IAP because it’s very important to keep range IP clean and be alerted when an IP becomes blacklisted.<\/p>\n\n\n\n My first version was in Python<\/a> and I continue in that way.<\/p>\n\n\n\n I moved from a service that uses subprocess to do check-in concurrency to 2 services because I need to check very quickly a large range of IP.<\/p>\n\n\n\n Asynchronous service taking a message from the queue and checking IP across the list<\/a>. I use it exclusively to add range to publish the message to the queue. The biggest move can be a migration to Haskell but right now, I don’t need it.<\/p>\n\n\n\n Migrating from JSON to binary format and in that case, I see these possibilities:<\/p>\n\n\n\n AIOPG<\/a> is asynchronous compared to psycopg2<\/a>.<\/p>\n\n\n\n I use PostgreSQL<\/a> and Yugabyte<\/a>, both can be used with PostgreSQL’s drivers so it was my choice to stay with classic<\/em> database that can be pushed in production very easily and won’t be a pain.<\/p>\n\n\n\n Also, public cloud providers provide managed PostgreSQL (like Amazon RDS for PostgreSQL <\/a>) so it’s easy to deploy.<\/p>\n\n\n\n One year ago, I left Flask<\/a> for FastAPI<\/a>.<\/p>\n\n\n\n It permits to build async rest api and provides OpenAPI<\/a> with Swagger UI<\/a> and ReDoc<\/a> by default.<\/p>\n\n\n\n Deploying Python-based software it’s very easy and compatible with every CPU architecture (ARM, RISC-V, x86).<\/p>\n\n\n\n I have one Kafka<\/a> cluster running so I continue to use my actual stack and I won’t add a new service (NATS<\/a> & co) for this little job and nothing more.<\/p>\n\n\n\n I activated compression on the producer<\/a> (lz4<\/a>) to gain disk space.<\/p>\n\n\n\n Some cloud providers provide Kafka or Kafka compatible managed service so it’s very easy to deploy and you don’t need to manage it.<\/p>\n","protected":false},"excerpt":{"rendered":" A long time ago, I wrote RBL-Checker, a tool to check if a range IP is blacklisted or not. I continue to use it but need a lot more complete and that integrate better in my use case. In this post, you’ll learn: My use case I wrote the first version at home when I […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[28],"tags":[11,29],"_links":{"self":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/196"}],"collection":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":1,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":197,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/196\/revisions\/197"}],"wp:attachment":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
My use case<\/h2>\n\n\n\n
My choice<\/h2>\n\n\n\n
From monolith to 2 services<\/h3>\n\n\n\n
Consumer<\/h4>\n\n\n\n
Finally, add blacklisted IP with the blacklist name and DateTime of the check to the database.<\/p>\n\n\n\nRest API<\/h4>\n\n\n\n
Maybe later, I’ll add an endpoint to know how many messages are in the queue.<\/p>\n\n\n\nPossible big change<\/h4>\n\n\n\n
\n
The stack<\/h3>\n\n\n\n
AIOPG<\/h4>\n\n\n\n
FastAPI<\/h4>\n\n\n\n
Kafka<\/h4>\n\n\n\n