-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy_pool.go
More file actions
65 lines (56 loc) · 1.72 KB
/
proxy_pool.go
File metadata and controls
65 lines (56 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import wailsapp "github.com/linhay/gettokens/internal/wailsapp"
type ProbeProxyNodeInput struct {
ProxyURL string `json:"proxyUrl"`
TargetURL string `json:"targetUrl,omitempty"`
}
type ProbeProxyNodeResult struct {
ProxyURL string `json:"proxyUrl"`
TargetURL string `json:"targetUrl"`
Success bool `json:"success"`
StatusCode int `json:"statusCode,omitempty"`
LatencyMs int `json:"latencyMs"`
CheckedAt string `json:"checkedAt"`
Message string `json:"message"`
}
type FetchProxySubscriptionInput struct {
URL string `json:"url"`
SourceLabel string `json:"sourceLabel,omitempty"`
}
type FetchProxySubscriptionResult struct {
URL string `json:"url"`
SourceLabel string `json:"sourceLabel"`
Content string `json:"content"`
}
func (a *App) ProbeProxyNode(input ProbeProxyNodeInput) (*ProbeProxyNodeResult, error) {
result, err := a.core.ProbeProxyNode(wailsapp.ProbeProxyNodeInput{
ProxyURL: input.ProxyURL,
TargetURL: input.TargetURL,
})
if err != nil {
return nil, err
}
return &ProbeProxyNodeResult{
ProxyURL: result.ProxyURL,
TargetURL: result.TargetURL,
Success: result.Success,
StatusCode: result.StatusCode,
LatencyMs: result.LatencyMs,
CheckedAt: result.CheckedAt,
Message: result.Message,
}, nil
}
func (a *App) FetchProxySubscription(input FetchProxySubscriptionInput) (*FetchProxySubscriptionResult, error) {
result, err := a.core.FetchProxySubscription(wailsapp.FetchProxySubscriptionInput{
URL: input.URL,
SourceLabel: input.SourceLabel,
})
if err != nil {
return nil, err
}
return &FetchProxySubscriptionResult{
URL: result.URL,
SourceLabel: result.SourceLabel,
Content: result.Content,
}, nil
}