mirror of
https://github.com/fatedier/frp.git
synced 2025-07-14 09:49:13 +07:00
add ci case of reload and reconnect
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user