Created
June 18, 2018 06:20
-
-
Save qnnnnez/64b3af6c208aee62ec383ea5ee5f13ac to your computer and use it in GitHub Desktop.
V2Ray geoip.dat and geosite.dat generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import config_pb2 | |
geoiplist = config_pb2.GeoIPList() | |
geoip = geoiplist.entry.add() | |
geoip.country_code = 'CN' | |
for l in open('china_ip_list.txt', 'r').readlines(): | |
l = l.strip() | |
network, prefix = l.split('/') | |
cidr = geoip.cidr.add() | |
cidr.prefix = int(prefix) | |
cidr.ip = socket.inet_aton(network) | |
open('china-ip-list.dat', 'wb').write(geoiplist.SerializeToString()) | |
geositelist = config_pb2.GeoSiteList() | |
geosite = geositelist.entry.add() | |
geosite.country_code = 'CN' | |
for l in open('accelerated-domains.china.raw.txt', 'r').readlines(): | |
l = l.strip() | |
domain = geosite.domain.add() | |
domain.type = 2 | |
domain.value = l | |
open('dnsmasq-china-list.dat', 'wb').write(geositelist.SerializeToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
config_pb2.py is generated by protoc using v2ray-core/app/router/config.proto
china_ip_list.txt and accelerated-domains.china.raw.txt are from china-ip-list and dnsmasq-china-list, respectively.