addition of proxyurl flag
This commit is contained in:
parent
6991be261c
commit
18f65dbd39
|
@ -14,6 +14,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -31,6 +32,7 @@ var underwater = flag.Bool("underwater", false, "Monitor certificates from distr
|
||||||
var noSave = flag.Bool("no_save", false, "Do not save a copy of matching certificates")
|
var noSave = flag.Bool("no_save", false, "Do not save a copy of matching certificates")
|
||||||
var verbose = flag.Bool("verbose", false, "Be verbose")
|
var verbose = flag.Bool("verbose", false, "Be verbose")
|
||||||
var allTime = flag.Bool("all_time", false, "Scan certs from all time, not just since last scan")
|
var allTime = flag.Bool("all_time", false, "Scan certs from all time, not just since last scan")
|
||||||
|
var proxy = flag.String("proxyurl", "", "Proxy URL to use for http connections (eg. http://my.proxy.com:8080)")
|
||||||
var state *State
|
var state *State
|
||||||
|
|
||||||
var printMutex sync.Mutex
|
var printMutex sync.Mutex
|
||||||
|
@ -108,11 +110,17 @@ func makeLogHandle(logInfo *certspotter.LogInfo) (*logHandle, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Bad public key: %s", err)
|
return nil, fmt.Errorf("Bad public key: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxyURL, err := url.Parse(*proxy)
|
||||||
|
if *proxy == "" {
|
||||||
|
proxyURL = nil
|
||||||
|
}
|
||||||
|
|
||||||
ctlog.scanner = certspotter.NewScanner(logInfo.FullURI(), logInfo.ID(), logKey, &certspotter.ScannerOptions{
|
ctlog.scanner = certspotter.NewScanner(logInfo.FullURI(), logInfo.ID(), logKey, &certspotter.ScannerOptions{
|
||||||
BatchSize: *batchSize,
|
BatchSize: *batchSize,
|
||||||
NumWorkers: *numWorkers,
|
NumWorkers: *numWorkers,
|
||||||
Quiet: !*verbose,
|
Quiet: !*verbose,
|
||||||
})
|
ProxyURL: proxyURL})
|
||||||
|
|
||||||
ctlog.state, err = state.OpenLogState(logInfo)
|
ctlog.state, err = state.OpenLogState(logInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -86,9 +86,10 @@ type addChainResponse struct {
|
||||||
// New constructs a new LogClient instance.
|
// New constructs a new LogClient instance.
|
||||||
// |uri| is the base URI of the CT log instance to interact with, e.g.
|
// |uri| is the base URI of the CT log instance to interact with, e.g.
|
||||||
// http://ct.googleapis.com/pilot
|
// http://ct.googleapis.com/pilot
|
||||||
func New(uri string) *LogClient {
|
func New(uri string, proxyURL *url.URL) *LogClient {
|
||||||
var c LogClient
|
var c LogClient
|
||||||
c.uri = uri
|
c.uri = uri
|
||||||
|
|
||||||
transport := &httpclient.Transport{
|
transport := &httpclient.Transport{
|
||||||
ConnectTimeout: 10 * time.Second,
|
ConnectTimeout: 10 * time.Second,
|
||||||
RequestTimeout: 60 * time.Second,
|
RequestTimeout: 60 * time.Second,
|
||||||
|
@ -106,6 +107,9 @@ func New(uri string) *LogClient {
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if proxyURL != nil {
|
||||||
|
transport.Proxy = http.ProxyURL(proxyURL)
|
||||||
|
}
|
||||||
c.httpClient = &http.Client{Transport: transport}
|
c.httpClient = &http.Client{Transport: transport}
|
||||||
return &c
|
return &c
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package certspotter
|
package certspotter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/url"
|
||||||
// "container/list"
|
// "container/list"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto"
|
"crypto"
|
||||||
|
@ -44,6 +45,9 @@ type ScannerOptions struct {
|
||||||
|
|
||||||
// Don't print any status messages to stdout
|
// Don't print any status messages to stdout
|
||||||
Quiet bool
|
Quiet bool
|
||||||
|
|
||||||
|
//
|
||||||
|
ProxyURL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new ScannerOptions struct with sensible defaults
|
// Creates a new ScannerOptions struct with sensible defaults
|
||||||
|
@ -52,6 +56,7 @@ func DefaultScannerOptions() *ScannerOptions {
|
||||||
BatchSize: 1000,
|
BatchSize: 1000,
|
||||||
NumWorkers: 1,
|
NumWorkers: 1,
|
||||||
Quiet: false,
|
Quiet: false,
|
||||||
|
ProxyURL: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +320,7 @@ func NewScanner(logUri string, logId []byte, publicKey crypto.PublicKey, opts *S
|
||||||
scanner.LogUri = logUri
|
scanner.LogUri = logUri
|
||||||
scanner.LogId = logId
|
scanner.LogId = logId
|
||||||
scanner.publicKey = publicKey
|
scanner.publicKey = publicKey
|
||||||
scanner.logClient = client.New(logUri)
|
scanner.logClient = client.New(logUri, opts.ProxyURL)
|
||||||
scanner.opts = *opts
|
scanner.opts = *opts
|
||||||
return &scanner
|
return &scanner
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue