now that Mastodon has api/v1/instance/peers I want to write a script to do some analysis of what autonomous systems Mastodon instances are distributed across

Cymru provides a IP -> ASN lookup service so I could use that

(at least from this instance's perspective)

@staticsafe and then see which sites lack AAAA records but are on ASNs that announce #IPv6 space.

@nivex might be a good way to test which instances publish a AAAA record but have broken IPv6 connectivity as well 🤔

it'll give me a chance to play with JSON data using Python

should be fun, I'll probably get started tomorrow

also if you open that API endpoint in Firefox, it gives you a nicely formatted view of the output

nice, that's cool

@staticsafe firefox only very recently started doing this and the first time i saw it happen i was like woooaaaahhh

dealing with JSON seems fairly straightforward in Python 3

so I reckon I'm gonna need the following imports:

json, requests, dnspython (for interfacing with the Cymru IP-to-ASN thing - )

actually doesn't look like I need dnspython, I can use GNU netcat to feed a file of IPs to the Cymru WHOIS server

$ netcat 43 < list01 | sort -n > list02

also need socket I guess to resolve the instance hostnames into IPs


welcome to "Sadiq thinks out how he's going to write some code aloud on the TL"

@staticsafe ah yes the "public debugging" method. very tactful

I already have PyCharm installed but I should get a IPython[0] development environment going, that interactive shell is so good

[0] -

returns a list object

In [9]: type(r.json())
Out[9]: list

google pls stop returning python 2 documentation links thanks

@staticsafe Google python3

Did you mean Python 2?


friends don't let friends write Python 2 code in 2017

@staticsafe we have users at work that still run Python 2.6 (because centos) and I despair every time

well in 2018 too and anytime in the future

say no to python 2

gaierror: [Errno -5] No address associated with hostname

dead instances, I need a way to clean the list I get from the API

...: except:
...: print('ASN not found for IP: ' + z)
ASN not found for IP:

lmao some of the instances in the list I'm using have those A records

guess I should cleanup the iplist list more

another interesting one, the subnet is not being announced:

ASN not found for IP:

In [34]: asnlist.count(16276)
Out[34]: 199

199 in the list in AS16276 aka OVH

In [35]: asnlist.count(12876)
Out[35]: 138

138 in AS12876 aka

@staticsafe don't take this the wrong way but this conversation is making me very warm 😅

In [36]: asnlist.count(63949)
Out[36]: 71

71 in 63949 aka Linode

okay I think I've worked out a proof of concept inside IPython, time to actually write the script out

@staticsafe I will 😛. I don’t want to port the whole legacy project to Python 3.

@staticsafe i think a corollary of this is "don't let your friends use old CentOS versions in 2017"


unfortunately.... *cries quietly on the inside*

@staticsafe I started calling it python and legacy python.

@staticsafe they should have named it python++ to make it easy to Google *runs*

@Canageek @staticsafe uhh, i think that name has already been used ( for a binding generator or something, iirc? ) 🤷

@Canageek @staticsafe pick a pack of CPickled,... wait is that still a thing in 3? iiiii forget.....

@staticsafe maybe the filter bubble knows you're secretly a python 2 user

@staticsafe Yeah, requests is awesome.

Kenneth Reitz's work is pretty amazing.

@staticsafe @angristan You're welcome. Of course, yo ucan do you thing by yourself (it's always a good idea multiplying sources and informations. Errors can happen :/ )

I'm sure you can do a better for providers, especially with your method (with So don't hesitate :)

Sign in to participate in the conversation

staticsafe's personal Mastodon instance.