@@ -59,10 +59,26 @@ def check_seed(x):
59
59
else :
60
60
print (f"\x1b [91mFAIL\x1b [0m { x } " )
61
61
62
- def has_answer_section (domain ):
62
+ def get_combinations (services ):
63
+
64
+ all_flags = services .values ()
65
+ all_combinations = []
66
+
67
+ for i in range (1 , len (all_flags ) + 1 ):
68
+ for combo in combinations (all_flags , i ):
69
+ combination_value = sum (combo )
70
+ combination_hex = hex (combination_value )[2 :].upper ()
71
+ combination_names = [service for service , flag in services .items () if flag in combo ]
72
+ all_combinations .append ((combination_hex , combination_names ))
73
+
74
+ return all_combinations
75
+
76
+ def check_dns_support (combination_hex , provider ):
63
77
"""
64
- Executes a dig command for the given domain and checks for an answer section .
78
+ Checks if a DNS provider supports a given combination of flags .
65
79
"""
80
+
81
+ domain = f"x{ combination_hex } .{ provider } "
66
82
command = ["dig" , domain ]
67
83
try :
68
84
result = subprocess .run (command , capture_output = True , check = True )
@@ -71,14 +87,6 @@ def has_answer_section(domain):
71
87
except subprocess .CalledProcessError :
72
88
return False
73
89
74
- def get_hex_from_combination (* flags ):
75
- """
76
- Calculates the hexadecimal representation of the combination value.
77
- """
78
- combination_value = sum (flags )
79
- hex_value = hex (combination_value )[2 :].upper ()
80
- return f"x{ hex_value } "
81
-
82
90
if __name__ == "__main__" :
83
91
print ("\n Bitcoin Core DNS Seed Status Check:\n " )
84
92
@@ -91,23 +99,22 @@ def get_hex_from_combination(*flags):
91
99
print ()
92
100
93
101
print ("\n " )
94
-
95
- all_flags = [NODE_NONE , NODE_NETWORK , NODE_BLOOM , NODE_WITNESS , NODE_COMPACT_FILTERS , NODE_NETWORK_LIMITED , NODE_P2P_V2 ]
96
- all_combinations = []
97
-
98
- for i in range (1 , len (all_flags ) + 1 ):
99
- for combo in combinations (all_flags , i ):
100
- combination = sum (combo )
101
- hex_value = get_hex_from_combination (* combo )
102
- all_combinations .append ((combo , hex_value ))
103
-
104
- print ("All possible combinations and their hexadecimal values:" )
105
- for combination , hex_value in all_combinations :
106
- combination_names = [flag_name for flag_name , flag_value in zip (["NODE_NONE" , "NODE_NETWORK" , "NODE_BLOOM" , "NODE_WITNESS" , "NODE_COMPACT_FILTERS" , "NODE_NETWORK_LIMITED" , "NODE_P2P_V2" ], combination ) if flag_value != 0 ]
107
- combination_string = ", " .join (combination_names )
108
- print (f"Combination: { combination_string } => Hexadecimal Value: { hex_value } " )
102
+ combinations = get_combinations ({
103
+ "NODE_NONE" : NODE_NONE ,
104
+ "NODE_NETWORK" : NODE_NETWORK ,
105
+ "NODE_BLOOM" : NODE_BLOOM ,
106
+ "NODE_WITNESS" : NODE_WITNESS ,
107
+ "NODE_COMPACT_FILTERS" : NODE_COMPACT_FILTERS ,
108
+ "NODE_NETWORK_LIMITED" : NODE_NETWORK_LIMITED ,
109
+ "NODE_P2P_V2" : NODE_P2P_V2 ,
110
+ })
111
+
112
+ print ("All possible combinations of node services and their bit flags in hexadecimal:" )
113
+ for combination_hex , service_names in combinations :
114
+ print (f" Bit flag (hex): { combination_hex } - Service: { ', ' .join (service_names )} " )
109
115
110
116
for provider in DNS_SEED_PROVIDERS :
111
- domain = f"{ hex_value } .{ provider } "
112
- has_answer = has_answer_section (domain )
113
- print (f" { domain } : { has_answer } " )
117
+ supports_combination = check_dns_support (combination_hex , provider )
118
+ print (f" Provider: { provider } - Supports Service: { supports_combination } " )
119
+
120
+
0 commit comments