Add an option to disable IPv6

This commit is contained in:
Matt Joiner 2015-08-05 02:41:50 +10:00
parent 085be622a0
commit 497d185373
2 changed files with 15 additions and 2 deletions

View File

@ -499,7 +499,13 @@ func NewClient(cfg *Config) (cl *Client, err error) {
}
if !cl.config.DisableTCP {
var l net.Listener
l, err = net.Listen("tcp", listenAddr())
l, err = net.Listen(func() string {
if cl.config.DisableIPv6 {
return "tcp4"
} else {
return "tcp"
}
}(), listenAddr())
if err != nil {
return
}
@ -507,7 +513,13 @@ func NewClient(cfg *Config) (cl *Client, err error) {
go cl.acceptConnections(l, false)
}
if !cl.config.DisableUTP {
cl.utpSock, err = utp.NewSocket(listenAddr())
cl.utpSock, err = utp.NewSocket(func() string {
if cl.config.DisableIPv6 {
return "udp4"
} else {
return "udp"
}
}(), listenAddr())
if err != nil {
return
}

View File

@ -46,4 +46,5 @@ type Config struct {
DisableEncryption bool `long:"disable-encryption"`
IPBlocklist *iplist.IPList
DisableIPv6 bool
}