Release 1.2.0 Windows amd64 with Hysteria 2

This commit is contained in:
Navis
2026-07-28 07:14:52 +03:00
parent 5d968dc0e3
commit 7eaf53f7c2
22 changed files with 801 additions and 75 deletions
+15 -2
View File
@@ -60,16 +60,29 @@ func (c *Config) SetActive(name string) error {
// UpsertProfile creates or updates a profile by name.
func (c *Config) UpsertProfile(name, proxy string) error {
return c.UpsertProfileWithProtocol(name, proxy, "")
}
// UpsertProfileWithProtocol creates/updates a profile and optionally sets protocol.
func (c *Config) UpsertProfileWithProtocol(name, proxy string, proto Protocol) error {
name = strings.TrimSpace(name)
if name == "" {
return fmt.Errorf("имя профиля пустое")
}
proxy = strings.TrimSpace(proxy)
if proto == "" {
proto = DetectProtocol(proxy)
}
if proto == "" {
proto = ProtocolNaive
}
for i := range c.Profiles {
if c.Profiles[i].Name == name {
c.Profiles[i].Proxy = proxy
if c.Profiles[i].Protocol == "" {
if proto != "" {
c.Profiles[i].Protocol = proto
} else if c.Profiles[i].Protocol == "" {
c.Profiles[i].Protocol = ProtocolNaive
}
if len(c.Profiles[i].Listen) == 0 {
@@ -82,7 +95,7 @@ func (c *Config) UpsertProfile(name, proxy string) error {
c.Profiles = append(c.Profiles, Profile{
Name: name,
Protocol: ProtocolNaive,
Protocol: proto,
Proxy: proxy,
Listen: defaultListen(),
})