Obfuscator interface in core & relay/proxy CLI support

This commit is contained in:
Toby
2020-04-23 14:43:12 -07:00
parent c441afea35
commit 5ebe556d8d
11 changed files with 145 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/lucas-clemente/quic-go/congestion"
hyCongestion "github.com/tobyxdd/hysteria/pkg/congestion"
"github.com/tobyxdd/hysteria/pkg/core"
"github.com/tobyxdd/hysteria/pkg/obfs"
"io"
"log"
"net"
@@ -55,11 +56,17 @@ func proxyServer(args []string) {
log.Println("WARNING: No authentication configured. This server can be used by anyone!")
}
var obfuscator core.Obfuscator
if len(config.Obfs) > 0 {
obfuscator = obfs.XORObfuscator(config.Obfs)
}
server, err := core.NewServer(config.ListenAddr, tlsConfig, quicConfig,
uint64(config.UpMbps)*mbpsToBps, uint64(config.DownMbps)*mbpsToBps,
func(refBPS uint64) congestion.SendAlgorithmWithDebugInfos {
return hyCongestion.NewBrutalSender(congestion.ByteCount(refBPS))
},
obfuscator,
func(addr net.Addr, username string, password string, sSend uint64, sRecv uint64) (core.AuthResult, string) {
if len(config.AuthFile) == 0 {
log.Printf("%s (%s) connected, negotiated speed (Mbps): Up %d / Down %d\n",