syncthing/lib/connections/deprecated.go
Jakob Borg e9b68a224c
lib/connections: Handle QUIC not being available (#7186)
This does two things:

- Exclude QUIC from go1.16 builds, automatically, for now, since it
  doesn't work and just panics.

- Provide some fake listeners and dialers when QUIC is disabled.

These fake listeners and dialers indicate that they are disabled and
unsupported, which silences "Dialing $address: unknown address scheme:
quic" type of stuff which is not super helpful to the user.
2020-12-09 19:23:50 +01:00

47 lines
1.2 KiB
Go

// Copyright (C) 2018 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package connections
import "github.com/syncthing/syncthing/lib/config"
// invalidListener is never valid
type invalidListener struct {
listenerFactory
err error
}
func (i invalidListener) Valid(_ config.Configuration) error {
if i.err == nil {
// fallback so we don't accidentally return nil
return errUnsupported
}
return i.err
}
// invalidDialer is never valid
type invalidDialer struct {
dialerFactory
err error
}
func (i invalidDialer) Valid(_ config.Configuration) error {
if i.err == nil {
// fallback so we don't accidentally return nil
return errUnsupported
}
return i.err
}
func init() {
listeners["kcp"] = invalidListener{err: errDeprecated}
listeners["kcp4"] = invalidListener{err: errDeprecated}
listeners["kcp6"] = invalidListener{err: errDeprecated}
dialers["kcp"] = invalidDialer{err: errDeprecated}
dialers["kcp4"] = invalidDialer{err: errDeprecated}
dialers["kcp6"] = invalidDialer{err: errDeprecated}
}