mirror of
				https://github.com/SSLMate/certspotter.git
				synced 2025-07-03 10:47:17 +02:00 
			
		
		
		
	Improve -version and User-Agent
This commit is contained in:
		
							parent
							
								
									b649b399e4
								
							
						
					
					
						commit
						5a8dd2ca82
					
				| @ -31,17 +31,16 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var programName = os.Args[0] | var programName = os.Args[0] | ||||||
| var Version = "" | var Version = "unknown" | ||||||
|  | var Source = "unknown" | ||||||
| 
 | 
 | ||||||
| const defaultLogList = "https://loglist.certspotter.org/monitor.json" | const defaultLogList = "https://loglist.certspotter.org/monitor.json" | ||||||
| 
 | 
 | ||||||
| func certspotterVersion() string { | func certspotterVersion() (string, string) { | ||||||
| 	if Version != "" { | 	if buildinfo, ok := debug.ReadBuildInfo(); ok && strings.HasPrefix(buildinfo.Main.Version, "v") { | ||||||
| 		return Version + "?" | 		return strings.TrimPrefix(buildinfo.Main.Version, "v"), buildinfo.Main.Path | ||||||
| 	} else if info, ok := debug.ReadBuildInfo(); ok && strings.HasPrefix(info.Main.Version, "v") { |  | ||||||
| 		return info.Main.Version |  | ||||||
| 	} else { | 	} else { | ||||||
| 		return "unknown" | 		return Version, Source | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -139,8 +138,10 @@ func appendFunc(slice *[]string) func(string) error { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func main() { | func main() { | ||||||
| 	loglist.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s)", certspotterVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH) | 	version, source := certspotterVersion() | ||||||
| 	ctclient.UserAgent = fmt.Sprintf("certspotter/%s (+https://github.com/SSLMate/certspotter)", certspotterVersion()) | 
 | ||||||
|  | 	ctclient.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s; %s; +https://github.com/SSLMate/certspotter)", version, source, runtime.Version(), runtime.GOOS, runtime.GOARCH) | ||||||
|  | 	loglist.UserAgent = ctclient.UserAgent | ||||||
| 
 | 
 | ||||||
| 	var flags struct { | 	var flags struct { | ||||||
| 		batchSize   bool | 		batchSize   bool | ||||||
| @ -175,7 +176,7 @@ func main() { | |||||||
| 		os.Exit(2) | 		os.Exit(2) | ||||||
| 	} | 	} | ||||||
| 	if flags.version { | 	if flags.version { | ||||||
| 		fmt.Fprintf(os.Stdout, "certspotter version %s\n", certspotterVersion()) | 		fmt.Fprintf(os.Stdout, "certspotter version %s (%s)\n", version, source) | ||||||
| 		os.Exit(0) | 		os.Exit(0) | ||||||
| 	} | 	} | ||||||
| 	if flags.watchlist == "" { | 	if flags.watchlist == "" { | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var UserAgent = "software.sslmate.com/src/certspotter" | var UserAgent = "" | ||||||
| 
 | 
 | ||||||
| // Create an HTTP client suitable for communicating with CT logs.  dialContext, if non-nil, is used for dialing. | // Create an HTTP client suitable for communicating with CT logs.  dialContext, if non-nil, is used for dialing. | ||||||
| func NewHTTPClient(dialContext func(context.Context, string, string) (net.Conn, error)) *http.Client { | func NewHTTPClient(dialContext func(context.Context, string, string) (net.Conn, error)) *http.Client { | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var UserAgent = "software.sslmate.com/src/certspotter" | var UserAgent = "" | ||||||
| 
 | 
 | ||||||
| type ModificationToken struct { | type ModificationToken struct { | ||||||
| 	etag     string | 	etag     string | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Andrew Ayer
						Andrew Ayer