func main() {
	// if we weren't called with any args, provide syntax
	if len(os.Args) <= 1 {
		syntax()
		return
	}

	// normalize our commandline
	argc := strings.ToLower(os.Args[1])

	// process the main command line switches and exit
	switch argc {
	case "version":
		version()
		return

	case "help":
		syntax()
		return

	case "checkconfig":
		checkConfig()
		return
	}

	// pull the registration information for our target executable
	// TODO: lets replace this with checkConfig in the future
	targetExe, err := walk.RegistryKeyString(walk.ClassesRootKey(), "starsiege", "Executable")
	if err != nil {
		debugError("Unable to find key HKCR\\starsiege\\Executable")
		return
	}

	// get the path for the executable
	targetFilePath := filepath.Dir(targetExe)

	// continue parsing our command line
	u, err := url.Parse(argc)
	if err != nil {
		debugError("Unable to parse URI")
		return
	}

	// did we accidentally get sent something we can't handle?
	if u.Scheme != "starsiege" {
		debugError("Invalid URI scheme")
		return
	}

	// split the host:port combination up
	host, port, err := net.SplitHostPort(u.Host)
	if err != nil {
		debugError("Unable to parse host and port")
		return
	}

	// sanity check the ip address
	// TODO: support for hostnames in the future, would likely require a DNS lookup
	ip := net.ParseIP(host)
	if ip == nil {
		debugError("Invalid IP address provided")
		return
	}

	// ensure the port is between 1 and 65535 [16 bits]
	uintport, err := strconv.ParseUint(port, 10, 16)
	if err != nil || uintport == 0 {
		debugError("Invalid port provided")
		return
	}

	// prepare our final arguments
	args := fmt.Sprintf("+connect IP:%s:%d", ip.String(), uintport)

	// display a preview of the shellexec call if debugging
	if DEBUG != "" {
		result := win.MessageBox(win.HWND_DESKTOP, L(targetExe, args), L("Execute?"), win.MB_OKCANCEL|win.MB_ICONQUESTION)
		if result != win.IDOK {
			return
		}
	}

	// yeet
	win.ShellExecute(win.HWND_DESKTOP, L(""), L(targetExe), L(args), L(targetFilePath), win.SW_SHOW)
}
// main is the body of the program
// technical note: by and large we fail silently, unless we're debugging
main is the body of the program
technical note: by and large we fail silently, unless we're debugging
// main is the body of the program // technical note : by and large we fail silently unless we ' re debugging
func main() {
	if len(os.Args) <= 1 {
		syntax()
		return
	}
	argc := strings.ToLower(os.Args[1])
	switch argc {
	case "version":
		version()
		return
	case "help":
		syntax()
		return
	case "checkconfig":
		checkConfig()
		return
	}
	targetExe, err := walk.RegistryKeyString(walk.ClassesRootKey(), "starsiege", "Executable")
	if err != nil {
		debugError("Unable to find key HKCR\\starsiege\\Executable")
		return
	}
	targetFilePath := filepath.Dir(targetExe)
	u, err := url.Parse(argc)
	if err != nil {
		debugError("Unable to parse URI")
		return
	}
	if u.Scheme != "starsiege" {
		debugError("Invalid URI scheme")
		return
	}
	host, port, err := net.SplitHostPort(u.Host)
	if err != nil {
		debugError("Unable to parse host and port")
		return
	}
	ip := net.ParseIP(host)
	if ip == nil {
		debugError("Invalid IP address provided")
		return
	}
	uintport, err := strconv.ParseUint(port, 10, 16)
	if err != nil || uintport == 0 {
		debugError("Invalid port provided")
		return
	}
	args := fmt.Sprintf("+connect IP:%s:%d", ip.String(), uintport)
	if DEBUG != "" {
		result := win.MessageBox(win.HWND_DESKTOP, L(targetExe, args), L("Execute?"), win.MB_OKCANCEL|win.MB_ICONQUESTION)
		if result != win.IDOK {
			return
		}
	}
	win.ShellExecute(win.HWND_DESKTOP, L(""), L(targetExe), L(args), L(targetFilePath), win.SW_SHOW)
}
func main ( ) { if len ( os . Args ) <= 1 { syntax ( ) return } argc := strings . ToLower ( os . Args [ 1 ] ) switch argc { case " " : version ( ) return case " " : syntax ( ) return case " " : checkConfig ( ) return } targetExe , err := walk . RegistryKeyString ( walk . ClassesRootKey ( ) , " " , " " ) if err != nil { debugError ( " \\ \\ " ) return } targetFilePath := filepath . Dir ( targetExe ) u , err := url . Parse ( argc ) if err != nil { debugError ( " " ) return } if u . Scheme != " " { debugError ( " " ) return } host , port , err := net . SplitHostPort ( u . Host ) if err != nil { debugError ( " " ) return } ip := net . ParseIP ( host ) if ip == nil { debugError ( " " ) return } uintport , err := strconv . ParseUint ( port , 10 , 16 ) if err != nil || uintport == 0 { debugError ( " " ) return } args := fmt . Sprintf ( " " , ip . String ( ) , uintport ) if DEBUG != " " { result := win . MessageBox ( win . HWND_DESKTOP , L ( targetExe , args ) , L ( " " ) , win . MB_OKCANCEL | win . MB_ICONQUESTION ) if result != win . IDOK { return } } win . ShellExecute ( win . HWND_DESKTOP , L ( " " ) , L ( targetExe ) , L ( args ) , L ( targetFilePath ) , win . SW_SHOW ) }
main is the body of the program
technical note: by and large we fail silently, unless we're debugging
main is the body of the program technical note : by and large we fail silently unless we ' re debugging
// if we weren't called with any args, provide syntax // normalize our commandline // process the main command line switches and exit // pull the registration information for our target executable // TODO: lets replace this with checkConfig in the future // get the path for the executable // continue parsing our command line // did we accidentally get sent something we can't handle? // split the host:port combination up // sanity check the ip address // TODO: support for hostnames in the future, would likely require a DNS lookup // ensure the port is between 1 and 65535 [16 bits] // prepare our final arguments // display a preview of the shellexec call if debugging // yeet