Jorropo 79071510cf Fixing version check (#12) | il y a 4 ans | |
---|---|---|
example | il y a 6 ans | |
.gitignore | il y a 10 ans | |
LICENSE | il y a 10 ans | |
README.md | il y a 10 ans | |
accept.go | il y a 6 ans | |
client.go | il y a 4 ans | |
client_test.go | il y a 6 ans | |
dial.go | il y a 6 ans | |
go.mod | il y a 4 ans | |
go.sum | il y a 6 ans | |
naming.go | il y a 9 ans | |
naming_test.go | il y a 6 ans | |
options.go | il y a 6 ans | |
options_test.go | il y a 6 ans | |
replyParser.go | il y a 6 ans | |
replyParser_test.go | il y a 6 ans | |
sessions.go | il y a 6 ans | |
stream.go | il y a 9 ans |
A go library for using the I2P Simple Anonymous Messaging (SAM version 3.0) bridge
This is in an early development stage. I would love to hear about any issues or ideas for improvement.
go get github.com/cryptix/goSam
I implemented Client.Dial
like net.Dial
so you can use go's library packages like http.
package main
import (
"io"
"log"
"net/http"
"os"
"github.com/cryptix/goSam"
)
func main() {
// create a default sam client
sam, err := goSam.NewDefaultClient()
checkErr(err)
log.Println("Client Created")
// create a transport that uses SAM to dial TCP Connections
tr := &http.Transport{
Dial: sam.Dial,
}
// create a client using this transport
client := &http.Client{Transport: tr}
// send a get request
resp, err := client.Get("http://stats.i2p/")
checkErr(err)
defer resp.Body.Close()
log.Printf("Get returned %+v\n", resp)
// create a file for the response
file, err := os.Create("stats.html")
checkErr(err)
defer file.Close()
// copy the response to the file
_, err = io.Copy(file, resp.Body)
checkErr(err)
log.Println("Done.")
}
func checkErr(err error) {
if err != nil {
log.Fatal(err)
}
}
STREAM ACCEPT
and STREAM FORWARD