small refactor and update next-release readme

This commit is contained in:
yusing 2025-01-02 12:20:21 +08:00
parent a587ada170
commit 9f71fc2dd5
4 changed files with 152 additions and 105 deletions

View file

@ -1,6 +1,9 @@
package task package task
import "strings" import (
"slices"
"strings"
)
// debug only. // debug only.
func (t *Task) listChildren() []string { func (t *Task) listChildren() []string {
@ -24,3 +27,17 @@ func (t *Task) listCallbacks() []string {
} }
return callbacks return callbacks
} }
// DebugTaskList returns list of all tasks.
//
// The returned string is suitable for printing to the console.
func DebugTaskList() []string {
l := make([]string, 0, allTasks.Size())
allTasks.RangeAll(func(t *Task) {
l = append(l, t.name)
})
slices.Sort(l)
return l
}

View file

@ -45,7 +45,8 @@ type (
finished chan struct{} finished chan struct{}
finishedCalled bool finishedCalled bool
mu sync.Mutex
mu sync.Mutex
ctx context.Context ctx context.Context
cancel context.CancelCauseFunc cancel context.CancelCauseFunc

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"slices"
"time" "time"
"github.com/yusing/go-proxy/internal/logging" "github.com/yusing/go-proxy/internal/logging"
@ -73,17 +72,3 @@ func GracefulShutdown(timeout time.Duration) (err error) {
} }
} }
} }
// DebugTaskList returns list of all tasks.
//
// The returned string is suitable for printing to the console.
func DebugTaskList() []string {
l := make([]string, 0, allTasks.Size())
allTasks.RangeAll(func(t *Task) {
l = append(l, t.name)
})
slices.Sort(l)
return l
}

View file

