From 6678da2fe2c357436510d1d744c3c8838ef63b0c Mon Sep 17 00:00:00 2001 From: v2ray Date: Sun, 7 Aug 2016 00:38:23 +0200 Subject: [PATCH] more no-op authenticator into a separate folder --- shell/point/main/main.go | 1 + transport/internet/authenticator.go | 22 --------------- .../internet/authenticators/noop/noop.go | 28 +++++++++++++++++++ 3 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 transport/internet/authenticators/noop/noop.go diff --git a/shell/point/main/main.go b/shell/point/main/main.go index 4f94a9f2a..eaf5160f8 100644 --- a/shell/point/main/main.go +++ b/shell/point/main/main.go @@ -26,6 +26,7 @@ import ( _ "github.com/v2ray/v2ray-core/transport/internet/tcp" _ "github.com/v2ray/v2ray-core/transport/internet/udp" + _ "github.com/v2ray/v2ray-core/transport/internet/authenticators/noop" _ "github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp" ) diff --git a/transport/internet/authenticator.go b/transport/internet/authenticator.go index 25bd49038..b6eea637e 100644 --- a/transport/internet/authenticator.go +++ b/transport/internet/authenticator.go @@ -85,25 +85,3 @@ 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{} }) -} diff --git a/transport/internet/authenticators/noop/noop.go b/transport/internet/authenticators/noop/noop.go new file mode 100644 index 000000000..4a0a3b7e7 --- /dev/null +++ b/transport/internet/authenticators/noop/noop.go @@ -0,0 +1,28 @@ +package noop + +import ( + "github.com/v2ray/v2ray-core/common/alloc" + "github.com/v2ray/v2ray-core/transport/internet" +) + +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 internet.AuthenticatorConfig) internet.Authenticator { + return NoOpAuthenticator{} +} + +type NoOpAuthenticatorConfig struct{} + +func init() { + internet.RegisterAuthenticator("none", NoOpAuthenticatorFactory{}, func() interface{} { return NoOpAuthenticatorConfig{} }) +}