fix tun for darwin
This commit is contained in:
parent
be1f050250
commit
18a515a5eb
@ -450,6 +450,7 @@ func (r *route) GenRouters() ([]router, error) {
|
||||
cfg := gost.TunConfig{
|
||||
Name: node.Get("name"),
|
||||
Addr: node.Get("net"),
|
||||
Peer: node.Get("peer"),
|
||||
MTU: node.GetInt("mtu"),
|
||||
Routes: tunRoutes,
|
||||
Gateway: node.Get("gw"),
|
||||
|
@ -48,6 +48,7 @@ type IPRoute struct {
|
||||
type TunConfig struct {
|
||||
Name string
|
||||
Addr string
|
||||
Peer string // peer addr of point-to-point on MacOS
|
||||
MTU int
|
||||
Routes []IPRoute
|
||||
Gateway string
|
||||
|
@ -29,7 +29,12 @@ func createTun(cfg TunConfig) (conn net.Conn, itf *net.Interface, err error) {
|
||||
mtu = DefaultMTU
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf("ifconfig %s inet %s mtu %d up", ifce.Name(), cfg.Addr, mtu)
|
||||
peer := cfg.Peer
|
||||
if peer == "" {
|
||||
peer = ip.String()
|
||||
}
|
||||
cmd := fmt.Sprintf("ifconfig %s inet %s %s mtu %d up",
|
||||
ifce.Name(), cfg.Addr, peer, mtu)
|
||||
log.Log("[tun]", cmd)
|
||||
args := strings.Split(cmd, " ")
|
||||
if er := exec.Command(args[0], args[1:]...).Run(); er != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user