func TestInterfaceName(t *testing.T) {
	fmt.Println("**********TestInterfaceName**********")
	configuration := config.LoadConfig()
	configuration.InterfaceName = "test"
	if err := Detect(configuration); err != nil {
		// handle err
		fmt.Println("err: ", err)
		fmt.Println("**********TestInterfaceName OK**********")
	} else {
		t.Error("Wrong Interfacename not detected!")
	}
}
示例#2
0
// Service setup.
//   Define service config.
//   Create the service.
//   Setup the logger.
//   Handle service controls (optional).
//   Run the service.
func main() {
	//Load configuration
	path, err := osext.ExecutableFolder()
	check(err)
	configuration = config.LoadConfig(path)

	//Check args for installation, needs to be done before the service is started.
	if len(os.Args) > 1 {
		command := os.Args[1]
		switch command {
		case "install":
			chooseService("install")
			s := initService()
			installService(s)
		case "uninstall", "remove":
			chooseService("uninstall")
			s := initService()
			uninstallService(s)
		case "interactive", "i":
			s := initService()
			err = s.Run()
		case "mtu-discovery", "mtu":
			var srcIP, dstIP string
			if len(os.Args) > 3 {
				srcIP = os.Args[2]
				dstIP = os.Args[3]
			} else {
				srcIP, dstIP = "127.0.0.1", "127.0.0.1"
			}
			mtu.RequestDaemonMTU(configuration.ApplicationID, srcIP, dstIP)
			log.Println("The daemon was triggered to start MTU Discovery for all configured tunnels.")
		case "about", "a":
			printAbout()
		case "debug", "d":
			printDebug(configuration)
		case "help", "--help", "h":
			printHelp()
		default:
			fmt.Println("Argument not reconized. Run 'ipsecdiagtool help' to learn how to use this application.")
		}
	} else {
		s := initService()
		err = s.Run()
	}
	check(err)
}