@ -1,111 +1,129 @@
GoDoxy v0.8 changes: # GoDoxy v0.8 changes:
## Breaking changes
- **Removed** `redirect_to_https` in `config.yml`, superseded by `redirectHTTP` as an entrypoint middleware
- **New** notification config format, support webhook notification, support multiple notification providers
- **Breaking** notification config format changed, support webhook notification, support multiple notification providers
old old
```yaml ```yaml
providers: providers:
notification: notification:
gotify: gotify:
url: ... url: ...
token: ... token: ...
``` ```
new new
```yaml ```yaml
providers: providers:
notification: notification:
- name: gotify - name: gotify
provider: gotify provider: gotify
url: ... url: ...
token: ... token: ...
- name: discord - name: discord
provider: webhook provider: webhook
url: https://discord.com/api/webhooks/... url: https://discord.com/api/webhooks/...
template: discord template: discord
``` ```
Webhook notification fields: Webhook notification fields:
| Field | Description | Required | Allowed values | | Field | Description | Required | Allowed values |
| ---------- | ---------------------- | ------------------------------ | ---------------- | | ---------- | ---------------------- | ------------------------------ | ---------------- |
| name | name of the provider | Yes | | | name | name of the provider | Yes | |
| provider | | Yes | `webhook` | | provider | | Yes | `webhook` |
| url | webhook URL | Yes | Full URL | | url | webhook URL | Yes | Full URL |
| template | webhook template | No | empty, `discord` | | template | webhook template | No | empty, `discord` |
| token | webhook token | No | | | token | webhook token | No | |
| payload | webhook payload | No **(if `template` is used)** | valid json | | payload | webhook payload | No **(if `template` is used)** | valid json |
| method | webhook request method | No | `GET POST PUT` | | method | webhook request method | No | `GET POST PUT` |
| mime_type | mime type | No | | | mime_type | mime type | No | |
| color_mode | color mode | No | `hex` `dec` | | color_mode | color mode | No | `hex` `dec` |
Available payload variables: Available payload variables:
| Variable | Description | Format | | Variable | Description | Format |
| -------- | --------------------------- | ------------------------------------ | | -------- | --------------------------- | ------------------------------------ |
| $title | message title | json string | | $title | message title | json string |
| $message | message in markdown format | json string | | $message | message in markdown format | json string |
| $fields | extra fields in json format | json object | | $fields | extra fields in json format | json object |
| $color | embed color by `color_mode` | `0xff0000` (hex) or `16711680` (dec) | | $color | embed color by `color_mode` | `0xff0000` (hex) or `16711680` (dec) |
- **Breaking** removed `redirect_to_https` in `config.yml`, superseded by `redirectHTTP` as an entrypoint middleware ## Non-breaking changes
- services health notification now in markdown format like `Uptime Kuma` for both webhook and Gotify - services health notification now in markdown format like `Uptime Kuma` for both webhook and Gotify
- docker services use docker now health check if possible, fallback to GoDoxy health check on failure / no docker health check - docker services now use docker health check if possible, fallback to GoDoxy health check on failure / no docker health check
- support entrypoint middlewares (applied to routes, before route middlewares) - `proxy.<alias>.path_patterns` fully support http.ServeMux patterns `[METHOD ][HOST]/[PATH]` (See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux)
```yaml - caching ACME private key in order to reuse ACME account, to prevent from ACME rate limit
entrypoint:
middlewares:
- use: CIDRWhitelist
allow:
- "127.0.0.1"
- "10.0.0.0/8"
- "192.168.0.0/16"
status: 403
message: "Forbidden"
```
- support exact host matching, i.e. - **New:** support entrypoint middlewares (applied to routes, before route middlewares)
```yaml ```yaml
app1.domain.tld: entrypoint:
host: 10.0.0.1 middlewares:
``` - use: CIDRWhitelist
allow:
- "127.0.0.1"
- "10.0.0.0/8"
- "192.168.0.0/16"
status: 403
message: "Forbidden"
```
will only match exactly `app1.domain.tld` - **New:** support exact host matching, i.e.
**If `match_domains` are used in config, `domain.tld` must be one of it**
- support `x-properties` (like in docker compose), example usage ```yaml
app1.domain.tld:
host: 10.0.0.1
```
```yaml will only match exactly `app1.domain.tld`
x-proxy: &proxy **`match_domains` in config will be ignored for this route**
scheme: https
healthcheck:
disable: true
middlewares:
hideXForwarded:
modifyRequest:
setHeaders:
Host: $req_host
api.openai.com: - **New:** support host matching without a subdomain, i.e.
<<: *proxy
host: api.openai.com ```yaml
api.groq.com: app1:
<<: *proxy host: 10.0.0.1
host: api.groq.com ```
```
will now also match `app1.tld`
- **New:** support `x-properties` (like in docker compose), example usage
```yaml
x-proxy: &proxy
scheme: https
healthcheck:
disable: true
middlewares:
hideXForwarded:
modifyRequest:
setHeaders:
Host: $req_host
api.openai.com:
<<: *proxy
host: api.openai.com
api.groq.com:
<<: *proxy
host: api.groq.com
```
- new middleware name aliases: - new middleware name aliases:
- `modifyRequest` = `request` - `modifyRequest` = `request`
- `modifyResponse` = `response` - `modifyResponse` = `response`
- support `$` variables in `request` and `response` middlewares (like nginx config) - **New:** support `$` variables in `request` and `response` middlewares (like nginx config)
- `$req_method`: request http method - `$req_method`: request http method
- `$req_scheme`: request URL scheme (http/https) - `$req_scheme`: request URL scheme (http/https)
@ -134,12 +152,38 @@ api.groq.com:
- `$resp_header(name)`: get response header by name - `$resp_header(name)`: get response header by name
- `$arg(name)`: get URL query parameter by name - `$arg(name)`: get URL query parameter by name
- `proxy.<alias>.path_patterns` fully support http.ServeMux patterns `[METHOD ][HOST]/[PATH]` (See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux) - **New:** Access Logging (entrypoint and per route), i.e.
- caching ACME private key in order to reuse ACME account, to prevent from ACME rate limit ```yaml
# config.yml
entrypoint:
access_log:
format: json # common, combined, json
path: /app/logs/access.json.log
filters:
cidr:
negative: true # no log for local requests
values:
- 127.0.0.1/32
- 172.0.0.0/8
- 192.168.0.0/16
- 10.0.0.0/16
fields:
headers:
default: drop # drop app headers in log
config: # keep only these
X-Real-Ip: keep
CF-Connecting-Ip: keep
X-Forwarded-For: keep
```
- fixed **mount logs directory before setting this**
- duplicated notification after config reload
- `timeout` was defaulted to `0` in some cases causing health check to fail ## Fixes
- `redirectHTTP` middleware may not work on non standard http port
- various other small bugs - duplicated notification after config reload
- `timeout` was defaulted to `0` in some cases causing health check to fail
- `redirectHTTP` middleware may not work on non standard http port
- various other small bugs
- `realIP` and `cloudflareRealIP` middlewares
- prometheus metrics gone after a single route reload