Add site contacts/FAQ and accept AWG 2.0 / naive pastes in Add config.
ImportSubscription no longer requires only http(s): paste awg://, AWG .conf/JSON, or naive links; subscription parser also reads hosted AWG and Clash wireguard/naive. Site lists support emails and FAQ; Store listing texts/tools updated. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -632,6 +632,9 @@ type ImportResult struct {
|
||||
|
||||
func (m *Manager) ImportSubscription(rawURL string) (ImportResult, error) {
|
||||
rawURL = strings.TrimSpace(rawURL)
|
||||
if rawURL == "" {
|
||||
return ImportResult{}, fmt.Errorf("пустой URL или конфигурация")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -650,11 +653,25 @@ func (m *Manager) ImportSubscription(rawURL string) (ImportResult, error) {
|
||||
return m.applySubscription(ctx, res, used, &s)
|
||||
}
|
||||
|
||||
res, err := subscription.Fetch(ctx, rawURL)
|
||||
if err != nil {
|
||||
return ImportResult{}, err
|
||||
// Remote subscription / hosted config file (http(s) without user:pass@).
|
||||
if linknorm.LooksLikeSubscriptionURL(rawURL) {
|
||||
res, err := subscription.Fetch(ctx, rawURL)
|
||||
if err != nil {
|
||||
return ImportResult{}, err
|
||||
}
|
||||
return m.applySubscription(ctx, res, rawURL, nil)
|
||||
}
|
||||
return m.applySubscription(ctx, res, rawURL, nil)
|
||||
|
||||
// Direct paste into «Добавить конфигурацию»: awg://, AWG 2.0 .conf / JSON,
|
||||
// naive share links, Clash YAML body, multi-line link lists — no HTTP fetch.
|
||||
res, err := subscription.ParseBodyDetailed(rawURL)
|
||||
if err != nil || res == nil || len(res.Items) == 0 {
|
||||
if err != nil {
|
||||
return ImportResult{}, fmt.Errorf("%w — либо вставьте http(s) URL конфигурации, либо ссылку/тело AWG, naive, hy2, vless…", err)
|
||||
}
|
||||
return ImportResult{}, fmt.Errorf("не удалось распознать конфигурацию — нужен http(s) URL либо ссылка/тело (AWG, naive, hy2, vless…)")
|
||||
}
|
||||
return m.applySubscription(ctx, res, "", nil)
|
||||
}
|
||||
|
||||
// ImportRemnawave fetches configs using saved / provided panel settings.
|
||||
|
||||
@@ -87,3 +87,60 @@ func TestSaveProfileKeepsNaiveLink(t *testing.T) {
|
||||
t.Fatalf("naive profile broken: %+v", p)
|
||||
}
|
||||
}
|
||||
|
||||
// «Добавить конфигурацию» must accept pasted AWG 2.0 .conf / naive links,
|
||||
// not only http(s) subscription URLs (regression: "нужен http(s) URL").
|
||||
func TestImportSubscriptionDirectAWGAndNaive(t *testing.T) {
|
||||
m := newTestManager(t)
|
||||
awgBody := `[Interface]
|
||||
PrivateKey = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
|
||||
Address = 10.8.0.2/32
|
||||
Jc = 4
|
||||
Jmin = 40
|
||||
Jmax = 70
|
||||
H1 = 1
|
||||
H2 = 2
|
||||
H3 = 3
|
||||
H4 = 4
|
||||
|
||||
[Peer]
|
||||
PublicKey = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEE=
|
||||
Endpoint = 203.0.113.10:51820
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
`
|
||||
r, err := m.ImportSubscription(awgBody)
|
||||
if err != nil {
|
||||
t.Fatalf("AWG paste: %v", err)
|
||||
}
|
||||
if r.Imported < 1 {
|
||||
t.Fatalf("AWG imported=%d", r.Imported)
|
||||
}
|
||||
foundAWG := false
|
||||
for _, p := range m.Profiles() {
|
||||
if config.Protocol(p.Protocol) == config.ProtocolAWG && strings.Contains(p.Proxy, "203.0.113.10:51820") {
|
||||
foundAWG = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !foundAWG {
|
||||
t.Fatal("AWG profile missing")
|
||||
}
|
||||
|
||||
r2, err := m.ImportSubscription("https://user:secret@naive.example.com:443#NV")
|
||||
if err != nil {
|
||||
t.Fatalf("naive paste: %v", err)
|
||||
}
|
||||
if r2.Imported < 1 {
|
||||
t.Fatalf("naive imported=%d", r2.Imported)
|
||||
}
|
||||
foundNaive := false
|
||||
for _, p := range m.Profiles() {
|
||||
if config.Protocol(p.Protocol) == config.ProtocolNaive && strings.Contains(p.Proxy, "naive.example.com") {
|
||||
foundNaive = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !foundNaive {
|
||||
t.Fatal("naive profile missing")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user