enable legacy supprot if at least one legacy config entry is found.

This commit is contained in:
Miroslav Šedivý 2025-02-20 20:10:07 +01:00
parent 3ac462e197
commit 4eadf996ed
12 changed files with 152 additions and 8 deletions

View file

@ -318,21 +318,27 @@ func (s *WebRTC) Set() {
}
func (s *WebRTC) SetV2() {
enableLegacy := false
if viper.IsSet("nat1to1") {
s.NAT1To1IPs = viper.GetStringSlice("nat1to1")
log.Warn().Msg("you are using v2 configuration 'NEKO_NAT1TO1' which is deprecated, please use 'NEKO_WEBRTC_NAT1TO1' instead")
enableLegacy = true
}
if viper.IsSet("tcpmux") {
s.TCPMux = viper.GetInt("tcpmux")
log.Warn().Msg("you are using v2 configuration 'NEKO_TCPMUX' which is deprecated, please use 'NEKO_WEBRTC_TCPMUX' instead")
enableLegacy = true
}
if viper.IsSet("udpmux") {
s.UDPMux = viper.GetInt("udpmux")
log.Warn().Msg("you are using v2 configuration 'NEKO_UDPMUX' which is deprecated, please use 'NEKO_WEBRTC_UDPMUX' instead")
enableLegacy = true
}
if viper.IsSet("icelite") {
s.ICELite = viper.GetBool("icelite")
log.Warn().Msg("you are using v2 configuration 'NEKO_ICELITE' which is deprecated, please use 'NEKO_WEBRTC_ICELITE' instead")
enableLegacy = true
}
if viper.IsSet("iceservers") {
@ -347,6 +353,7 @@ func (s *WebRTC) SetV2() {
s.ICEServersFrontend = iceServers
s.ICEServersBackend = iceServers
log.Warn().Msg("you are using v2 configuration 'NEKO_ICESERVERS' which is deprecated, please use 'NEKO_WEBRTC_ICESERVERS_FRONTEND' and/or 'NEKO_WEBRTC_ICESERVERS_BACKEND' instead")
enableLegacy = true
}
if viper.IsSet("iceserver") {
@ -356,6 +363,7 @@ func (s *WebRTC) SetV2() {
s.ICEServersBackend = append(s.ICEServersBackend, types.ICEServer{URLs: iceServerSlice})
}
log.Warn().Msg("you are using v2 configuration 'NEKO_ICESERVER' which is deprecated, please use 'NEKO_WEBRTC_ICESERVERS_FRONTEND' and/or 'NEKO_WEBRTC_ICESERVERS_BACKEND' instead")
enableLegacy = true
}
if viper.IsSet("ipfetch") {
@ -368,6 +376,7 @@ func (s *WebRTC) SetV2() {
s.NAT1To1IPs = append(s.NAT1To1IPs, ip)
}
log.Warn().Msg("you are using v2 configuration 'NEKO_IPFETCH' which is deprecated, please use 'NEKO_WEBRTC_IP_RETRIEVAL_URL' instead")
enableLegacy = true
}
if viper.IsSet("epr") {
@ -395,5 +404,12 @@ func (s *WebRTC) SetV2() {
s.EphemeralMax = max
}
log.Warn().Msg("you are using v2 configuration 'NEKO_EPR' which is deprecated, please use 'NEKO_WEBRTC_EPR' instead")
enableLegacy = true
}
// set legacy flag if any V2 configuration was used
if !viper.IsSet("legacy") && enableLegacy {
log.Warn().Msg("legacy configuration is enabled because at least one V2 configuration was used, please migrate to V3 configuration, or set 'NEKO_LEGACY=true' to acknowledge this message")
viper.Set("legacy", true)
}
}