-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
init.go
68 lines (56 loc) · 2.63 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Nging is a toolbox for webmasters
Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package frp
import (
"github.com/webx-top/echo"
"github.com/admpub/nging/v3/application/handler"
"github.com/admpub/nging/v3/application/handler/frp/proxy"
_ "github.com/admpub/nging/v3/application/handler/frp/plugins/multiuser"
)
func init() {
handler.RegisterToGroup(`/frp`, func(g echo.RouteRegister) {
e := handler.Echo()
g.Route(`GET,POST`, `/server_index`, ServerIndex)
g.Route(`GET,POST`, `/server_add`, ServerAdd)
g.Route(`GET,POST`, `/server_edit`, ServerEdit)
g.Route(`GET,POST`, `/server_delete`, ServerDelete)
g.Route(`GET,POST`, `/server_log`, ServerLog)
g.Route(`GET`, `/account`, AccountIndex)
g.Route(`GET,POST`, `/account_add`, AccountAdd)
g.Route(`GET,POST`, `/account_edit`, AccountEdit)
g.Route(`GET,POST`, `/account_delete`, AccountDelete)
g.Route(`GET`, `/client_index`, ClientIndex)
g.Route(`GET,POST`, `/client_add`, ClientAdd)
g.Route(`GET,POST`, `/client_edit`, ClientEdit)
g.Route(`GET,POST`, `/client_delete`, ClientDelete)
g.Route(`GET,POST`, `/client_log`, ClientLog)
g.Route(`GET`, `/group_index`, GroupIndex)
g.Route(`GET,POST`, `/group_add`, GroupAdd)
g.Route(`GET,POST`, `/group_edit`, GroupEdit)
g.Route(`GET,POST`, `/group_delete`, GroupDelete)
g.Route(`GET,POST`, `/server_restart`, ServerRestart)
g.Route(`GET,POST`, `/server_stop`, ServerStop)
g.Route(`GET,POST`, `/client_restart`, ClientRestart)
g.Route(`GET,POST`, `/client_stop`, ClientStop)
g.Route(`GET`, `/addon_form`, e.MetaHandler(echo.H{`name`: `FRP客户端配置表单`}, AddonForm))
})
handler.RegisterToGroup(`/frp/dashboard`, func(g echo.RouteRegister) {
g.Get(`/server/:id`, ServerDashboard)
g.Get(`/client/:id`, ClientDashboard)
// - 代理方案 -
g.Route(`GET,POST`, `/server/:id/*`, echo.NotFoundHandler, proxy.ProxyServer, proxy.Proxy())
g.Route(`GET,POST`, `/client/:id/*`, echo.NotFoundHandler, proxy.ProxyClient, proxy.Proxy())
})
}