aria2 是命令行下载工具, 使用不方便,添加了个web服务, 双击可以直接运行。
下载地址:http://pan.baidu.com/s/1slVtGct
源码如下:
// aria2web project main.go
package main
import (
"aria2web/ui"
"flag"
"os/exec"
"syscall"
"web"
"github.com/astaxie/beego/logs"
)
var paramHttpAddr = flag.String("httpaddr", ":80", "The address of server.")
var paramHttpRoot = flag.String("root", "www", "The address of server.")
var paramLogLevel = flag.Int("level", 6, "The level of log.")
func main() {
flag.Parse()
logs.SetLevel(logs.LevelInfo)
logs.SetLogFuncCall(true)
logs.SetLogFuncCallDepth(3)
logs.SetLogger(logs.AdapterConsole)
logs.SetLogger("file", `{"filename":"app.log"}`)
cmd := exec.Command("aria2c.exe", "--conf-path=aria2.conf")
cmd.SysProcAttr = new(syscall.SysProcAttr)
cmd.SysProcAttr.HideWindow = true
err := cmd.Start()
if err != nil {
logs.Fatal(err)
}
go web.Run(*paramHttpAddr, *paramHttpRoot)
ui.Run()
}