Skip to content

Commit 9866001

Browse files
committed
feat: server api, some doc improvements
1 parent dc36be9 commit 9866001

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5221
-771
lines changed

cmd/server/go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.4
55
require (
66
github.com/karol-broda/funnel/server v0.0.0-00010101000000-000000000000
77
github.com/karol-broda/funnel/shared v0.0.0-00010101000000-000000000000
8-
github.com/karol-broda/funnel/version v0.0.0-00010101000000-000000000000
8+
github.com/karol-broda/funnel/version v0.0.0-20250808200607-dc36be944b32
99
)
1010

1111
require (
@@ -30,6 +30,7 @@ require (
3030
github.com/Azure/go-autorest/logger v0.2.1 // indirect
3131
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
3232
github.com/AzureAD/microsoft-authentication-library-for-go v1.3.3 // indirect
33+
github.com/KyleBanks/depth v1.2.1 // indirect
3334
github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 // indirect
3435
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 // indirect
3536
github.com/aliyun/alibaba-cloud-sdk-go v1.63.100 // indirect
@@ -68,6 +69,10 @@ require (
6869
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
6970
github.com/go-logr/logr v1.4.2 // indirect
7071
github.com/go-logr/stdr v1.2.2 // indirect
72+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
73+
github.com/go-openapi/jsonreference v0.20.0 // indirect
74+
github.com/go-openapi/spec v0.20.6 // indirect
75+
github.com/go-openapi/swag v0.19.15 // indirect
7176
github.com/go-playground/locales v0.14.1 // indirect
7277
github.com/go-playground/universal-translator v0.18.1 // indirect
7378
github.com/go-playground/validator/v10 v10.16.0 // indirect
@@ -95,6 +100,7 @@ require (
95100
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
96101
github.com/infobloxopen/infoblox-go-client/v2 v2.9.0 // indirect
97102
github.com/jmespath/go-jmespath v0.4.0 // indirect
103+
github.com/josharian/intern v1.0.0 // indirect
98104
github.com/json-iterator/go v1.1.12 // indirect
99105
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
100106
github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect
@@ -106,6 +112,7 @@ require (
106112
github.com/liquidweb/liquidweb-cli v0.6.9 // indirect
107113
github.com/liquidweb/liquidweb-go v1.6.4 // indirect
108114
github.com/magiconair/properties v1.8.7 // indirect
115+
github.com/mailru/easyjson v0.7.6 // indirect
109116
github.com/miekg/dns v1.1.64 // indirect
110117
github.com/mimuret/golang-iij-dpf v0.9.1 // indirect
111118
github.com/mitchellh/go-homedir v1.1.0 // indirect
@@ -157,6 +164,9 @@ require (
157164
github.com/spf13/viper v1.18.2 // indirect
158165
github.com/stretchr/testify v1.10.0 // indirect
159166
github.com/subosito/gotenv v1.6.0 // indirect
167+
github.com/swaggo/files/v2 v2.0.0 // indirect
168+
github.com/swaggo/http-swagger/v2 v2.0.2 // indirect
169+
github.com/swaggo/swag v1.16.6 // indirect
160170
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1128 // indirect
161171
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1128 // indirect
162172
github.com/tjfoc/gmsm v1.4.1 // indirect

cmd/server/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+Z
2424
github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=
2525
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM=
2626
github.com/AzureAD/microsoft-authentication-library-for-go v1.3.3 h1:H5xDQaE3XowWfhZRUpnfC+rGZMEVoSiji+b+/HFAPU4=
27+
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
2728
github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 h1:xPMsUicZ3iosVPSIP7bW5EcGUzjiiMl1OYTe14y/R24=
2829
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 h1:F1j7z+/DKEsYqZNoxC6wvfmaiDneLsQOFQmuq9NADSY=
2930
github.com/aliyun/alibaba-cloud-sdk-go v1.63.100 h1:yUkCbrSM1cWtgBfRVKMQtdt22KhDvKY7g4V+92eG9wA=
@@ -69,6 +70,10 @@ github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6
6970
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
7071
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
7172
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
73+
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
74+
github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA=
75+
github.com/go-openapi/spec v0.20.6 h1:ich1RQ3WDbfoeTqTAb+5EIxNmpKVJZWBNah9RAT0jIQ=
76+
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
7277
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
7378
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
7479
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
@@ -113,6 +118,7 @@ github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInw
113118
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
114119
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
115120
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
121+
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
116122
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
117123
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 h1:qGQQKEcAR99REcMpsXCp3lJ03zYT1PkRd3kQGPn9GVg=
118124
github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs=
@@ -127,6 +133,7 @@ github.com/linode/linodego v1.48.1 h1:Ojw1S+K5jJr1dggO8/H6r4FINxXnJbOU5GkbpaTfmh
127133
github.com/liquidweb/liquidweb-cli v0.6.9 h1:acbIvdRauiwbxIsOCEMXGwF75aSJDbDiyAWPjVnwoYM=
128134
github.com/liquidweb/liquidweb-go v1.6.4 h1:6S0m3hHSpiLqGD7AFSb7lH/W/qr1wx+tKil9fgIbjMc=
129135
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
136+
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
130137
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
131138
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
132139
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@@ -203,6 +210,9 @@ github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
203210
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
204211
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
205212
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
213+
github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw=
214+
github.com/swaggo/http-swagger/v2 v2.0.2 h1:FKCdLsl+sFCx60KFsyM0rDarwiUSZ8DqbfSyIKC9OBg=
215+
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
206216
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1128 h1:NGnqDc8FQL0YdiCHgTO4Wkso6ToD8rE3JW9VOzoPBNA=
207217
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1128 h1:mrJ5Fbkd7sZIJ5F6oRfh5zebPQaudPH9Y0+GUmFytYU=
208218
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=

cmd/server/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
// Package main provides the main entry point for the funnel server.
2+
//
3+
// @title Funnel Server API
4+
// @version 1.0
5+
// @description REST API for tunnel management and monitoring in the funnel tunneling solution
6+
// @description
7+
// @description This API provides endpoints for:
8+
// @description - Health checking
9+
// @description - Server statistics and monitoring
10+
// @description - Tunnel management (list, view, delete)
11+
// @description - Individual tunnel statistics
12+
//
13+
// @contact.name Funnel Support
14+
// @contact.url https://github.com/karol-broda/funnel
15+
//
16+
// @license.name MIT
17+
// @license.url https://github.com/karol-broda/funnel/blob/master/LICENSE.md
18+
//
19+
// @host localhost:8080
20+
// @BasePath /api
21+
//
22+
// @schemes http https
23+
//
24+
// @tag.name Server
25+
// @tag.description Server health and statistics endpoints
26+
//
27+
// @tag.name Tunnels
28+
// @tag.description Tunnel management and monitoring endpoints
129
package main
230

331
import (
@@ -64,6 +92,11 @@ func runServer(cmd *cobra.Command, args []string) {
6492

6593
s := server.NewServer()
6694
tunnelRouter := server.NewTunnelRouter(s)
95+
s.SetRouter(tunnelRouter)
96+
97+
// Initialize API handler
98+
apiHandler := server.NewAPIHandler(s, tunnelRouter)
99+
tunnelRouter.SetAPIHandler(apiHandler)
67100

68101
if enableTls {
69102
if letsEncryptEmail == "" || dnsProvidersConfig == "" {

0 commit comments

Comments
 (0)