Ejemplo n.º 1
0
func (p *program) run() error {
	mtu.Init(configuration, icmpPackets)

	if len(os.Args) > 1 {
		command := os.Args[1]
		switch command {
		case "interactive", "i":
			log.Println("Interactive testing")
			if len(os.Args) > 2 {
				handleInteractiveArg(os.Args[2])
			} else {
				fmt.Println("Please specify an additional argument when using 'ipsecdiagtool " + command + "'")
				fmt.Println("Use 'ipsecdiagtool help' to get additional information.")
			}
		}
	} else {
		go packetloss.Detect(configuration, ipsecPackets, false)
		capture.Start(configuration, icmpPackets, ipsecPackets)

		/*
			//Code tested in the IDE could be placed here
			if configuration.Debug {
				log.Println("WARNING DEBUG ENABLES IDE TEST CODE.")
				//Code tested directly in the IDE belongs in here
				go mtu.FindAll()
			}*/
	}

	if configuration.Debug {
		log.Println("Running Daemon via", service.Platform())
	}
	<-p.exit
	return nil
}
Ejemplo n.º 2
0
func handleInteractiveArg(arg string) {
	switch arg {
	case "mtu", "m":
		capture.Start(configuration, icmpPackets, ipsecPackets)
		go mtu.FindAll()
	case "packetloss", "p", "pl":
		if len(os.Args) > 3 {
			pcapPath := os.Args[3]
			configuration.PcapFile = pcapPath
			log.Println("Reading packetloss test data from file.")
		}
		if configuration.PcapFile == "" {
			log.Println("Detecting packetloss from ethernet")
		} else {
			log.Println("Detecting packetloss from configured file:", configuration.PcapFile)
		}
		go packetloss.Detect(configuration, ipsecPackets, true)
		capture.Start(configuration, icmpPackets, ipsecPackets)
	default:
		fmt.Println("Command", arg, "not recognized")
		fmt.Println("See 'ipsecdiagtool help' for additional information.")
	}
}