mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-13 20:44:12 +08:00
19 lines
329 B
Go
19 lines
329 B
Go
package route
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
func AddRoute(dest, netmask, gateway string) error {
|
|
out, err := exec.Command("route", "add", dest, gateway, "-netmask", netmask).Output()
|
|
if err != nil {
|
|
if len(out) != 0 {
|
|
return errors.New(fmt.Sprintf("%v, output: %s", err, out))
|
|
}
|
|
return err
|
|
}
|
|
return nil
|
|
}
|