|
|
|
@ -429,6 +429,40 @@ func reload() error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func reloadRemote(server string) error { |
|
|
|
url := syncScheme + server + ":" + syncPort + "/api/reload" |
|
|
|
req, err := http.NewRequest("POST", url, nil) |
|
|
|
if err != nil { |
|
|
|
log.Println(err.Error()) |
|
|
|
return errors.New("Couldn't create new HTTP reload request for server: " + server) |
|
|
|
} |
|
|
|
req.Close = true |
|
|
|
req.Header.Set("User-Agent", myUserAgent) |
|
|
|
req.SetBasicAuth(appconf.Username, appconf.SecretKey) |
|
|
|
//req.Header.Set("Authorization", "Bearer "+appconf.SecretKey)
|
|
|
|
//skip verification of cert, since the cert may not be setup properly at first
|
|
|
|
customTransport := http.DefaultTransport.(*http.Transport).Clone() |
|
|
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} |
|
|
|
client := &http.Client{Transport: customTransport, Timeout: timeout} |
|
|
|
//client := &http.Client{Timeout: timeout}
|
|
|
|
response, err := client.Do(req) |
|
|
|
if err != nil { |
|
|
|
log.Println(err.Error()) |
|
|
|
return errors.New("Couldn't send HTTP remote reload to server: " + server) |
|
|
|
} |
|
|
|
body, err := ioutil.ReadAll(response.Body) |
|
|
|
if err != nil { |
|
|
|
log.Println(err.Error()) |
|
|
|
return errors.New("Couldn't parse response body on request to server: " + server) |
|
|
|
} |
|
|
|
if response.StatusCode != 200 { |
|
|
|
errorString := "Problem sending remote reload to server " + server + ". Status code: " + strconv.Itoa(response.StatusCode) + " Body: " + string(body) |
|
|
|
log.Println(errorString) |
|
|
|
return errors.New(errorString) |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func checkDomain(domain, certPath string) error { |
|
|
|
log.Println("Checking for successful installation of certificate on '" + domain + "' (verify fingerprint)...") |
|
|
|
//could do this in go with tls.Dial but using openssl is quicker and easier
|
|
|
|
|