mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
[fix]
This commit is contained in:
parent
82c8e02d02
commit
e2a0437685
|
@ -79,7 +79,7 @@ func patchConfigs(w http.ResponseWriter, r *http.Request) {
|
|||
P.ReCreateMixed(pointerOrDefault(general.MixedPort, ports.MixedPort), tcpIn, udpIn)
|
||||
|
||||
if general.Tun != nil {
|
||||
err := P.ReCreateTun(*general.Tun, nil, nil)
|
||||
err := P.ReCreateTun(*general.Tun, tcpIn, udpIn)
|
||||
if err == nil {
|
||||
log.Infoln("Recreate tun success.")
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
|
@ -49,8 +50,10 @@ func addLinuxSystemRoute(net string) {
|
|||
return
|
||||
}
|
||||
cmd := exec.Command("route", "add", "-net", net, "198.18.0.1")
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Errorln("[auto route] Failed to add system route: %s, cmd: %s", err.Error(), cmd.String())
|
||||
log.Errorln("[auto route] Failed to add system route: %s: %s , cmd: %s", err.Error(), stderr.String(), cmd.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ type tunLinux struct {
|
|||
|
||||
// OpenTunDevice return a TunDevice according a URL
|
||||
func OpenTunDevice(tunAddress string, autoRoute bool) (TunDevice, error) {
|
||||
deviceURL, _ := url.Parse("dev://clash0")
|
||||
deviceURL, _ := url.Parse("dev://utun")
|
||||
mtu, _ := strconv.ParseInt(deviceURL.Query().Get("mtu"), 0, 32)
|
||||
|
||||
t := &tunLinux{
|
||||
|
@ -204,7 +204,7 @@ func (t *tunLinux) configInterface() error {
|
|||
}
|
||||
|
||||
// set netmask for tun
|
||||
netmask := []byte{255, 255, 255, 0}
|
||||
netmask := []byte{255, 255, 0, 0}
|
||||
copy(ifr[unix.IFNAMSIZ+4:], netmask)
|
||||
|
||||
_, _, errno = unix.Syscall(
|
||||
|
|
|
@ -50,7 +50,7 @@ func OpenTunDevice(tunAddress string, autoRoute bool) (TunDevice, error) {
|
|||
log.Warnln("Error parese GUID from string: %v", err)
|
||||
}
|
||||
|
||||
interfaceName := "Clash.Mini"
|
||||
interfaceName := "Meta Tunnel"
|
||||
mtu := 9000
|
||||
|
||||
tun, err := CreateTUN(interfaceName, mtu, tunAddress, autoRoute)
|
||||
|
|
|
@ -48,7 +48,7 @@ type gvisorAdapter struct {
|
|||
}
|
||||
|
||||
// GvisorAdapter create GvisorAdapter
|
||||
func NewAdapter(device dev.TunDevice, conf config.Tun, tunAddress string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.TunAdapter, error) {
|
||||
func NewAdapter(device dev.TunDevice, conf config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.TunAdapter, error) {
|
||||
ipstack := stack.New(stack.Options{
|
||||
NetworkProtocols: []stack.NetworkProtocolFactory{ipv4.NewProtocol, ipv6.NewProtocol},
|
||||
TransportProtocols: []stack.TransportProtocolFactory{tcp.NewProtocol, udp.NewProtocol},
|
||||
|
|
|
@ -47,7 +47,7 @@ func New(conf config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.Pack
|
|||
if strings.EqualFold(stack, "system") {
|
||||
tunAdapter, err = system.NewAdapter(device, conf, mtu, tunAddress, tunAddress, func() {}, tcpIn, udpIn)
|
||||
} else if strings.EqualFold(stack, "gvisor") {
|
||||
tunAdapter, err = gvisor.NewAdapter(device, conf, tunAddress, tcpIn, udpIn)
|
||||
tunAdapter, err = gvisor.NewAdapter(device, conf, tcpIn, udpIn)
|
||||
} else {
|
||||
err = fmt.Errorf("can not support tun ip stack: %s, only support \"lwip\" \"system\" and \"gvisor\"", stack)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user