monlor / MIXBOX-ARCHIVE

一款基于Shell的小米路由器工具箱,原为Monlor-Tools,A tool box for XiaoMi Router base on Shell.
GNU General Public License v3.0
2.26k stars 374 forks source link

小米自带的 curl 证书有问题,用go写了个get工具替换 #209

Open cocotyty opened 3 years ago

cocotyty commented 3 years ago

curl 总是报这个错误

我用go写了个简易版本,自带根证书

package main
import "os"
import "fmt"
import "github.com/alexflint/stdroots"
import "io"
func main(){
    if len(os.Args) != 3{
        os.Exit(1)
    }
    resp,err:=stdroots.Client.Get(os.Args[1])
    if err!=nil{
        fmt.Println(err)
        os.Exit(1)
    }
    file,err:=os.Create(os.Args[2])
    if err!=nil{
        fmt.Println("error:",err)   
        os.Exit(1)
    }
    fmt.Println(resp.StatusCode)
    io.Copy(file,resp.Body)
}
GOARCH=mipsle GOOS=linux go build -o httpget main.go && cp ./httpget  root@192.168.31.1:/etc/mixbox/bin

可以作为 wgetsh 这个方法的实现之一

skinnyshy commented 2 years ago

main.go:4:8: cannot find package "github.com/alexflint/stdroots" in any of: /usr/local/go/src/github.com/alexflint/stdroots (from $GOROOT) /root/go/src/github.com/alexflint/stdroots (from $GOPATH) [root@MiWiFi-R3G-srv scritps]# vim main.go