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