2014-06-26 02:35:25 +02:00
|
|
|
# README #
|
|
|
|
|
2022-08-28 13:40:47 -04:00
|
|
|
STATUS: This project is maintained. I will respond to issues, pull requests, and feature requests within a few days.
|
|
|
|
|
2024-11-14 10:43:00 -05:00
|
|
|
[](https://goreportcard.com/report/github.com/go-i2p/sam3)
|
|
|
|
|
2022-03-10 01:02:13 -05:00
|
|
|
# README #
|
|
|
|
|
2014-07-01 17:02:33 +02:00
|
|
|
go library for the I2P [SAMv3.0](https://geti2p.net/en/docs/api/samv3) bridge, used to build anonymous/pseudonymous end-to-end encrypted sockets.
|
2014-06-26 02:35:25 +02:00
|
|
|
|
|
|
|
This library is much better than ccondom (that use BOB), much more stable and much easier to maintain.
|
|
|
|
|
|
|
|
## Support/TODO ##
|
|
|
|
|
|
|
|
**What works:**
|
|
|
|
|
|
|
|
* Utils
|
2014-06-29 21:01:46 +02:00
|
|
|
* Resolving domain names to I2P destinations
|
2014-06-26 02:36:27 +02:00
|
|
|
* .b32.i2p hashes
|
|
|
|
* Generating keys/i2p destinations
|
2014-06-26 02:35:25 +02:00
|
|
|
* Streaming
|
2014-06-26 02:36:27 +02:00
|
|
|
* DialI2P() - Connecting to stuff in I2P
|
|
|
|
* Listen()/Accept() - Handling incomming connections
|
2014-06-29 19:58:34 +02:00
|
|
|
* Implements net.Conn and net.Listener
|
|
|
|
* Datagrams
|
|
|
|
* Implements net.PacketConn
|
2014-06-29 21:01:46 +02:00
|
|
|
* Raw datagrams
|
|
|
|
* Like datagrams, but without addresses
|
2014-06-26 02:35:25 +02:00
|
|
|
|
|
|
|
**Does not work:**
|
|
|
|
|
2021-10-04 21:00:03 -04:00
|
|
|
* Stream Forwarding
|
2014-06-29 21:01:46 +02:00
|
|
|
* Probably needs some real-world testing
|
2014-06-26 02:35:25 +02:00
|
|
|
|
|
|
|
## Documentation ##
|
|
|
|
|
2014-07-01 17:00:25 +02:00
|
|
|
* Latest version-documentation:
|
|
|
|
* set your GOPATH
|
|
|
|
* Enter `godoc -http=:8081` into your terminal and hit enter.
|
|
|
|
* Goto http://localhost:8081, click packages, and navigate to sam3
|
2014-06-26 02:35:25 +02:00
|
|
|
|
2014-06-29 21:01:46 +02:00
|
|
|
## Examples ##
|
2014-06-29 21:04:12 +02:00
|
|
|
```go
|
2014-06-29 21:01:46 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-14 10:43:00 -05:00
|
|
|
"github.com/go-i2p/sam3"
|
|
|
|
"github.com/go-i2p/sam3/i2pkeys"
|
2014-06-29 21:01:46 +02:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const yoursam = "127.0.0.1:7656" // sam bridge
|
|
|
|
|
2021-10-04 21:00:03 -04:00
|
|
|
func client(server i2pkeys.I2PAddr) {
|
|
|
|
sam, _ := sam3.NewSAM(yoursam)
|
2014-06-29 21:01:46 +02:00
|
|
|
keys, _ := sam.NewKeys()
|
2021-10-04 21:00:03 -04:00
|
|
|
stream, _ := sam.NewStreamSession("clientTun", keys, sam3.Options_Small)
|
2014-06-29 21:01:46 +02:00
|
|
|
fmt.Println("Client: Connecting to " + server.Base32())
|
|
|
|
conn, _ := stream.DialI2P(server)
|
|
|
|
conn.Write([]byte("Hello world!"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
sam, _ := NewSAM(yoursam)
|
|
|
|
keys, _ := sam.NewKeys()
|
2021-10-04 21:00:03 -04:00
|
|
|
stream, _ := sam.NewStreamSession("serverTun", keys, sam3.Options_Medium)
|
2020-12-14 21:43:04 -05:00
|
|
|
listener, _ := stream.Listen()
|
2014-06-29 21:01:46 +02:00
|
|
|
go client(keys.Addr())
|
|
|
|
conn, _ := listener.Accept()
|
|
|
|
buf := make([]byte, 4096)
|
2014-06-29 21:16:02 +02:00
|
|
|
n, _ := conn.Read(buf)
|
2014-06-29 21:01:46 +02:00
|
|
|
fmt.Println("Server received: " + string(buf[:n]))
|
|
|
|
}
|
2014-06-29 21:04:12 +02:00
|
|
|
```
|
2014-06-29 21:01:46 +02:00
|
|
|
|
|
|
|
The above will write to the terminal:
|
|
|
|
|
|
|
|
```text
|
|
|
|
Client: Connecting to zjnvfh4hs3et5vtz35ogwzrws26zvwkcad5uo5esecvg4qpk5b4a.b32.i2p
|
|
|
|
Server received: Hello world!
|
|
|
|
```
|
|
|
|
|
|
|
|
Error handling was omitted in the above code for readability.
|
|
|
|
|
2014-06-26 02:35:25 +02:00
|
|
|
## Testing ##
|
|
|
|
|
2019-05-18 18:21:01 -04:00
|
|
|
* `go test -tags=nettest` runs the whole suite (takes 90+ sec to perform!)
|
2014-06-29 21:01:46 +02:00
|
|
|
* `go test -short` runs the shorter variant, does not connect to anything
|
2014-06-26 02:35:25 +02:00
|
|
|
|
2024-10-17 14:42:19 -04:00
|
|
|
## Verbosity ##
|
|
|
|
Logging can be enabled and configured using the DEBUG_I2P environment variable. By default, logging is disabled.
|
|
|
|
|
|
|
|
There are three available log levels:
|
|
|
|
|
|
|
|
- Debug
|
|
|
|
```shell
|
|
|
|
export DEBUG_I2P=debug
|
|
|
|
```
|
|
|
|
- Warn
|
|
|
|
```shell
|
|
|
|
export DEBUG_I2P=warn
|
|
|
|
```
|
|
|
|
- Error
|
|
|
|
```shell
|
|
|
|
export DEBUG_I2P=error
|
|
|
|
```
|
|
|
|
|
2024-11-02 22:20:52 -04:00
|
|
|
If DEBUG_I2P is set to an unrecognized variable, it will fall back to "debug".
|
2024-10-17 14:42:19 -04:00
|
|
|
|
2014-06-26 02:35:25 +02:00
|
|
|
## License ##
|
|
|
|
|
|
|
|
Public domain.
|
|
|
|
|
2015-10-15 17:21:11 -04:00
|
|
|
## Author ##
|
2014-06-26 02:35:25 +02:00
|
|
|
|
2015-11-07 09:20:02 +00:00
|
|
|
* Kalle Vedin `kalle.vedin@fripost.org`
|
2019-05-18 18:21:01 -04:00
|
|
|
* Unknown Name (majestrate)
|
2020-10-18 01:04:40 -04:00
|
|
|
* idk
|
|
|
|
* qiwenmin
|