Release 1.2.0 Windows amd64 with Hysteria 2
This commit is contained in:
@@ -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(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user