add ci case of reload and reconnect

This commit is contained in:
fatedier
2018-07-12 15:23:34 +08:00
parent d74b45be5d
commit 57417c83ae
6 changed files with 208 additions and 30 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
@ -75,6 +76,27 @@ func GetProxyStatus(statusAddr string, user string, passwd string, name string)
return status, errors.New("no proxy status found")
}
func ReloadConf(reloadAddr string, user string, passwd string) error {
req, err := http.NewRequest("GET", "http://"+reloadAddr+"/api/reload", nil)
if err != nil {
return err
}
authStr := "Basic " + base64.StdEncoding.EncodeToString([]byte(user+":"+passwd))
req.Header.Add("Authorization", authStr)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
} else {
if resp.StatusCode != 200 {
return fmt.Errorf("admin api status code [%d]", resp.StatusCode)
}
defer resp.Body.Close()
io.Copy(ioutil.Discard, resp.Body)
}
return nil
}
func SendTcpMsg(addr string, msg string) (res string, err error) {
c, err := frpNet.ConnectTcpServer(addr)
if err != nil {