| // |
| 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 |
| 15 | package controller |
| 16 |
| 17 | import ( |
| 18 | "github.com/fatedier/frp/pkg/nathole" |
| 19 | plugin "github.com/fatedier/frp/pkg/plugin/server" |
| 20 | "github.com/fatedier/frp/pkg/util/tcpmux" |
| 21 | "github.com/fatedier/frp/pkg/util/vhost" |
| 22 | "github.com/fatedier/frp/server/group" |
| 23 | "github.com/fatedier/frp/server/ports" |
| 24 | "github.com/fatedier/frp/server/visitor" |
| 25 | ) |
| 26 |
| 27 | // All resource managers and controllers |
| 28 | type ResourceController struct { |
| 29 | // Manage all visitor listeners |
| 30 | VisitorManager *visitor.Manager |
| 31 |
| 32 | // TCP Group Controller |
| 33 | TCPGroupCtl *group.TCPGroupCtl |
| 34 |
| 35 | // HTTP Group Controller |
| 36 | HTTPGroupCtl *group.HTTPGroupController |
| 37 |
| 38 | // HTTPS Group Controller |
| 39 | HTTPSGroupCtl *group.HTTPSGroupController |
| 40 |
| 41 | // TCP Mux Group Controller |
| 42 | TCPMuxGroupCtl *group.TCPMuxGroupCtl |
| 43 |
| 44 | // Manage all TCP ports |
| 45 | TCPPortManager *ports.Manager |
| 46 |
| 47 | // Manage all UDP ports |
| 48 | UDPPortManager *ports.Manager |
| 49 |
| 50 | // For HTTP proxies, forwarding HTTP requests |
| 51 | HTTPReverseProxy *vhost.HTTPReverseProxy |
| 52 |
| 53 | // For HTTPS proxies, route requests to different clients by hostname and other information |
| 54 | VhostHTTPSMuxer *vhost.HTTPSMuxer |
| 55 |
| 56 | // Controller for nat hole connections |
| 57 | NatHoleController *nathole.Controller |
| 58 |
| 59 | // TCPMux HTTP CONNECT multiplexer |
| 60 | TCPMuxHTTPConnectMuxer *tcpmux.HTTPConnectTCPMuxer |
| 61 |
| 62 | // All server manager plugin |
| 63 | PluginManager *plugin.Manager |
| 64 | } |
| 65 |
| 66 | func (rc *ResourceController) Close() error { |
| 67 | if rc.VhostHTTPSMuxer != nil { |
| 68 | rc.VhostHTTPSMuxer.Close() |
| 69 | } |
| 70 | if rc.TCPMuxHTTPConnectMuxer != nil { |
| 71 | rc.TCPMuxHTTPConnectMuxer.Close() |
| 72 | } |
| 73 | return nil |
| 74 | } |