Release 1.2.0 Windows amd64 with Hysteria 2
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"vpnclient/internal/config"
|
||||
"vpnclient/internal/core"
|
||||
"vpnclient/internal/netcheck"
|
||||
"vpnclient/internal/protocols/hysteria2"
|
||||
"vpnclient/internal/protocols/naive"
|
||||
"vpnclient/internal/update"
|
||||
)
|
||||
@@ -93,10 +94,7 @@ func main() {
|
||||
_ = os.MkdirAll(dataPath, 0o755)
|
||||
|
||||
go func() {
|
||||
if _, err := naive.ResolveBinary(mgr.BinDir()); err == nil {
|
||||
return
|
||||
}
|
||||
_, _ = naive.EnsureBinary(mgr.BinDir())
|
||||
_, _ = mgr.EnsureAllCores()
|
||||
}()
|
||||
|
||||
w := webview2.NewWithOptions(webview2.WebViewOptions{
|
||||
@@ -160,7 +158,22 @@ func (a *app) getState() (uiState, error) {
|
||||
proxy = p.Proxy
|
||||
active = p.Name
|
||||
}
|
||||
corePath, coreErr := naive.ResolveBinary(a.mgr.BinDir())
|
||||
corePath := ""
|
||||
coreReady := false
|
||||
if p, err := cfg.ActiveProfile(); err == nil {
|
||||
switch p.Protocol {
|
||||
case config.ProtocolHysteria2:
|
||||
if path, err := hysteria2.ResolveBinary(a.mgr.BinDir()); err == nil {
|
||||
corePath, coreReady = path, true
|
||||
}
|
||||
default:
|
||||
if path, err := naive.ResolveBinary(a.mgr.BinDir()); err == nil {
|
||||
corePath, coreReady = path, true
|
||||
}
|
||||
}
|
||||
} else if path, err := naive.ResolveBinary(a.mgr.BinDir()); err == nil {
|
||||
corePath, coreReady = path, true
|
||||
}
|
||||
out := uiState{
|
||||
Connected: st.Connected,
|
||||
Profile: st.Profile,
|
||||
@@ -170,7 +183,7 @@ func (a *app) getState() (uiState, error) {
|
||||
SOCKSProxy: st.SOCKSProxy,
|
||||
SystemProxy: cfg.SystemProxy,
|
||||
Proxy: proxy,
|
||||
CoreReady: coreErr == nil,
|
||||
CoreReady: coreReady,
|
||||
CorePath: corePath,
|
||||
ConfigPath: a.cfgPath,
|
||||
Profiles: cfg.ListProfiles(),
|
||||
@@ -178,6 +191,11 @@ func (a *app) getState() (uiState, error) {
|
||||
Update: a.updateStatus,
|
||||
Pings: append([]netcheck.Result(nil), a.pings...),
|
||||
}
|
||||
if out.Protocol == "" {
|
||||
if p, err := cfg.ActiveProfile(); err == nil {
|
||||
out.Protocol = string(p.Protocol)
|
||||
}
|
||||
}
|
||||
if st.Connected {
|
||||
out.SystemProxy = st.SystemProxy
|
||||
}
|
||||
@@ -228,7 +246,7 @@ func (a *app) connect() error {
|
||||
return fmt.Errorf("сначала вставьте ссылку сервера")
|
||||
}
|
||||
|
||||
if _, err := naive.EnsureBinary(a.mgr.BinDir()); err != nil {
|
||||
if _, err := a.mgr.EnsureCore(""); err != nil {
|
||||
return err
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
@@ -245,7 +263,15 @@ func (a *app) disconnect() error {
|
||||
func (a *app) installCore() (string, error) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return naive.EnsureBinary(a.mgr.BinDir())
|
||||
paths, err := a.mgr.EnsureAllCores()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
parts := make([]string, 0, len(paths))
|
||||
for k, v := range paths {
|
||||
parts = append(parts, k+": "+v)
|
||||
}
|
||||
return strings.Join(parts, " | "), nil
|
||||
}
|
||||
|
||||
func (a *app) pingServers() ([]netcheck.Result, error) {
|
||||
@@ -263,7 +289,7 @@ func (a *app) pingServers() ([]netcheck.Result, error) {
|
||||
out = append(out, netcheck.Result{Name: p.Name, Error: "нет ссылки сервера"})
|
||||
continue
|
||||
}
|
||||
out = append(out, netcheck.PingProxyURI(ctx, p.Name, proxy))
|
||||
out = append(out, netcheck.PingProfile(ctx, p.Name, config.Protocol(p.Protocol), proxy))
|
||||
}
|
||||
|
||||
a.mu.Lock()
|
||||
|
||||
+12
-5
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"vpnclient/internal/config"
|
||||
"vpnclient/internal/core"
|
||||
"vpnclient/internal/protocols/hysteria2"
|
||||
"vpnclient/internal/protocols/naive"
|
||||
)
|
||||
|
||||
@@ -110,12 +111,18 @@ func runInstallCore(args []string) int {
|
||||
binDir = "bin"
|
||||
}
|
||||
}
|
||||
path, err := naive.EnsureBinary(binDir)
|
||||
pathNaive, err := naive.EnsureBinary(binDir)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "install-core: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "install-core naive: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Printf("naive core ready: %s\n", path)
|
||||
fmt.Printf("naive core ready: %s\n", pathNaive)
|
||||
pathHy2, err := hysteria2.EnsureBinary(binDir)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "install-core hysteria2: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Printf("hysteria2 core ready: %s\n", pathHy2)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -149,7 +156,7 @@ func runConnect(args []string) int {
|
||||
}
|
||||
|
||||
// Ensure official core is present.
|
||||
if _, err := naive.EnsureBinary(mgr.BinDir()); err != nil {
|
||||
if _, err := mgr.EnsureCore(""); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "connect: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
@@ -203,7 +210,7 @@ func runProbe(args []string) int {
|
||||
}
|
||||
cfg.SystemProxy = false
|
||||
|
||||
if _, err := naive.EnsureBinary(mgr.BinDir()); err != nil {
|
||||
if _, err := mgr.EnsureCore(""); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "probe: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user