Skip to content

Commit

Permalink
fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed Feb 11, 2019
1 parent 95a881a commit 2481dfa
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion assets/frpc/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html> <html lang=en> <head> <meta charset=utf-8> <title>frp client admin UI</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?9b7dd6f843b02e4142ac"></script><script type="text/javascript" src="vendor.js?f837702123a3b4f7a651"></script></body> </html>
<!doctype html> <html lang=en> <head> <meta charset=utf-8> <title>frp client admin UI</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?d2cd6337d30c7b22e836"></script><script type="text/javascript" src="vendor.js?edb271e1d9c81f857840"></script></body> </html>
2 changes: 1 addition & 1 deletion assets/frpc/static/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/frpc/static/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/frpc/statik/statik.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/frps/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?bc42bc4eff72df8da372"></script><script type="text/javascript" src="vendor.js?ee403fce53c8757fc931"></script></body> </html>
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?14bea8276eef86cc7c61"></script><script type="text/javascript" src="vendor.js?51925ec1a77936b64d61"></script></body> </html>
2 changes: 1 addition & 1 deletion assets/frps/static/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/frps/static/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/frps/statik/statik.go

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions cmd/frpc/sub/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package sub

import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
Expand All @@ -25,7 +24,6 @@ import (

"github.com/spf13/cobra"

"github.com/fatedier/frp/client"
"github.com/fatedier/frp/g"
"github.com/fatedier/frp/models/config"
)
Expand Down Expand Up @@ -79,21 +77,16 @@ func reload() error {
if err != nil {
return err
} else {
if resp.StatusCode != 200 {
return fmt.Errorf("admin api status code [%d]", resp.StatusCode)
if resp.StatusCode == 200 {
return nil
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
res := &client.GeneralResponse{}
err = json.Unmarshal(body, &res)
if err != nil {
return fmt.Errorf("unmarshal http response error: %s", strings.TrimSpace(string(body)))
} else if res.Code != 0 {
return fmt.Errorf(res.Msg)
}
return fmt.Errorf("code [%d], %s", resp.StatusCode, strings.TrimSpace(string(body)))
}
return nil
}
2 changes: 1 addition & 1 deletion server/dashboard_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,6 @@ func (svr *Service) ApiProxyTraffic(w http.ResponseWriter, r *http.Request) {
trafficResp.TrafficOut = proxyTrafficInfo.TrafficOut
}

buf, _ := json.Marshal(&res)
buf, _ := json.Marshal(&trafficResp)
res.Msg = string(buf)
}
10 changes: 3 additions & 7 deletions web/frpc/src/components/Configure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,17 @@
credentials: 'include',
method: 'PUT',
body: this.textarea,
}).then(res => {
return res.json()
}).then(json => {
}).then(() => {
fetch('/api/reload', {credentials: 'include'})
.then(res => {
return res.json()
}).then(json => {
.then(() => {
this.$message({
type: 'success',
message: 'Success'
})
}).catch(err => {
this.$message({
showClose: true,
message: 'Reload frpc configure file error!',
message: 'Reload frpc configure file error, ' + err,
type: 'warning'
})
})
Expand Down

0 comments on commit 2481dfa

Please sign in to comment.