hadiasghari / pyasn

Python IP address to Autonomous System Number lookup module. (Supports fast local lookups, and historical lookups using archived BGP dumps.)
Other
275 stars 71 forks source link

AssertionError while converting RIB #76

Closed ct-wei closed 11 months ago

ct-wei commented 11 months ago

I just found the error when I try to convert the rib to dat. mrtx.dump_prefixes_to_file(prefixes, args.single[1], args.single[0]) fw.write('; IP-ASN32-DAT file\n; Original source: %s\n' % source_description) UnicodeEncodeError: 'ascii' codec can't encode characters in position 60-61: ordinal not in range(128)

it seems the older rib data can work perfectly, while the new rib data can't. like: rib.20230803.2200.bz2 Is it the data's wrong or code bug?

hadiasghari commented 11 months ago

Hi @ct-wei. Can you provide some extra information to help with troubleshooting/replication:

ct-wei commented 11 months ago

Thanks for reply! rib data is from http://archive.routeviews.org/route-views6/bgpdata/2023.08/RIBS/ the command is pyasn_util_convert.py --single rib.20230803.2200.bz2 test.dat

hadiasghari commented 11 months ago

That file and command work without any problems for me--here is my output:

$ pyasn_util_convert.py --single rib.20230803.2200.bz2 test.dat
Parsing MRT/RIB archive ..  MrtTD2Record (PEER-INDEX-TABLE, collector 2162111344, 74 peers)
  MRT record 100000 @4s
  MRT record 200000 @9s
IPASN database saved (0 IPV4 + 200024 IPV6 prefixes)

Perhaps try downloading the RIB file again. If it's still not resolved, please tell me your Python & pyasn versions.

ct-wei commented 11 months ago

That file and command work without any problems for me--here is my output:

$ pyasn_util_convert.py --single rib.20230803.2200.bz2 test.dat
Parsing MRT/RIB archive ..  MrtTD2Record (PEER-INDEX-TABLE, collector 2162111344, 74 peers)
  MRT record 100000 @4s
  MRT record 200000 @9s
IPASN database saved (0 IPV4 + 200024 IPV6 prefixes)

Perhaps try downloading the RIB file again. If it's still not resolved, please tell me your Python & pyasn versions.

Oh it seems work.Thanks a lot!😊