proxy: add new env: FORWARDER_URL to script health check (#310)

This commit is contained in:
nadoo committed 2022-01-27 12:42:49 +08:00
1 parent fac4b86f60
commit 9b2f00f4c8
7 files changed
+21 -15

No files matched your search

+7 -1
View File
@@ -18,6 +18,7 @@ type StatusHandler func(*Forwarder)
// Forwarder associates with a `-forward` command, usually a dialer or a chain of dialers.
type Forwarder struct {
proxy.Dialer
url string
addr string
priority uint32
maxFailures uint32 // maxfailures to set to Disabled
@@ -30,7 +31,7 @@ type Forwarder struct {
// ForwarderFromURL parses `forward=` command value and returns a new forwarder.
func ForwarderFromURL(s, intface string, dialTimeout, relayTimeout time.Duration) (f *Forwarder, err error) {
f = &Forwarder{}
f = &Forwarder{url: s}
ss := strings.Split(s, "#")
if len(ss) > 1 {
@@ -107,6 +108,11 @@ func (f *Forwarder) Addr() string {
return f.addr
}
// URL returns the forwarder's full url.
func (f *Forwarder) URL() string {
return f.url
}
// Dial dials to addr and returns conn.
func (f *Forwarder) Dial(network, addr string) (c net.Conn, err error) {
c, err = f.Dialer.Dial(network, addr)