github.com/Psiphon-Labs/tls-tris@v0.0.0-20230824155421-58bf6d336a9a/_dev/mint/mint-client.go (about)

     1  package main
     2  
     3  import (
     4  	"log"
     5  	"net"
     6  	"net/http"
     7  	"os"
     8  
     9  	"github.com/bifurcation/mint"
    10  )
    11  
    12  func main() {
    13  	c := &mint.Config{
    14  		PSKs: &mint.PSKMapCache{},
    15  	}
    16  
    17  	tr := &http.Transport{
    18  		DialTLS: func(network, addr string) (net.Conn, error) {
    19  			return mint.Dial(network, addr, c)
    20  		},
    21  		DisableKeepAlives: true,
    22  	}
    23  	client := &http.Client{Transport: tr}
    24  
    25  	resp, err := client.Get("https://" + os.Args[1])
    26  	if err != nil {
    27  		log.Fatal(err)
    28  	}
    29  	if err := resp.Write(os.Stdout); err != nil {
    30  		log.Fatal(err)
    31  	}
    32  
    33  	// Resumption
    34  	resp, err = client.Get("https://" + os.Args[1])
    35  	if err != nil {
    36  		log.Fatal(err)
    37  	}
    38  	if err := resp.Write(os.Stdout); err != nil {
    39  		log.Fatal(err)
    40  	}
    41  }