github.com/MicalKarl/sing-shadowsocks@v0.0.5/shadowimpl/fetcher.go (about) 1 package shadowimpl 2 3 import ( 4 "time" 5 6 shadowsocks "github.com/MicalKarl/sing-shadowsocks" 7 "github.com/MicalKarl/sing-shadowsocks/shadowaead" 8 "github.com/MicalKarl/sing-shadowsocks/shadowaead_2022" 9 "github.com/MicalKarl/sing-shadowsocks/shadowstream" 10 "github.com/sagernet/sing/common" 11 E "github.com/sagernet/sing/common/exceptions" 12 ) 13 14 func FetchMethod(method string, password string, timeFunc func() time.Time) (shadowsocks.Method, error) { 15 if method == "none" || method == "plain" || method == "dummy" { 16 return shadowsocks.NewNone(), nil 17 } else if common.Contains(shadowstream.List, method) { 18 return shadowstream.New(method, nil, password) 19 } else if common.Contains(shadowaead.List, method) { 20 return shadowaead.New(method, nil, password) 21 } else if common.Contains(shadowaead_2022.List, method) { 22 return shadowaead_2022.NewWithPassword(method, password, timeFunc) 23 } else { 24 return nil, E.New("shadowsocks: unsupported method ", method) 25 } 26 }