mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
commit
0573ddcd84
@ -15,6 +15,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -68,7 +69,18 @@ func main() {
|
|||||||
// reload check
|
// reload check
|
||||||
if args["--reload"] != nil {
|
if args["--reload"] != nil {
|
||||||
if args["--reload"].(bool) {
|
if args["--reload"].(bool) {
|
||||||
resp, err := http.Get("http://" + server.BindAddr + ":" + fmt.Sprintf("%d", server.DashboardPort) + "/api/reload")
|
req, err := http.NewRequest("GET", "http://"+server.BindAddr+":"+fmt.Sprintf("%d", server.DashboardPort)+"/api/reload", nil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("frps reload error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
authStr := "Basic " + base64.StdEncoding.EncodeToString([]byte(server.DashboardUsername+":"+server.DashboardPassword))
|
||||||
|
|
||||||
|
req.Header.Add("Authorization", authStr)
|
||||||
|
defaultClient := &http.Client{}
|
||||||
|
resp, err := defaultClient.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("frps reload error: %v\n", err)
|
fmt.Printf("frps reload error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -34,7 +34,8 @@ func RunDashboardServer(addr string, port int64) (err error) {
|
|||||||
// url router
|
// url router
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
// api, see dashboard_api.go
|
// api, see dashboard_api.go
|
||||||
mux.HandleFunc("/api/reload", apiReload)
|
// mux.HandleFunc("/api/reload", apiReload)
|
||||||
|
mux.HandleFunc("/api/reload", use(apiReload, basicAuth))
|
||||||
mux.HandleFunc("/api/proxies", apiProxies)
|
mux.HandleFunc("/api/proxies", apiProxies)
|
||||||
|
|
||||||
// view, see dashboard_view.go
|
// view, see dashboard_view.go
|
||||||
|
Loading…
Reference in New Issue
Block a user