From 8d6a9167b5bb413a4148f91d02632a9471358fca Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 6 Aug 2016 23:15:06 +0200 Subject: [PATCH] add no-op authenticator --- transport/internet/authenticator.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/transport/internet/authenticator.go b/transport/internet/authenticator.go index b6eea637e..25bd49038 100644 --- a/transport/internet/authenticator.go +++ b/transport/internet/authenticator.go @@ -85,3 +85,25 @@ func (this *AuthenticatorChain) Seal(payload *alloc.Buffer) { auth.Seal(payload) } } + +type NoOpAuthenticator struct{} + +func (this NoOpAuthenticator) Overhead() int { + return 0 +} +func (this NoOpAuthenticator) Open(payload *alloc.Buffer) bool { + return true +} +func (this NoOpAuthenticator) Seal(payload *alloc.Buffer) {} + +type NoOpAuthenticatorFactory struct{} + +func (this NoOpAuthenticatorFactory) Create(config AuthenticatorConfig) Authenticator { + return NoOpAuthenticator{} +} + +type NoOpAuthenticatorConfig struct{} + +func init() { + RegisterAuthenticator("none", NoOpAuthenticatorFactory{}, func() interface{} { return NoOpAuthenticatorConfig{} }) +}