File tree Expand file tree Collapse file tree 6 files changed +40
-4
lines changed Expand file tree Collapse file tree 6 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package client
17
17
import (
18
18
"net"
19
19
"net/http"
20
+ "net/http/pprof"
20
21
"time"
21
22
22
23
"github.com/fatedier/frp/assets"
@@ -26,8 +27,8 @@ import (
26
27
)
27
28
28
29
var (
29
- httpServerReadTimeout = 10 * time .Second
30
- httpServerWriteTimeout = 10 * time .Second
30
+ httpServerReadTimeout = 60 * time .Second
31
+ httpServerWriteTimeout = 60 * time .Second
31
32
)
32
33
33
34
func (svr * Service ) RunAdminServer (address string ) (err error ) {
@@ -36,6 +37,15 @@ func (svr *Service) RunAdminServer(address string) (err error) {
36
37
37
38
router .HandleFunc ("/healthz" , svr .healthz )
38
39
40
+ // debug
41
+ if svr .cfg .PprofEnable {
42
+ router .HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
43
+ router .HandleFunc ("/debug/pprof/profile" , pprof .Profile )
44
+ router .HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
45
+ router .HandleFunc ("/debug/pprof/trace" , pprof .Trace )
46
+ router .PathPrefix ("/debug/pprof/" ).HandlerFunc (pprof .Index )
47
+ }
48
+
39
49
subRouter := router .NewRoute ().Subrouter ()
40
50
user , passwd := svr .cfg .AdminUser , svr .cfg .AdminPwd
41
51
subRouter .Use (frpNet .NewHTTPAuthMiddleware (user , passwd ).Middleware )
Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ udp_packet_size = 1500
126
126
# If DisableCustomTLSFirstByte is true, frpc will not send that custom byte.
127
127
disable_custom_tls_first_byte = false
128
128
129
+ # Enable golang pprof handlers in admin listener.
130
+ # Admin port must be set first.
131
+ pprof_enable = false
132
+
129
133
# 'ssh' is the unique proxy name
130
134
# if user in [common] section is not empty, it will be changed to {user}.{proxy} such as 'your_name.ssh'
131
135
[ssh]
Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ tcp_mux = true
133
133
# It affects the udp and sudp proxy.
134
134
udp_packet_size = 1500
135
135
136
+ # Enable golang pprof handlers in dashboard listener.
137
+ # Dashboard port must be set first
138
+ pprof_enable = false
139
+
136
140
[plugin.user-manager]
137
141
addr = 127.0.0.1:9000
138
142
path = /handler
Original file line number Diff line number Diff line change @@ -151,6 +151,9 @@ type ClientCommonConf struct {
151
151
UDPPacketSize int64 `ini:"udp_packet_size" json:"udp_packet_size"`
152
152
// Include other config files for proxies.
153
153
IncludeConfigFiles []string `ini:"includes" json:"includes"`
154
+ // Enable golang pprof handlers in admin listener.
155
+ // Admin port must be set first.
156
+ PprofEnable bool `ini:"pprof_enable" json:"pprof_enable"`
154
157
}
155
158
156
159
// GetDefaultClientConf returns a client configuration with default values.
@@ -188,6 +191,7 @@ func GetDefaultClientConf() ClientCommonConf {
188
191
Metas : make (map [string ]string ),
189
192
UDPPacketSize : 1500 ,
190
193
IncludeConfigFiles : make ([]string , 0 ),
194
+ PprofEnable : false ,
191
195
}
192
196
}
193
197
Original file line number Diff line number Diff line change @@ -167,6 +167,9 @@ type ServerCommonConf struct {
167
167
// UDPPacketSize specifies the UDP packet size
168
168
// By default, this value is 1500
169
169
UDPPacketSize int64 `ini:"udp_packet_size" json:"udp_packet_size"`
170
+ // Enable golang pprof handlers in dashboard listener.
171
+ // Dashboard port must be set first.
172
+ PprofEnable bool `ini:"pprof_enable" json:"pprof_enable"`
170
173
}
171
174
172
175
// GetDefaultServerConf returns a server configuration with reasonable
@@ -210,6 +213,7 @@ func GetDefaultServerConf() ServerCommonConf {
210
213
Custom404Page : "" ,
211
214
HTTPPlugins : make (map [string ]plugin.HTTPPluginOptions ),
212
215
UDPPacketSize : 1500 ,
216
+ PprofEnable : false ,
213
217
}
214
218
}
215
219
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package server
17
17
import (
18
18
"net"
19
19
"net/http"
20
+ "net/http/pprof"
20
21
"time"
21
22
22
23
"github.com/fatedier/frp/assets"
@@ -27,15 +28,24 @@ import (
27
28
)
28
29
29
30
var (
30
- httpServerReadTimeout = 10 * time .Second
31
- httpServerWriteTimeout = 10 * time .Second
31
+ httpServerReadTimeout = 60 * time .Second
32
+ httpServerWriteTimeout = 60 * time .Second
32
33
)
33
34
34
35
func (svr * Service ) RunDashboardServer (address string ) (err error ) {
35
36
// url router
36
37
router := mux .NewRouter ()
37
38
router .HandleFunc ("/healthz" , svr .Healthz )
38
39
40
+ // debug
41
+ if svr .cfg .PprofEnable {
42
+ router .HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
43
+ router .HandleFunc ("/debug/pprof/profile" , pprof .Profile )
44
+ router .HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
45
+ router .HandleFunc ("/debug/pprof/trace" , pprof .Trace )
46
+ router .PathPrefix ("/debug/pprof/" ).HandlerFunc (pprof .Index )
47
+ }
48
+
39
49
subRouter := router .NewRoute ().Subrouter ()
40
50
41
51
user , passwd := svr .cfg .DashboardUser , svr .cfg .DashboardPwd
You can’t perform that action at this time.
0 commit comments