Merge pull request #98 from HyNetwork/wip-no-cgo

Allow build with CGO_ENABLED=0 by disable TUN Mode
This commit is contained in:
Toby 2021-07-08 09:51:01 -07:00 committed by GitHub
commit d866f474bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 0 deletions

View File

@ -1,3 +1,5 @@
// +build cgo
package tun
import (

44
pkg/tun/server_fake.go Normal file
View File

@ -0,0 +1,44 @@
// +build !cgo
package tun
import (
"errors"
"github.com/tobyxdd/hysteria/pkg/acl"
"github.com/tobyxdd/hysteria/pkg/core"
"github.com/tobyxdd/hysteria/pkg/transport"
"io"
"net"
"time"
)
type Server struct {
HyClient *core.Client
Timeout time.Duration
TunDev io.ReadWriteCloser
Transport transport.Transport
ACLEngine *acl.Engine
RequestFunc func(addr net.Addr, reqAddr string, action acl.Action, arg string)
ErrorFunc func(addr net.Addr, reqAddr string, err error)
}
const (
MTU = 1500
)
func NewServerWithTunDev(hyClient *core.Client, transport transport.Transport,
timeout time.Duration,
tunDev io.ReadWriteCloser) (*Server, error) {
return nil, errors.New("TUN mode is not available when build with CGO_ENABLED=0")
}
func NewServer(hyClient *core.Client, transport transport.Transport,
timeout time.Duration,
name, address, gateway, mask string, dnsServers []string, persist bool) (*Server, error) {
return nil, errors.New("TUN mode is not available when build with CGO_ENABLED=0")
}
func (s *Server) ListenAndServe() error {
panic("not implemented!")
}

View File

@ -1,3 +1,5 @@
// +build cgo
package tun
import (

View File

@ -1,3 +1,5 @@
// +build cgo
package tun
import (