示例#1
0
func main() {
	flag.Parse()

	booter, err := pickBooter()
	if err != nil {
		flag.Usage()
		fmt.Fprintf(os.Stderr, "\nERROR: %s\n", err)
		os.Exit(1)
	}

	pxelinux, err := Asset("lpxelinux.0")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	ldlinux, err := Asset("ldlinux.c32")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	go func() {
		addrDHCP := fmt.Sprintf("%s:%d", *listenAddr, *portDHCP)
		log.Fatalln(ServeProxyDHCP(addrDHCP, booter))
	}()
	go func() {
		addrPXE := fmt.Sprintf("%s:%d", *listenAddr, *portPXE)
		log.Fatalln(ServePXE(addrPXE, *portHTTP))
	}()
	go func() {
		addrTFTP := fmt.Sprintf("%s:%d", *listenAddr, *portTFTP)
		tftp.Log = func(msg string, args ...interface{}) { Log("TFTP", msg, args...) }
		tftp.Debug = func(msg string, args ...interface{}) { Debug("TFTP", msg, args...) }
		log.Fatalln(tftp.ListenAndServe("udp4", addrTFTP, tftp.Blob(pxelinux)))
	}()
	go func() {
		log.Fatalln(ServeHTTP(*listenAddr, *portHTTP, booter, ldlinux))
	}()
	RecordLogs(*debug)
}
示例#2
0
func main() {
	flag.Parse()

	booter, err := pickBooter()
	if err != nil {
		flag.Usage()
		fmt.Fprintf(os.Stderr, "\nERROR: %s\n", err)
		os.Exit(1)
	}

	pxelinux, err := assets.Asset("lpxelinux.0")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	ldlinux, err := assets.Asset("ldlinux.c32")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	go func() {
		log.Fatalln(dhcp.ServeProxyDHCP(*portDHCP, booter))
	}()
	go func() {
		log.Fatalln(pxe.ServePXE(*portPXE, *portHTTP))
	}()
	go func() {
		tftp.Log = func(msg string, args ...interface{}) { pixiecorelog.Log("TFTP", msg, args...) }
		tftp.Debug = func(msg string, args ...interface{}) { pixiecorelog.Debug("TFTP", msg, args...) }
		log.Fatalln(tftp.ListenAndServe("udp4", ":"+strconv.Itoa(*portTFTP), tftp.Blob(pxelinux)))
	}()
	go func() {
		log.Fatalln(http.ServeHTTP(*portHTTP, booter, ldlinux))
	}()
	pixiecorelog.RecordLogs(*debug)
}