1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-02-05 15:55:25 -05:00

refine http header

This commit is contained in:
Darien Raymond
2016-11-02 22:26:21 +01:00
parent 1600a59254
commit 0747203132
12 changed files with 336 additions and 201 deletions

View File

@@ -28,6 +28,7 @@ type TCPListener struct {
listener *net.TCPListener
awaitingConns chan *ConnectionWithError
tlsConfig *tls.Config
authConfig internet.ConnectionAuthenticator
config *Config
}
@@ -62,6 +63,17 @@ func ListenTCP(address v2net.Address, port v2net.Port, options internet.ListenOp
l.tlsConfig = tlsConfig.GetTLSConfig()
}
}
if tcpSettings.HeaderSettings != nil {
headerConfig, err := tcpSettings.HeaderSettings.GetInstance()
if err != nil {
return nil, errors.New("TCP: Failed to get header settings: " + err.Error())
}
auth, err := internet.CreateConnectionAuthenticator(tcpSettings.HeaderSettings.Type, headerConfig)
if err != nil {
return nil, errors.New("TCP: Failed to create header authenticator: " + err.Error())
}
l.authConfig = auth
}
go l.KeepAccepting()
return l, nil
}
@@ -95,6 +107,9 @@ func (this *TCPListener) KeepAccepting() {
if this.tlsConfig != nil {
conn = tls.Server(conn, this.tlsConfig)
}
if this.authConfig != nil {
conn = this.authConfig.Server(conn)
}
select {
case this.awaitingConns <- &ConnectionWithError{
conn: conn,