mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-06-17 04:33:18 +08:00
modify ProxyParser interface
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "github.com/bestnite/sub2clash/parser"
|
||||
|
||||
type ClashType int
|
||||
|
||||
const (
|
||||
@ -8,29 +10,19 @@ const (
|
||||
)
|
||||
|
||||
func GetSupportProxyTypes(clashType ClashType) map[string]bool {
|
||||
if clashType == Clash {
|
||||
return map[string]bool{
|
||||
"ss": true,
|
||||
"ssr": true,
|
||||
"vmess": true,
|
||||
"trojan": true,
|
||||
"socks5": true,
|
||||
supportProxyTypes := make(map[string]bool)
|
||||
|
||||
for _, parser := range parser.GetAllParsers() {
|
||||
if clashType == Clash {
|
||||
if parser.SupportClash() {
|
||||
supportProxyTypes[parser.GetType()] = true
|
||||
}
|
||||
} else if clashType == ClashMeta {
|
||||
if parser.SupportMeta() {
|
||||
supportProxyTypes[parser.GetType()] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if clashType == ClashMeta {
|
||||
return map[string]bool{
|
||||
"ss": true,
|
||||
"ssr": true,
|
||||
"vmess": true,
|
||||
"trojan": true,
|
||||
"vless": true,
|
||||
"hysteria": true,
|
||||
"hysteria2": true,
|
||||
"socks5": true,
|
||||
"anytls": true,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return supportProxyTypes
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ import (
|
||||
|
||||
type AnytlsParser struct{}
|
||||
|
||||
func (p *AnytlsParser) SupportClash() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *AnytlsParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *AnytlsParser) GetPrefixes() []string {
|
||||
return []string{"anytls://"}
|
||||
}
|
||||
|
@ -12,6 +12,14 @@ import (
|
||||
|
||||
type HysteriaParser struct{}
|
||||
|
||||
func (p *HysteriaParser) SupportClash() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *HysteriaParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *HysteriaParser) GetPrefixes() []string {
|
||||
return []string{"hysteria://"}
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ import (
|
||||
|
||||
type Hysteria2Parser struct{}
|
||||
|
||||
func (p *Hysteria2Parser) SupportClash() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Hysteria2Parser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Hysteria2Parser) GetPrefixes() []string {
|
||||
return []string{"hysteria2://", "hy2://"}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ type ProxyParser interface {
|
||||
GetPrefixes() []string
|
||||
// GetType 返回协议类型名称
|
||||
GetType() string
|
||||
SupportClash() bool
|
||||
SupportMeta() bool
|
||||
}
|
||||
|
||||
// parserRegistry 解析器注册中心
|
||||
|
@ -12,6 +12,14 @@ import (
|
||||
// ShadowsocksParser Shadowsocks协议解析器
|
||||
type ShadowsocksParser struct{}
|
||||
|
||||
func (p *ShadowsocksParser) SupportClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *ShadowsocksParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// GetPrefixes 返回支持的协议前缀
|
||||
func (p *ShadowsocksParser) GetPrefixes() []string {
|
||||
return []string{"ss://"}
|
||||
|
@ -11,6 +11,14 @@ import (
|
||||
|
||||
type ShadowsocksRParser struct{}
|
||||
|
||||
func (p *ShadowsocksRParser) SupportClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *ShadowsocksRParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *ShadowsocksRParser) GetPrefixes() []string {
|
||||
return []string{"ssr://"}
|
||||
}
|
||||
|
@ -11,6 +11,13 @@ import (
|
||||
|
||||
type SocksParser struct{}
|
||||
|
||||
func (p *SocksParser) SupportClash() bool {
|
||||
return true
|
||||
}
|
||||
func (p *SocksParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *SocksParser) GetPrefixes() []string {
|
||||
return []string{"socks://"}
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ import (
|
||||
|
||||
type TrojanParser struct{}
|
||||
|
||||
func (p *TrojanParser) SupportClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *TrojanParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *TrojanParser) GetPrefixes() []string {
|
||||
return []string{"trojan://"}
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ import (
|
||||
|
||||
type VlessParser struct{}
|
||||
|
||||
func (p *VlessParser) SupportClash() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *VlessParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *VlessParser) GetPrefixes() []string {
|
||||
return []string{"vless://"}
|
||||
}
|
||||
|
@ -12,6 +12,14 @@ import (
|
||||
|
||||
type VmessParser struct{}
|
||||
|
||||
func (p *VmessParser) SupportClash() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *VmessParser) SupportMeta() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *VmessParser) GetPrefixes() []string {
|
||||
return []string{"vmess://"}
|
||||
}
|
||||
|
Reference in New Issue
Block a user