fix: gen_multi2 使用真实公网IP,GeoIP可解析
根因: 服务器IP(203.0.113.x等RFC5737)和代理IP(10.0.x.x私有)无法被GeoIP解析 → 500条边仅2条两端有坐标 → 图上不显示 修复: - 服务器IP: 替换为 Akamai/Cloudflare/Google/AWS/Microsoft 公网IP - 代理IP: 替换为 1.1.1.1/8.8.8.8 等已知DNS公网IP - 移除硬编码SERVER_GEO,依赖MMDB自动解析 结果: 710/718节点有坐标, 496/500边两端可渲染 → 300条边显示 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+19
-39
@@ -35,15 +35,15 @@ from gen_test_data import (
|
||||
# When a row has a given snam/cnam, its :ipd is replaced with one of these IPs.
|
||||
# This creates realistic topology — servers have high in-degree.
|
||||
|
||||
# CDN: 3 edge nodes in different regions
|
||||
CDN_IPS = ['203.0.113.10', '203.0.113.11', '203.0.113.12']
|
||||
API_IPS = ['198.51.100.20', '198.51.100.21']
|
||||
MAIL_IPS = ['192.0.2.50', '192.0.2.51']
|
||||
AUTH_IPS = ['10.20.30.40']
|
||||
SOCIAL_IPS = ['172.16.100.10']
|
||||
STORAGE_IPS = ['198.51.100.50']
|
||||
STREAM_IPS = ['203.0.113.50', '203.0.113.51']
|
||||
SEARCH_IPS = ['198.51.100.60']
|
||||
# CDN: 3 edge nodes in different regions (Akamai/Cloudflare ranges)
|
||||
CDN_IPS = ['23.0.5.10', '104.16.100.10', '151.101.1.10']
|
||||
API_IPS = ['52.84.100.20', '54.230.100.20'] # Amazon CloudFront
|
||||
MAIL_IPS = ['74.125.200.26', '66.102.1.26'] # Google mail
|
||||
AUTH_IPS = ['40.126.32.100'] # Microsoft Azure
|
||||
SOCIAL_IPS = ['157.240.1.35'] # Facebook
|
||||
STORAGE_IPS = ['52.216.100.50'] # Amazon S3
|
||||
STREAM_IPS = ['52.84.200.50', '54.192.200.50'] # Amazon CloudFront
|
||||
SEARCH_IPS = ['142.250.80.4'] # Google
|
||||
|
||||
SNAM_TO_IPS = {
|
||||
'cdn.example.com': CDN_IPS,
|
||||
@@ -75,25 +75,15 @@ ALL_SERVER_IPS = list(set(
|
||||
ip for pool in SNAM_TO_IPS.values() for ip in pool
|
||||
))
|
||||
|
||||
# Server IP → geo info (so GeoIP columns match when we remap :ipd)
|
||||
SERVER_GEO = {
|
||||
'203.0.113.10': {'lat': 37.77, 'lon': -122.42, 'city': 'San Francisco', 'country': 'us', 'isp': 'AT&T', 'org': 'Amazon.com Inc.'},
|
||||
'203.0.113.11': {'lat': 40.71, 'lon': -74.00, 'city': 'New York', 'country': 'us', 'isp': 'Verizon', 'org': 'Google LLC'},
|
||||
'203.0.113.12': {'lat': 51.51, 'lon': -0.13, 'city': 'London', 'country': 'gb', 'isp': 'BT Group', 'org': 'Microsoft Corp.'},
|
||||
'198.51.100.20': {'lat': 31.23, 'lon': 121.47, 'city': 'Shanghai', 'country': 'cn', 'isp': 'China Mobile','org': 'Tencent'},
|
||||
'198.51.100.21': {'lat': 39.90, 'lon': 116.40, 'city': 'Beijing', 'country': 'cn', 'isp': 'China Telecom','org': 'Alibaba Inc.'},
|
||||
'192.0.2.50': {'lat': 37.77, 'lon': -122.42, 'city': 'San Francisco', 'country': 'us', 'isp': 'AT&T', 'org': 'Google LLC'},
|
||||
'192.0.2.51': {'lat': 50.11, 'lon': 8.68, 'city': 'Frankfurt', 'country': 'de', 'isp': 'Deutsche Telekom', 'org': 'Meta Platforms'},
|
||||
'10.20.30.40': {'lat': 40.71, 'lon': -74.00, 'city': 'New York', 'country': 'us', 'isp': 'Verizon', 'org': 'Microsoft Corp.'},
|
||||
'172.16.100.10': {'lat': 37.77, 'lon': -122.42, 'city': 'San Francisco', 'country': 'us', 'isp': 'AT&T', 'org': 'Meta Platforms'},
|
||||
'198.51.100.50': {'lat': 40.71, 'lon': -74.00, 'city': 'New York', 'country': 'us', 'isp': 'Verizon', 'org': 'Amazon.com Inc.'},
|
||||
'203.0.113.50': {'lat': 1.35, 'lon': 103.82, 'city': 'Singapore', 'country': 'sg', 'isp': 'Singtel', 'org': 'Netflix Inc.'},
|
||||
'203.0.113.51': {'lat': 35.68, 'lon': 139.76, 'city': 'Tokyo', 'country': 'jp', 'isp': 'NTT', 'org': 'Apple Inc.'},
|
||||
'198.51.100.60': {'lat': 37.77, 'lon': -122.42, 'city': 'San Francisco', 'country': 'us', 'isp': 'AT&T', 'org': 'Google LLC'},
|
||||
}
|
||||
|
||||
# Proxy IPs — high out-degree (appear as :ips connecting to many servers)
|
||||
PROXY_IPS = ['10.0.1.1', '10.0.2.1', '10.0.3.1', '10.0.4.1', '10.0.5.1']
|
||||
# Proxy IPs — public IPs resolvable by GeoIP MMDB
|
||||
# MUST be public IPs that GeoIP can resolve (no private ranges!)
|
||||
PROXY_IPS = [
|
||||
'1.1.1.1', # Cloudflare DNS — US-West
|
||||
'8.8.8.8', # Google DNS — US-West
|
||||
'223.5.5.5', # AliDNS — CN
|
||||
'208.67.222.222', # OpenDNS — US-East
|
||||
'77.88.8.8', # Yandex DNS — EU
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
@@ -179,17 +169,7 @@ def main():
|
||||
row[':ips'] = random.choice(PROXY_IPS)
|
||||
row['client-ip'] = row[':ips']
|
||||
|
||||
# Update GeoIP columns to match server location
|
||||
geo = SERVER_GEO.get(dst_ip)
|
||||
if geo:
|
||||
rlat = round(geo['lat'] + random.uniform(-0.3, 0.3), 6)
|
||||
rlon = round(geo['lon'] + random.uniform(-0.3, 0.3), 6)
|
||||
row[':ipd.latd'] = str(rlat)
|
||||
row[':ipd.lond'] = str(rlon)
|
||||
row[':ipd.city'] = geo['city']
|
||||
row[':ipd.ispn'] = geo['isp']
|
||||
row[':ipd.orgn'] = geo['org']
|
||||
row['dcnt'] = geo['country']
|
||||
# GeoIP: use MMDB in upload flow; CSV lat/lon are ignored anyway
|
||||
|
||||
file_rows.append(row)
|
||||
degree_src[row[':ips']] += 1
|
||||
|
||||
Reference in New Issue
Block a user