33 lines
733 B
Go
33 lines
733 B
Go
package subscription
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/prism/proxy/internal/store"
|
|
)
|
|
|
|
// ParseLinkLines parses share links (ss/socks5/http/trojan) into manual proxy nodes.
|
|
func ParseLinkLines(text string) ([]store.ProxyNode, []string) {
|
|
lines := strings.Split(text, "\n")
|
|
var out []store.ProxyNode
|
|
var errs []string
|
|
idx := 0
|
|
for i, line := range lines {
|
|
line = strings.TrimSpace(line)
|
|
if line == "" || strings.HasPrefix(line, "#") {
|
|
continue
|
|
}
|
|
n, err := parseLink(line, 0, idx)
|
|
if err != nil {
|
|
errs = append(errs, fmt.Sprintf("第 %d 行: %v", i+1, err))
|
|
continue
|
|
}
|
|
n.Source = "manual"
|
|
n.RuntimeName = store.RuntimeName("manual", 0, n.Name)
|
|
out = append(out, n)
|
|
idx++
|
|
}
|
|
return out, errs
|
|
}
|