mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-12 03:52:11 +08:00
fix: empty proxy provider subscription info not omitted (#1759)
This commit is contained in:
parent
f4806b49b4
commit
56c128880c
@ -137,7 +137,7 @@ func (pp *proxySetProvider) Initial() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if subscriptionInfo := cachefile.Cache().GetSubscriptionInfo(pp.Name()); subscriptionInfo != "" {
|
if subscriptionInfo := cachefile.Cache().GetSubscriptionInfo(pp.Name()); subscriptionInfo != "" {
|
||||||
pp.subscriptionInfo.Update(subscriptionInfo)
|
pp.subscriptionInfo = NewSubscriptionInfo(subscriptionInfo)
|
||||||
}
|
}
|
||||||
pp.closeAllConnections()
|
pp.closeAllConnections()
|
||||||
return nil
|
return nil
|
||||||
@ -165,14 +165,12 @@ func NewProxySetProvider(name string, interval time.Duration, parser resource.Pa
|
|||||||
go hc.process()
|
go hc.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
si := new(SubscriptionInfo)
|
|
||||||
pd := &proxySetProvider{
|
pd := &proxySetProvider{
|
||||||
baseProvider: baseProvider{
|
baseProvider: baseProvider{
|
||||||
name: name,
|
name: name,
|
||||||
proxies: []C.Proxy{},
|
proxies: []C.Proxy{},
|
||||||
healthCheck: hc,
|
healthCheck: hc,
|
||||||
},
|
},
|
||||||
subscriptionInfo: si,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetcher := resource.NewFetcher[[]C.Proxy](name, interval, vehicle, parser, proxiesOnUpdate(pd))
|
fetcher := resource.NewFetcher[[]C.Proxy](name, interval, vehicle, parser, proxiesOnUpdate(pd))
|
||||||
@ -181,7 +179,7 @@ func NewProxySetProvider(name string, interval time.Duration, parser resource.Pa
|
|||||||
httpVehicle.SetInRead(func(resp *http.Response) {
|
httpVehicle.SetInRead(func(resp *http.Response) {
|
||||||
if subscriptionInfo := resp.Header.Get("subscription-userinfo"); subscriptionInfo != "" {
|
if subscriptionInfo := resp.Header.Get("subscription-userinfo"); subscriptionInfo != "" {
|
||||||
cachefile.Cache().SetSubscriptionInfo(name, subscriptionInfo)
|
cachefile.Cache().SetSubscriptionInfo(name, subscriptionInfo)
|
||||||
si.Update(subscriptionInfo)
|
pd.subscriptionInfo = NewSubscriptionInfo(subscriptionInfo)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,9 @@ type SubscriptionInfo struct {
|
|||||||
Expire int64
|
Expire int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (info *SubscriptionInfo) Update(userinfo string) {
|
func NewSubscriptionInfo(userinfo string) (si *SubscriptionInfo) {
|
||||||
userinfo = strings.ReplaceAll(strings.ToLower(userinfo), " ", "")
|
userinfo = strings.ReplaceAll(strings.ToLower(userinfo), " ", "")
|
||||||
|
si = new(SubscriptionInfo)
|
||||||
|
|
||||||
for _, field := range strings.Split(userinfo, ";") {
|
for _, field := range strings.Split(userinfo, ";") {
|
||||||
name, value, ok := strings.Cut(field, "=")
|
name, value, ok := strings.Cut(field, "=")
|
||||||
@ -32,15 +33,16 @@ func (info *SubscriptionInfo) Update(userinfo string) {
|
|||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
case "upload":
|
case "upload":
|
||||||
info.Upload = intValue
|
si.Upload = intValue
|
||||||
case "download":
|
case "download":
|
||||||
info.Download = intValue
|
si.Download = intValue
|
||||||
case "total":
|
case "total":
|
||||||
info.Total = intValue
|
si.Total = intValue
|
||||||
case "expire":
|
case "expire":
|
||||||
info.Expire = intValue
|
si.Expire = intValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return si
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseValue(value string) (int64, error) {
|
func parseValue(value string) (int64, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user