测试:尝试增加hysteria2协议,尝试增加设备数限制功能

This commit is contained in:
wyx2685
2023-11-18 07:05:28 +09:00
parent f928b4f8f3
commit cf8016f405
18 changed files with 380 additions and 323 deletions

View File

@@ -200,6 +200,22 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
Obfs: info.Hysteria.Obfs,
TLS: &tls,
}
case "hysteria2":
in.Type = "hysteria2"
var obfs *option.Hysteria2Obfs
if info.Hysteria2.ObfsType != "" {
obfs = &option.Hysteria2Obfs{
Type: info.Hysteria2.ObfsType,
Password: info.Hysteria2.ObfsPassword,
}
}
in.Hysteria2Options = option.Hysteria2InboundOptions{
ListenOptions: listen,
UpMbps: info.Hysteria2.UpMbps,
DownMbps: info.Hysteria2.DownMbps,
Obfs: obfs,
TLS: &tls,
}
}
return in, nil
}

View File

@@ -114,6 +114,7 @@ func (b *Sing) Protocols() []string {
"shadowsocks",
"trojan",
"hysteria",
"hysteria2",
}
}

View File

@@ -67,7 +67,16 @@ func (b *Sing) AddUsers(p *core.AddUsersParams) (added int, err error) {
AuthString: p.Users[i].Uuid,
}
}
err = b.inbounds[p.Tag].(*inbound.HysteriaM).AddUsers(us)
err = b.inbounds[p.Tag].(*inbound.Hysteria).AddUsers(us)
case "hysteria2":
us := make([]option.Hysteria2User, len(p.Users))
for i := range p.Users {
us[i] = option.Hysteria2User{
Name: p.Users[i].Uuid,
Password: p.Users[i].Uuid,
}
}
err = b.inbounds[p.Tag].(*inbound.Hysteria2).AddUsers(us)
}
if err != nil {
return 0, err
@@ -105,7 +114,9 @@ func (b *Sing) DelUsers(users []panel.UserInfo, tag string) error {
case "trojan":
del = i.(*inbound.Trojan)
case "hysteria":
del = i.(*inbound.HysteriaM)
del = i.(*inbound.Hysteria)
case "hysteria2":
del = i.(*inbound.Hysteria2)
}
} else {
return errors.New("the inbound not found")