noop.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package noop
  2. import (
  3. "io"
  4. "v2ray.com/core/common/alloc"
  5. "v2ray.com/core/common/loader"
  6. "v2ray.com/core/transport/internet"
  7. )
  8. type NoOpAuthenticator struct{}
  9. func (this NoOpAuthenticator) Overhead() int {
  10. return 0
  11. }
  12. func (this NoOpAuthenticator) Open(payload *alloc.Buffer) bool {
  13. return true
  14. }
  15. func (this NoOpAuthenticator) Seal(payload *alloc.Buffer) {}
  16. type NoOpAuthenticatorFactory struct{}
  17. func (this NoOpAuthenticatorFactory) Create(config interface{}) internet.Authenticator {
  18. return NoOpAuthenticator{}
  19. }
  20. type NoOpConnectionAuthenticator struct{}
  21. func (NoOpConnectionAuthenticator) Open(reader io.Reader) (io.Reader, error) {
  22. return reader, nil
  23. }
  24. func (NoOpConnectionAuthenticator) Seal(writer io.Writer) io.Writer {
  25. return writer
  26. }
  27. type NoOpConnectionAuthenticatorFactory struct{}
  28. func (NoOpConnectionAuthenticatorFactory) Create(config interface{}) internet.ConnectionAuthenticator {
  29. return NoOpConnectionAuthenticator{}
  30. }
  31. func init() {
  32. internet.RegisterAuthenticator(loader.GetType(new(Config)), NoOpAuthenticatorFactory{})
  33. internet.RegisterConnectionAuthenticator(loader.GetType(new(Config)), NoOpConnectionAuthenticatorFactory{})
  34. }