Chore: improve outbound architecture
This commit is contained in:
@ -3,6 +3,7 @@ package adapters
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -12,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type URLTest struct {
|
||||
name string
|
||||
*Base
|
||||
proxies []C.Proxy
|
||||
rawURL string
|
||||
fast C.Proxy
|
||||
@ -28,19 +29,11 @@ type URLTestOption struct {
|
||||
Interval int `proxy:"interval"`
|
||||
}
|
||||
|
||||
func (u *URLTest) Name() string {
|
||||
return u.name
|
||||
}
|
||||
|
||||
func (u *URLTest) Type() C.AdapterType {
|
||||
return C.URLTest
|
||||
}
|
||||
|
||||
func (u *URLTest) Now() string {
|
||||
return u.fast.Name()
|
||||
}
|
||||
|
||||
func (u *URLTest) Generator(metadata *C.Metadata) (adapter C.ProxyAdapter, err error) {
|
||||
func (u *URLTest) Generator(metadata *C.Metadata) (net.Conn, error) {
|
||||
a, err := u.fast.Generator(metadata)
|
||||
if err != nil {
|
||||
go u.speedTest()
|
||||
@ -128,7 +121,10 @@ func NewURLTest(option URLTestOption, proxies []C.Proxy) (*URLTest, error) {
|
||||
|
||||
interval := time.Duration(option.Interval) * time.Second
|
||||
urlTest := &URLTest{
|
||||
name: option.Name,
|
||||
Base: &Base{
|
||||
name: option.Name,
|
||||
tp: C.URLTest,
|
||||
},
|
||||
proxies: proxies[:],
|
||||
rawURL: option.URL,
|
||||
fast: proxies[0],
|
||||
|
Reference in New Issue
Block a user