@@ -36,6 +36,10 @@ Version History:
36360.2.2; 2025-01-04
3737 Added geo printout
3838 Updated Reverse Proxy / WAF list
39+ 0.2.3; 2025-01-07
40+ add sanity check for punycode domains, https://github.com/cyclone-github/ipscope/issues/1
41+ add -json output flag, https://github.com/cyclone-github/ipscope/issues/2
42+ fixed stdout to stderr, https://github.com/cyclone-github/ipscope/issues/3
3943*/
4044
4145const cloudflareIPv4URL = "https://www.cloudflare.com/ips-v4/"
@@ -52,6 +56,7 @@ func main() {
5256 urlFlag := flag .String ("url" , "" , "URL to process" )
5357 subFlag := flag .String ("sub" , "" , "File containing subdomains" )
5458 dnsFlag := flag .String ("dns" , "1.1.1.1" , "Custom DNS server (ex: 1.1.1.1)" )
59+ jsonFlag := flag .Bool ("json" , false , "Output results in JSON format" )
5560 cycloneFlag := flag .Bool ("cyclone" , false , "" )
5661 versionFlag := flag .Bool ("version" , false , "Version info" )
5762 helpFlag := flag .Bool ("help" , false , "Display help" )
@@ -79,6 +84,8 @@ func main() {
7984 os .Exit (1 )
8085 }
8186
87+ jsonOutput := * jsonFlag
88+
8289 domain := * urlFlag
8390
8491 // DNS resolver
@@ -99,8 +106,8 @@ func main() {
99106
100107 printCyclone ()
101108
102- fmt .Fprintf (writer , "Processing URL: %s using DNS: %s\n \n " , domain , * dnsFlag )
103- writer .Flush ()
109+ fmt .Fprintf (os . Stderr , "Processing URL: %s using DNS: %s\n \n " , domain , * dnsFlag )
110+ // writer.Flush()
104111
105112 // load Cloudflare IP ranges
106113 loadCloudflareIPs ()
@@ -136,7 +143,7 @@ func main() {
136143 }
137144
138145 if ips , err := customResolver .LookupIP (context .Background (), "ip4" , fullDomain ); err == nil {
139- printOutput (writer , label , fullDomain , ips )
146+ printOutput (writer , label , fullDomain , ips , jsonOutput )
140147 writer .Flush ()
141148 }
142149 }
@@ -148,7 +155,7 @@ func main() {
148155 if err != nil {
149156 fmt .Fprintf (writer , "Error getting IP for TLD (%s): %v\n " , domain , err )
150157 } else {
151- printOutput (writer , "TLD" , domain , tldIPs )
158+ printOutput (writer , "TLD" , domain , tldIPs , jsonOutput )
152159 writer .Flush ()
153160 processedSubdomains [domain ] = true
154161 }
@@ -171,7 +178,7 @@ func main() {
171178 }
172179 processedSubdomains [fullDomain ] = true
173180 if ips , err := customResolver .LookupIP (context .Background (), "ip4" , fullDomain ); err == nil {
174- printOutput (writer , "SUB" , fullDomain , ips )
181+ printOutput (writer , "SUB" , fullDomain , ips , jsonOutput )
175182 writer .Flush ()
176183 }
177184 }
@@ -187,7 +194,7 @@ func main() {
187194 }
188195 processedSubdomains [fullDomain ] = true
189196 if ips , err := customResolver .LookupIP (context .Background (), "ip4" , fullDomain ); err == nil {
190- printOutput (writer , "SUB" , fullDomain , ips )
197+ printOutput (writer , "SUB" , fullDomain , ips , jsonOutput )
191198 writer .Flush ()
192199 }
193200 }
0 commit comments