mirror of
https://github.com/go-i2p/goSam.git
synced 2025-07-13 06:07:42 -04:00
702cc4d699bda4263a40fcc7ad832b172bb4ccd1

* replyParser had a bug where, when a base64 address ended with '==', the key-value pairs would break. I worked around the issue by switching '==' it with a non-base64 character before the split, and back after. * switch to strings.SplitN and apply gofmt, add test * I don't know exactly why, but checking that the kvPair in replyParser.go is not nil fixes the crash on image-heavy sites. * added new configuration options for host, port, address, and debugging * Fix commit history * added tunnel length control features * added tunnel length control defaults * added length variance feature * added tunnel quantity option * added backup tunnel quantity option * added leaseset configuration options * gofmt * add new options to session establishment commands & gofmt * Reference the change to the debug global in the httpTest.go example * Switch to less than or equal to 16 tunnels at a time. * add in the comments I forgot to do. * add in the comments I forgot to do. * Improved formatting with linter. * Improved formatting with linter. * Ditch interfaces in the functional arguments, instead use different functions for the string and int-based variations. * Fixed broken option * added in missing formatting directive. * change addr to host in client so names are consistent. * change TestClientLookupInvalid back.
goSam
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.
Installation
go get github.com/cryptix/goSam
Using it for HTTP Transport
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)
}
}
TODO
- Implement
STREAM ACCEPT
andSTREAM FORWARD
- Implement datagrams (Repliable and Anon)
Languages
Go
83.4%
HTML
11.5%
CSS
4.3%
Makefile
0.8%