Jorropo 79071510cf Fixing version check (#12) | %!s(int64=4) %!d(string=hai) anos | |
---|---|---|
example | %!s(int64=6) %!d(string=hai) anos | |
.gitignore | %!s(int64=10) %!d(string=hai) anos | |
LICENSE | %!s(int64=10) %!d(string=hai) anos | |
README.md | %!s(int64=10) %!d(string=hai) anos | |
accept.go | %!s(int64=6) %!d(string=hai) anos | |
client.go | %!s(int64=4) %!d(string=hai) anos | |
client_test.go | %!s(int64=6) %!d(string=hai) anos | |
dial.go | %!s(int64=6) %!d(string=hai) anos | |
go.mod | %!s(int64=4) %!d(string=hai) anos | |
go.sum | %!s(int64=6) %!d(string=hai) anos | |
naming.go | %!s(int64=9) %!d(string=hai) anos | |
naming_test.go | %!s(int64=6) %!d(string=hai) anos | |
options.go | %!s(int64=6) %!d(string=hai) anos | |
options_test.go | %!s(int64=6) %!d(string=hai) anos | |
replyParser.go | %!s(int64=6) %!d(string=hai) anos | |
replyParser_test.go | %!s(int64=6) %!d(string=hai) anos | |
sessions.go | %!s(int64=6) %!d(string=hai) anos | |
stream.go | %!s(int64=9) %!d(string=hai) anos |
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