mirror of
https://github.com/terorie/od-database-crawler.git
synced 2025-04-19 10:26:43 +00:00
Fix missing port
This commit is contained in:
parent
c72f4ba475
commit
9bc3455ee0
4
crawl.go
4
crawl.go
@ -20,7 +20,7 @@ var tlsConfig = tls.Config {
|
|||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHTTPClient(url *fasturl.URL) *fasthttp.PipelineClient {
|
func newHTTPClient(url fasturl.URL) *fasthttp.PipelineClient {
|
||||||
var isTLS bool
|
var isTLS bool
|
||||||
switch url.Scheme {
|
switch url.Scheme {
|
||||||
case fasturl.SchemeHTTP:
|
case fasturl.SchemeHTTP:
|
||||||
@ -29,6 +29,8 @@ func newHTTPClient(url *fasturl.URL) *fasthttp.PipelineClient {
|
|||||||
isTLS = true
|
isTLS = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url.AddDefaultPort()
|
||||||
|
|
||||||
return &fasthttp.PipelineClient {
|
return &fasthttp.PipelineClient {
|
||||||
MaxConns: viper.GetInt(ConfWorkers),
|
MaxConns: viper.GetInt(ConfWorkers),
|
||||||
Addr: url.Host,
|
Addr: url.Host,
|
||||||
|
@ -562,6 +562,20 @@ func validOptionalPort(port string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Check if RFC-compliant (99% sure not)
|
||||||
|
func (u *URL) AddDefaultPort() {
|
||||||
|
if strings.ContainsRune(u.Host, ':') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch u.Scheme {
|
||||||
|
case SchemeHTTP:
|
||||||
|
u.Host += ":80"
|
||||||
|
case SchemeHTTPS:
|
||||||
|
u.Host += ":443"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// String reassembles the URL into a valid URL string.
|
// String reassembles the URL into a valid URL string.
|
||||||
// The general form of the result is one of:
|
// The general form of the result is one of:
|
||||||
//
|
//
|
||||||
|
@ -23,7 +23,7 @@ type WorkerContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerContext) Prepare() {
|
func (w *WorkerContext) Prepare() {
|
||||||
w.client = newHTTPClient(&w.OD.BaseUri)
|
w.client = newHTTPClient(w.OD.BaseUri)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkerContext) Worker(results chan<- File) {
|
func (w *WorkerContext) Worker(results chan<- File) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user