noop.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package noop
  2. import (
  3. "net"
  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) Client(conn net.Conn) net.Conn {
  22. return conn
  23. }
  24. func (NoOpConnectionAuthenticator) Server(conn net.Conn) net.Conn {
  25. return conn
  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. }