Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cryptix/goSam
A go library for using the I2P Simple Anonymous Messaging (SAM version 3.0) bridge
https://github.com/cryptix/goSam
Last synced: 5 days ago
JSON representation
A go library for using the I2P Simple Anonymous Messaging (SAM version 3.0) bridge
- Host: GitHub
- URL: https://github.com/cryptix/goSam
- Owner: cryptix
- License: gpl-2.0
- Created: 2014-02-09T13:40:28.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-12-23T11:08:48.000Z (almost 5 years ago)
- Last Synced: 2024-11-08T16:55:18.359Z (12 days ago)
- Language: Go
- Size: 39.1 KB
- Stars: 40
- Watchers: 4
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-i2p - goSam - A go library for using the I2P Simple Anonymous Messaging (SAM version 3.0) bridge. (Libraries / I2Pd)
README
goSam
=====A go library for using the [I2P](https://geti2p.net/en/) Simple Anonymous Messaging ([SAM version 3.0](https://geti2p.net/en/docs/api/samv3)) 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.
```go
package mainimport (
"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` and `STREAM FORWARD`
* Implement datagrams (Repliable and Anon)