types.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Copyright 2025 The frp Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package api
  15. import (
  16. v1 "github.com/fatedier/frp/pkg/config/v1"
  17. )
  18. type ServerInfoResp struct {
  19. Version string `json:"version"`
  20. BindPort int `json:"bindPort"`
  21. VhostHTTPPort int `json:"vhostHTTPPort"`
  22. VhostHTTPSPort int `json:"vhostHTTPSPort"`
  23. TCPMuxHTTPConnectPort int `json:"tcpmuxHTTPConnectPort"`
  24. KCPBindPort int `json:"kcpBindPort"`
  25. QUICBindPort int `json:"quicBindPort"`
  26. SubdomainHost string `json:"subdomainHost"`
  27. MaxPoolCount int64 `json:"maxPoolCount"`
  28. MaxPortsPerClient int64 `json:"maxPortsPerClient"`
  29. HeartBeatTimeout int64 `json:"heartbeatTimeout"`
  30. AllowPortsStr string `json:"allowPortsStr,omitempty"`
  31. TLSForce bool `json:"tlsForce,omitempty"`
  32. TotalTrafficIn int64 `json:"totalTrafficIn"`
  33. TotalTrafficOut int64 `json:"totalTrafficOut"`
  34. CurConns int64 `json:"curConns"`
  35. ClientCounts int64 `json:"clientCounts"`
  36. ProxyTypeCounts map[string]int64 `json:"proxyTypeCount"`
  37. }
  38. type ClientInfoResp struct {
  39. Key string `json:"key"`
  40. User string `json:"user"`
  41. ClientID string `json:"clientID"`
  42. RunID string `json:"runID"`
  43. Hostname string `json:"hostname"`
  44. ClientIP string `json:"clientIP,omitempty"`
  45. FirstConnectedAt int64 `json:"firstConnectedAt"`
  46. LastConnectedAt int64 `json:"lastConnectedAt"`
  47. DisconnectedAt int64 `json:"disconnectedAt,omitempty"`
  48. Online bool `json:"online"`
  49. }
  50. type BaseOutConf struct {
  51. v1.ProxyBaseConfig
  52. }
  53. type TCPOutConf struct {
  54. BaseOutConf
  55. RemotePort int `json:"remotePort"`
  56. }
  57. type TCPMuxOutConf struct {
  58. BaseOutConf
  59. v1.DomainConfig
  60. Multiplexer string `json:"multiplexer"`
  61. RouteByHTTPUser string `json:"routeByHTTPUser"`
  62. }
  63. type UDPOutConf struct {
  64. BaseOutConf
  65. RemotePort int `json:"remotePort"`
  66. }
  67. type HTTPOutConf struct {
  68. BaseOutConf
  69. v1.DomainConfig
  70. Locations []string `json:"locations"`
  71. HostHeaderRewrite string `json:"hostHeaderRewrite"`
  72. }
  73. type HTTPSOutConf struct {
  74. BaseOutConf
  75. v1.DomainConfig
  76. }
  77. type STCPOutConf struct {
  78. BaseOutConf
  79. }
  80. type XTCPOutConf struct {
  81. BaseOutConf
  82. }
  83. // Get proxy info.
  84. type ProxyStatsInfo struct {
  85. Name string `json:"name"`
  86. Conf any `json:"conf"`
  87. ClientVersion string `json:"clientVersion,omitempty"`
  88. TodayTrafficIn int64 `json:"todayTrafficIn"`
  89. TodayTrafficOut int64 `json:"todayTrafficOut"`
  90. CurConns int64 `json:"curConns"`
  91. LastStartTime string `json:"lastStartTime"`
  92. LastCloseTime string `json:"lastCloseTime"`
  93. Status string `json:"status"`
  94. }
  95. type GetProxyInfoResp struct {
  96. Proxies []*ProxyStatsInfo `json:"proxies"`
  97. }
  98. // Get proxy info by name.
  99. type GetProxyStatsResp struct {
  100. Name string `json:"name"`
  101. Conf any `json:"conf"`
  102. TodayTrafficIn int64 `json:"todayTrafficIn"`
  103. TodayTrafficOut int64 `json:"todayTrafficOut"`
  104. CurConns int64 `json:"curConns"`
  105. LastStartTime string `json:"lastStartTime"`
  106. LastCloseTime string `json:"lastCloseTime"`
  107. Status string `json:"status"`
  108. }
  109. // /api/traffic/:name
  110. type GetProxyTrafficResp struct {
  111. Name string `json:"name"`
  112. TrafficIn []int64 `json:"trafficIn"`
  113. TrafficOut []int64 `json:"trafficOut"`
  114. }