mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-22 12:26:19 +03:00
Add MTProxy, MASQUE, VPN, Link parser. Update AmneziaWG. Remove Tunneling
This commit is contained in:
31
parser/parser.go
Normal file
31
parser/parser.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-box/parser/clash"
|
||||
"github.com/sagernet/sing-box/parser/raw"
|
||||
"github.com/sagernet/sing-box/parser/singbox"
|
||||
"github.com/sagernet/sing-box/parser/sip008"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
var subscriptionParsers = []func(ctx context.Context, content string) ([]option.Outbound, error){
|
||||
singbox.ParseBoxSubscription,
|
||||
clash.ParseClashSubscription,
|
||||
sip008.ParseSIP008Subscription,
|
||||
raw.ParseRawSubscription,
|
||||
}
|
||||
|
||||
func ParseSubscription(ctx context.Context, content string) ([]option.Outbound, error) {
|
||||
var pErr error
|
||||
for _, parser := range subscriptionParsers {
|
||||
servers, err := parser(ctx, content)
|
||||
if len(servers) > 0 {
|
||||
return servers, nil
|
||||
}
|
||||
pErr = E.Errors(pErr, err)
|
||||
}
|
||||
return nil, E.Cause(pErr, "no servers found")
|
||||
}
|
||||
Reference in New Issue
Block a user