1. Go run shell script or Go run shell string

curl := "curl -v https://const.net.cn"
cmd := exec.Command("bash", "-c", curl)
stdout, err := cmd.CombinedOutput()
if err != nil {
    fmt.Println("curl " + err.Error())
    return
}
fmt.Println(string(stdout)) 

2.输出结果

  • Uses proxy env variable https_proxy == 'socks5://127.0.0.1:1080'
  • Trying 127.0.0.1:1080...
  • TCP_NODELAY set % Total % Received % Xferd Average Speed Time Time Time Current

                                 Dload  Upload   Total   Spent    Left  Speed   0     0    0     0    0     0      0      0 --:--:-- --:--:--

    --:--:-- 0

  • SOCKS5 communication to const.net.cn:443
  • SOCKS5 connect to IPv4 43.129.233.128:443 (locally resolved)
  • SOCKS5 request granted.
  • Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs } [5 bytes data]
  • TLSv1.3 (OUT), TLS handshake, Client hello (1): } [512 bytes data]
  • TLSv1.3 (IN), TLS handshake, Server hello (2): { [122 bytes data]
  • TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): { [25 bytes data]
  • TLSv1.3 (IN), TLS handshake, Certificate (11): { [2780 bytes data]
  • TLSv1.3 (IN), TLS handshake, CERT verify (15): { [264 bytes data]
  • TLSv1.3 (IN), TLS handshake, Finished (20): { [52 bytes data]
  • TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): } [1 bytes data]
  • TLSv1.3 (OUT), TLS handshake, Finished (20): } [52 bytes data]
  • SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  • ALPN, server accepted to use http/1.1
  • Server certificate:
  • subject: CN=const.net.cn
  • start date: May 19 00:00:00 2021 GMT
  • expire date: May 18 23:59:59 2022 GMT
  • subjectAltName: host "const.net.cn" matched cert's "const.net.cn"
  • issuer: C=CN; O=TrustAsia Technologies, Inc.; OU=Domain Validated SSL; CN=TrustAsia TLS RSA CA
  • SSL certificate verify ok. } [5 bytes data]

GET / HTTP/1.1
Host: const.net.cn
User-Agent: curl/7.68.0
Accept: /

......

本文链接地址:https://const.net.cn/18.html

标签: shell

添加新评论