mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-19 07:43:54 +01:00
preparing for v0.5
This commit is contained in:
43
src/models/proxy_entry.go
Normal file
43
src/models/proxy_entry.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
F "github.com/yusing/go-proxy/utils/functional"
|
||||
)
|
||||
|
||||
type (
|
||||
ProxyEntry struct {
|
||||
Alias string `yaml:"-" json:"-"`
|
||||
Scheme string `yaml:"scheme" json:"scheme"`
|
||||
Host string `yaml:"host" json:"host"`
|
||||
Port string `yaml:"port" json:"port"`
|
||||
NoTLSVerify bool `yaml:"no_tls_verify" json:"no_tls_verify"` // http proxy only
|
||||
Path string `yaml:"path" json:"path"` // http proxy only
|
||||
SetHeaders http.Header `yaml:"set_headers" json:"set_headers"` // http proxy only
|
||||
HideHeaders []string `yaml:"hide_headers" json:"hide_headers"` // http proxy only
|
||||
}
|
||||
|
||||
ProxyEntries = *F.Map[string, *ProxyEntry]
|
||||
)
|
||||
|
||||
var NewProxyEntries = F.NewMap[string, *ProxyEntry]
|
||||
|
||||
func (e *ProxyEntry) SetDefaults() {
|
||||
if e.Scheme == "" {
|
||||
if strings.ContainsRune(e.Port, ':') {
|
||||
e.Scheme = "tcp"
|
||||
} else {
|
||||
switch e.Port {
|
||||
case "443", "8443":
|
||||
e.Scheme = "https"
|
||||
default:
|
||||
e.Scheme = "http"
|
||||
}
|
||||
}
|
||||
}
|
||||
if e.Path == "" {
|
||||
e.Path = "/"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user