Implement TUN, no ACL support yet

This commit is contained in:
Haruue Icymoon
2021-04-24 20:18:58 +08:00
parent 89b9ec2acf
commit 13ec19cbfe
9 changed files with 266 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/tobyxdd/hysteria/pkg/socks5"
"github.com/tobyxdd/hysteria/pkg/tproxy"
"github.com/tobyxdd/hysteria/pkg/transport"
"github.com/tobyxdd/hysteria/pkg/tun"
"io"
"io/ioutil"
"net"
@@ -188,6 +189,17 @@ func client(config *clientConfig) {
}()
}
if len(config.TUN.Name) != 0 {
go func() {
tunServer, err := tun.NewServer(client, time.Duration(config.TUN.Timeout)*time.Second,
config.TUN.Name, config.TUN.Address, config.TUN.Gateway, config.TUN.Mask, config.TUN.DNS, config.TUN.Persist)
if err != nil {
logrus.WithField("error", err).Fatal("Failed to initialize TUN server")
}
errChan <- tunServer.ListenAndServe()
}()
}
if len(config.TCPRelay.Listen) > 0 {
go func() {
rl, err := relay.NewTCPRelay(client, transport.DefaultTransport,