mirror of https://github.com/v2ray/v2ray-core
				
				
				
			remove unnecessary code
							parent
							
								
									17504d2aac
								
							
						
					
					
						commit
						289c467a12
					
				| 
						 | 
				
			
			@ -115,8 +115,6 @@ func (Router) Interface() interface{} {
 | 
			
		|||
	return (*Router)(nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type RouterFactory struct{}
 | 
			
		||||
 | 
			
		||||
func FromSpace(space app.Space) *Router {
 | 
			
		||||
	app := space.GetApplication((*Router)(nil))
 | 
			
		||||
	if app == nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,6 @@ import (
 | 
			
		|||
	"v2ray.com/core/common"
 | 
			
		||||
	"v2ray.com/core/common/buf"
 | 
			
		||||
	"v2ray.com/core/common/serial"
 | 
			
		||||
	"v2ray.com/core/transport/internet"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
| 
						 | 
				
			
			@ -259,20 +258,14 @@ func (v HttpAuthenticator) Server(conn net.Conn) net.Conn {
 | 
			
		|||
	}))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type HttpAuthenticatorFactory struct{}
 | 
			
		||||
 | 
			
		||||
func (HttpAuthenticatorFactory) Create(config interface{}) internet.ConnectionAuthenticator {
 | 
			
		||||
func NewHttpAuthenticator(ctx context.Context, config *Config) (HttpAuthenticator, error) {
 | 
			
		||||
	return HttpAuthenticator{
 | 
			
		||||
		config: config.(*Config),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewHttpAuthenticator(ctx context.Context, config interface{}) (interface{}, error) {
 | 
			
		||||
	return HttpAuthenticator{
 | 
			
		||||
		config: config.(*Config),
 | 
			
		||||
		config: config,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	common.Must(common.RegisterConfig((*Config)(nil), NewHttpAuthenticator))
 | 
			
		||||
	common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
 | 
			
		||||
		return NewHttpAuthenticator(ctx, config.(*Config))
 | 
			
		||||
	}))
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
package http_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"v2ray.com/core/common/buf"
 | 
			
		||||
| 
						 | 
				
			
			@ -34,8 +34,7 @@ func TestReaderWriter(t *testing.T) {
 | 
			
		|||
func TestRequestHeader(t *testing.T) {
 | 
			
		||||
	assert := assert.On(t)
 | 
			
		||||
 | 
			
		||||
	factory := HttpAuthenticatorFactory{}
 | 
			
		||||
	auth := factory.Create(&Config{
 | 
			
		||||
	auth, err := NewHttpAuthenticator(context.Background(), &Config{
 | 
			
		||||
		Request: &RequestConfig{
 | 
			
		||||
			Uri: []string{"/"},
 | 
			
		||||
			Header: []*Header{
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +44,11 @@ func TestRequestHeader(t *testing.T) {
 | 
			
		|||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}).(HttpAuthenticator)
 | 
			
		||||
	})
 | 
			
		||||
	assert.Error(err).IsNil()
 | 
			
		||||
 | 
			
		||||
	cache := buf.New()
 | 
			
		||||
	err := auth.GetClientWriter().Write(cache)
 | 
			
		||||
	err = auth.GetClientWriter().Write(cache)
 | 
			
		||||
	assert.Error(err).IsNil()
 | 
			
		||||
 | 
			
		||||
	assert.String(cache.String()).Equals("GET / HTTP/1.1\r\nTest: Value\r\n\r\n")
 | 
			
		||||
| 
						 | 
				
			
			@ -57,8 +57,8 @@ func TestRequestHeader(t *testing.T) {
 | 
			
		|||
func TestConnection(t *testing.T) {
 | 
			
		||||
	assert := assert.On(t)
 | 
			
		||||
 | 
			
		||||
	factory := HttpAuthenticatorFactory{}
 | 
			
		||||
	auth := factory.Create(new(Config))
 | 
			
		||||
	auth, err := NewHttpAuthenticator(context.Background(), new(Config))
 | 
			
		||||
	assert.Error(err).IsNil()
 | 
			
		||||
 | 
			
		||||
	listener, err := net.Listen("tcp", "127.0.0.1:0")
 | 
			
		||||
	assert.Error(err).IsNil()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue