Skip to content

Commit

Permalink
Merge pull request #52 from peter-tank/dev
Browse files Browse the repository at this point in the history
fix: server side `double_tls`
  • Loading branch information
p4gefau1t authored May 15, 2020
2 parents 2a9f663 + a0008ef commit ae349f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 11 additions & 0 deletions conf/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,17 @@ func loadServerConfig(config *GlobalConfig) error {
}
config.TLS.HTTPResponse = payload
}

if config.Websocket.DoubleTLS {
if config.Websocket.TLS.CertPath == "" {
log.Warn("Empty double TLS settings, using default ssl settings")
config.Websocket.TLS = config.TLS
}
if err := loadCertAndKey(&config.Websocket.TLS); err != nil {
return err
}
}

return nil
}

Expand Down
8 changes: 4 additions & 4 deletions protocol/trojan/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ func NewInboundWebsocket(ctx context.Context, conn net.Conn, config *conf.Global
return transport, nil
}
tlsConfig := &tls.Config{
Certificates: config.TLS.KeyPair,
CipherSuites: config.TLS.CipherSuites,
PreferServerCipherSuites: config.TLS.PreferServerCipher,
SessionTicketsDisabled: !config.TLS.SessionTicket,
Certificates: config.Websocket.TLS.KeyPair,
CipherSuites: config.Websocket.TLS.CipherSuites,
PreferServerCipherSuites: config.Websocket.TLS.PreferServerCipher,
SessionTicketsDisabled: !config.Websocket.TLS.SessionTicket,
}
tlsConn := tls.Server(transport, tlsConfig)
protocol.SetRandomizedTimeout(tlsConn)
Expand Down
3 changes: 2 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package version
import (
"flag"
"fmt"
"runtime"

"github.com/p4gefau1t/trojan-go/common"
)
Expand All @@ -22,7 +23,7 @@ func (*versionOption) Priority() int {

func (c *versionOption) Handle() error {
if *c.arg {
fmt.Println("Trojan-Go", common.Version)
fmt.Println("Trojan-Go", common.Version, fmt.Sprintf("(%s %s/%s)", runtime.Version(), runtime.GOOS, runtime.GOARCH))
fmt.Println("Developed by PageFault (p4gefau1t)")
fmt.Println("Lisensed under GNU General Public License v3")
fmt.Println("GitHub Repository: https://github.com/p4gefau1t/trojan-go")
Expand Down

0 comments on commit ae349f8

Please sign in to comment.