2018-02-09 03:40:57 -07:00
|
|
|
// 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"
|
|
|
|
|
2020-12-09 11:23:50 -07:00
|
|
|
// invalidListener is never valid
|
|
|
|
type invalidListener struct {
|
2018-02-09 03:40:57 -07:00
|
|
|
listenerFactory
|
2020-12-09 11:23:50 -07:00
|
|
|
err error
|
2018-02-09 03:40:57 -07:00
|
|
|
}
|
|
|
|
|
2020-12-09 11:23:50 -07:00
|
|
|
func (i invalidListener) Valid(_ config.Configuration) error {
|
|
|
|
if i.err == nil {
|
|
|
|
// fallback so we don't accidentally return nil
|
|
|
|
return errUnsupported
|
|
|
|
}
|
|
|
|
return i.err
|
2018-02-09 03:40:57 -07:00
|
|
|
}
|
|
|
|
|
2020-12-09 11:23:50 -07:00
|
|
|
// invalidDialer is never valid
|
|
|
|
type invalidDialer struct {
|
2018-02-09 03:40:57 -07:00
|
|
|
dialerFactory
|
2020-12-09 11:23:50 -07:00
|
|
|
err error
|
2018-02-09 03:40:57 -07:00
|
|
|
}
|
|
|
|
|
2020-12-09 11:23:50 -07:00
|
|
|
func (i invalidDialer) Valid(_ config.Configuration) error {
|
|
|
|
if i.err == nil {
|
|
|
|
// fallback so we don't accidentally return nil
|
|
|
|
return errUnsupported
|
|
|
|
}
|
|
|
|
return i.err
|
2018-02-09 03:40:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2020-12-09 11:23:50 -07:00
|
|
|
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}
|
2018-02-09 03:40:57 -07:00
|
|
|
}
|