Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cd2a4f072e | ||
![]() |
818b5249bc | ||
![]() |
83f9866de4 | ||
![]() |
b4293f755e | ||
![]() |
2bde2687b3 | ||
![]() |
19d8d8e4a8 | ||
![]() |
1cec982a61 | ||
![]() |
b2df466212 | ||
![]() |
bf2a12d78d | ||
![]() |
760e0b44b2 | ||
![]() |
9b7a798782 | ||
![]() |
3dc49e391d | ||
![]() |
b08d519a17 | ||
![]() |
256aaa7430 | ||
![]() |
197aca0ece | ||
![]() |
fff37dbffa | ||
![]() |
dfd7cd886f | ||
![]() |
c998e57a89 | ||
![]() |
41317685c5 |
5
Makefile
5
Makefile
@@ -1,13 +1,14 @@
|
||||
|
||||
USER_GH=eyedeekay
|
||||
VERSION=0.33.4
|
||||
VERSION=0.33.8
|
||||
CREDIT='contributors to this release: @hkh4n, @eyedeekay'
|
||||
packagename=sam3
|
||||
|
||||
echo:
|
||||
@echo "type make version to do release $(VERSION)"
|
||||
|
||||
version:
|
||||
github-release release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "version $(VERSION)"
|
||||
github-release release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "version $(VERSION) $(CREDIT)"
|
||||
|
||||
del:
|
||||
github-release delete -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION)
|
||||
|
@@ -10,6 +10,8 @@ before upgrading your sam3 dependencies. You can probably do this by running:
|
||||
find . -name '*.go' -exec sed -i 's|github.com/eyedeekay/sam3/i2pkeys|github.com/eyedeekay/i2pkeys|g' {} \;
|
||||
```
|
||||
|
||||
STATUS: This project is maintained. I will respond to issues, pull requests, and feature requests within a few days.
|
||||
|
||||
# README #
|
||||
|
||||
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.
|
||||
|
15
config.go
15
config.go
@@ -51,6 +51,8 @@ type I2PConfig struct {
|
||||
ReduceIdle string
|
||||
ReduceIdleTime string
|
||||
ReduceIdleQuantity string
|
||||
LeaseSetEncryption string
|
||||
|
||||
//Streaming Library options
|
||||
AccessListType string
|
||||
AccessList []string
|
||||
@@ -234,6 +236,7 @@ func (f *I2PConfig) Print() []string {
|
||||
lsk, lspk, lspsk,
|
||||
f.Accesslisttype(),
|
||||
f.Accesslist(),
|
||||
f.LeaseSetEncryptionType(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +262,18 @@ func (f *I2PConfig) Accesslist() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *I2PConfig) LeaseSetEncryptionType() string {
|
||||
if f.LeaseSetEncryption == "" {
|
||||
return "i2cp.leaseSetEncType=4,0"
|
||||
}
|
||||
for _, s := range strings.Split(f.LeaseSetEncryption, ",") {
|
||||
if _, err := strconv.Atoi(s); err != nil {
|
||||
panic("Invalid encrypted leaseSet type: " + s)
|
||||
}
|
||||
}
|
||||
return "i2cp.leaseSetEncType=" + f.LeaseSetEncryption
|
||||
}
|
||||
|
||||
func NewConfig(opts ...func(*I2PConfig) error) (*I2PConfig, error) {
|
||||
var config I2PConfig
|
||||
config.SamHost = "127.0.0.1"
|
||||
|
@@ -60,7 +60,7 @@ func (s *SAM) NewDatagramSession(id string, keys i2pkeys.I2PKeys, options []stri
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
conn, err := s.newGenericSession("DATAGRAM", id, keys, options, []string{"PORT=" + lport})
|
||||
conn, err := s.newGenericSession("DATAGRAM", id, keys, options, []string{" PORT=" + lport})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -6,10 +6,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
//Option is a SAMEmit Option
|
||||
// Option is a SAMEmit Option
|
||||
type Option func(*SAMEmit) error
|
||||
|
||||
//SetType sets the type of the forwarder server
|
||||
// SetType sets the type of the forwarder server
|
||||
func SetType(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if s == "STREAM" {
|
||||
@@ -41,7 +41,7 @@ func SetSAMAddress(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMHost sets the host of the SAMEmit's SAM bridge
|
||||
// SetSAMHost sets the host of the SAMEmit's SAM bridge
|
||||
func SetSAMHost(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.SamHost = s
|
||||
@@ -49,7 +49,7 @@ func SetSAMHost(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMPort sets the port of the SAMEmit's SAM bridge using a string
|
||||
// SetSAMPort sets the port of the SAMEmit's SAM bridge using a string
|
||||
func SetSAMPort(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
@@ -64,7 +64,7 @@ func SetSAMPort(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetName sets the host of the SAMEmit's SAM bridge
|
||||
// SetName sets the host of the SAMEmit's SAM bridge
|
||||
func SetName(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.TunName = s
|
||||
@@ -72,7 +72,7 @@ func SetName(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetInLength sets the number of hops inbound
|
||||
// SetInLength sets the number of hops inbound
|
||||
func SetInLength(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u < 7 && u >= 0 {
|
||||
@@ -83,7 +83,7 @@ func SetInLength(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutLength sets the number of hops outbound
|
||||
// SetOutLength sets the number of hops outbound
|
||||
func SetOutLength(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u < 7 && u >= 0 {
|
||||
@@ -94,7 +94,7 @@ func SetOutLength(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetInVariance sets the variance of a number of hops inbound
|
||||
// SetInVariance sets the variance of a number of hops inbound
|
||||
func SetInVariance(i int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if i < 7 && i > -7 {
|
||||
@@ -105,7 +105,7 @@ func SetInVariance(i int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutVariance sets the variance of a number of hops outbound
|
||||
// SetOutVariance sets the variance of a number of hops outbound
|
||||
func SetOutVariance(i int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if i < 7 && i > -7 {
|
||||
@@ -116,7 +116,7 @@ func SetOutVariance(i int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetInQuantity sets the inbound tunnel quantity
|
||||
// SetInQuantity sets the inbound tunnel quantity
|
||||
func SetInQuantity(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u <= 16 && u > 0 {
|
||||
@@ -127,7 +127,7 @@ func SetInQuantity(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutQuantity sets the outbound tunnel quantity
|
||||
// SetOutQuantity sets the outbound tunnel quantity
|
||||
func SetOutQuantity(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u <= 16 && u > 0 {
|
||||
@@ -138,7 +138,7 @@ func SetOutQuantity(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetInBackups sets the inbound tunnel backups
|
||||
// SetInBackups sets the inbound tunnel backups
|
||||
func SetInBackups(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u < 6 && u >= 0 {
|
||||
@@ -149,7 +149,7 @@ func SetInBackups(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutBackups sets the inbound tunnel backups
|
||||
// SetOutBackups sets the inbound tunnel backups
|
||||
func SetOutBackups(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u < 6 && u >= 0 {
|
||||
@@ -160,7 +160,7 @@ func SetOutBackups(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetEncrypt tells the router to use an encrypted leaseset
|
||||
// SetEncrypt tells the router to use an encrypted leaseset
|
||||
func SetEncrypt(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -172,7 +172,7 @@ func SetEncrypt(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetKey sets the host of the SAMEmit's SAM bridge
|
||||
// SetLeaseSetKey sets the host of the SAMEmit's SAM bridge
|
||||
func SetLeaseSetKey(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.LeaseSetKey = s
|
||||
@@ -180,7 +180,7 @@ func SetLeaseSetKey(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateKey sets the host of the SAMEmit's SAM bridge
|
||||
// SetLeaseSetPrivateKey sets the host of the SAMEmit's SAM bridge
|
||||
func SetLeaseSetPrivateKey(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.LeaseSetPrivateKey = s
|
||||
@@ -188,7 +188,7 @@ func SetLeaseSetPrivateKey(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateSigningKey sets the host of the SAMEmit's SAM bridge
|
||||
// SetLeaseSetPrivateSigningKey sets the host of the SAMEmit's SAM bridge
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.LeaseSetPrivateSigningKey = s
|
||||
@@ -196,7 +196,7 @@ func SetLeaseSetPrivateSigningKey(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetMessageReliability sets the host of the SAMEmit's SAM bridge
|
||||
// SetMessageReliability sets the host of the SAMEmit's SAM bridge
|
||||
func SetMessageReliability(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.MessageReliability = s
|
||||
@@ -204,7 +204,7 @@ func SetMessageReliability(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetAllowZeroIn tells the tunnel to accept zero-hop peers
|
||||
// SetAllowZeroIn tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroIn(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -216,7 +216,7 @@ func SetAllowZeroIn(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetAllowZeroOut tells the tunnel to accept zero-hop peers
|
||||
// SetAllowZeroOut tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroOut(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -228,7 +228,7 @@ func SetAllowZeroOut(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetCompress tells clients to use compression
|
||||
// SetCompress tells clients to use compression
|
||||
func SetCompress(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -240,7 +240,7 @@ func SetCompress(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetFastRecieve tells clients to use compression
|
||||
// SetFastRecieve tells clients to use compression
|
||||
func SetFastRecieve(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -252,7 +252,7 @@ func SetFastRecieve(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdle tells the connection to reduce it's tunnels during extended idle time.
|
||||
// SetReduceIdle tells the connection to reduce it's tunnels during extended idle time.
|
||||
func SetReduceIdle(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -264,7 +264,7 @@ func SetReduceIdle(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
// SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetReduceIdleTime(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.ReduceIdleTime = "300000"
|
||||
@@ -276,7 +276,7 @@ func SetReduceIdleTime(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
// SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetReduceIdleTimeMs(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.ReduceIdleTime = "300000"
|
||||
@@ -288,7 +288,7 @@ func SetReduceIdleTimeMs(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleQuantity sets minimum number of tunnels to reduce to during idle time
|
||||
// SetReduceIdleQuantity sets minimum number of tunnels to reduce to during idle time
|
||||
func SetReduceIdleQuantity(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if u < 5 {
|
||||
@@ -299,7 +299,7 @@ func SetReduceIdleQuantity(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdle tells the connection to close it's tunnels during extended idle time.
|
||||
// SetCloseIdle tells the connection to close it's tunnels during extended idle time.
|
||||
func SetCloseIdle(b bool) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if b {
|
||||
@@ -311,7 +311,7 @@ func SetCloseIdle(b bool) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
// SetCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetCloseIdleTime(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.CloseIdleTime = "300000"
|
||||
@@ -323,7 +323,7 @@ func SetCloseIdleTime(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
// SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetCloseIdleTimeMs(u int) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
c.I2PConfig.CloseIdleTime = "300000"
|
||||
@@ -335,7 +335,7 @@ func SetCloseIdleTimeMs(u int) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetAccessListType tells the system to treat the AccessList as a whitelist
|
||||
// SetAccessListType tells the system to treat the AccessList as a whitelist
|
||||
func SetAccessListType(s string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if s == "whitelist" {
|
||||
@@ -355,7 +355,7 @@ func SetAccessListType(s string) func(*SAMEmit) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetAccessList tells the system to treat the AccessList as a whitelist
|
||||
// SetAccessList tells the system to treat the AccessList as a whitelist
|
||||
func SetAccessList(s []string) func(*SAMEmit) error {
|
||||
return func(c *SAMEmit) error {
|
||||
if len(s) > 0 {
|
||||
|
5
emit.go
5
emit.go
@@ -12,10 +12,7 @@ type SAMEmit struct {
|
||||
}
|
||||
|
||||
func (e *SAMEmit) OptStr() string {
|
||||
optStr := ""
|
||||
for _, opt := range e.I2PConfig.Print() {
|
||||
optStr += opt + " "
|
||||
}
|
||||
optStr := strings.Join(e.I2PConfig.Print(), " ")
|
||||
return optStr
|
||||
}
|
||||
|
||||
|
10
go.mod
10
go.mod
@@ -2,12 +2,4 @@ module github.com/eyedeekay/sam3
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/eyedeekay/goSam v0.32.31-0.20210122211817-f97683379f23
|
||||
github.com/eyedeekay/i2pkeys v0.0.0-20220310052025-204d4ae6dcae // indirect
|
||||
github.com/google/renameio v1.0.0 // indirect
|
||||
github.com/riobard/go-x25519 v0.0.0-20190716001027-10cc4d8d0b33
|
||||
github.com/rogpeppe/go-internal v1.6.2 // indirect
|
||||
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b // indirect
|
||||
honnef.co/go/tools v0.0.1-2020.1.6 // indirect
|
||||
)
|
||||
require github.com/eyedeekay/i2pkeys v0.33.8
|
||||
|
94
go.sum
94
go.sum
@@ -1,90 +1,4 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 h1:iPf1jQ8yKTms6k6L5vYSE7RZJpjEe5vLTOmzRZdpnKc=
|
||||
github.com/cryptix/go v1.3.1 h1:I9opbROgEpldI0PwkMku0UY2DLFYgelZd9u0uaxmMgY=
|
||||
github.com/cryptix/go v1.3.1/go.mod h1:mFQotm9rTzptzvNjJM+1vSIDa/rVOVqMu0889GIXg70=
|
||||
github.com/cryptix/goSam v0.1.0 h1:lKXtrTv3Kd6+eIuNtcq3zPShJEVRqw+lQwmh49HmC7k=
|
||||
github.com/cryptix/goSam v0.1.0/go.mod h1:7ewkjhXT8V5RG07pvWUOHHtMahvGbeKlEv8ukUyRiTA=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/eyedeekay/goSam v0.32.30 h1:mMlZNE2oISdjjjpgfN17W56tn9F8rD/Jc2tsjTDDFYg=
|
||||
github.com/eyedeekay/goSam v0.32.30/go.mod h1:UgJnih/LpotwKriwVPOEa6yPDM2NDdVrKfLtS5DOLPE=
|
||||
github.com/eyedeekay/goSam v0.32.31-0.20210122211024-dddd8ea916d6 h1:seMFdfTWvmAsyj9jYPZATBJiJu5gHPsvJJk4Ruo2npQ=
|
||||
github.com/eyedeekay/goSam v0.32.31-0.20210122211024-dddd8ea916d6/go.mod h1:UgJnih/LpotwKriwVPOEa6yPDM2NDdVrKfLtS5DOLPE=
|
||||
github.com/eyedeekay/goSam v0.32.31-0.20210122211817-f97683379f23 h1:AHm/EzBilSQH+RFgEuslnlCpVQd88MQWx7KHW/VIQlc=
|
||||
github.com/eyedeekay/goSam v0.32.31-0.20210122211817-f97683379f23/go.mod h1:UgJnih/LpotwKriwVPOEa6yPDM2NDdVrKfLtS5DOLPE=
|
||||
github.com/eyedeekay/i2pkeys v0.0.0-20220310052025-204d4ae6dcae h1:SwegHeaf4pkDMB24UltIvJlj2+nd06QUZAbs8BDyfjM=
|
||||
github.com/eyedeekay/i2pkeys v0.0.0-20220310052025-204d4ae6dcae/go.mod h1:W9KCm9lqZ+Ozwl3dwcgnpPXAML97+I8Jiht7o5A8YBM=
|
||||
github.com/eyedeekay/sam3 v0.32.32/go.mod h1:qRA9KIIVxbrHlkj+ZB+OoxFGFgdKeGp1vSgPw26eOVU=
|
||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
|
||||
github.com/getlantern/errors v1.0.1/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A=
|
||||
github.com/getlantern/go-socks5 v0.0.0-20171114193258-79d4dd3e2db5/go.mod h1:kGHRXch95rnGLHjER/GhhFiHvfnqNz7KqWD9kGfATHY=
|
||||
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9/go.mod h1:ZyIjgH/1wTCl+B+7yH1DqrWp6MPJqESmwmEQ89ZfhvA=
|
||||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o=
|
||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA=
|
||||
github.com/getlantern/netx v0.0.0-20190110220209-9912de6f94fd/go.mod h1:wKdY0ikOgzrWSeB9UyBVKPRhjXQ+vTb+BPeJuypUuNE=
|
||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
|
||||
github.com/getlantern/ops v0.0.0-20200403153110-8476b16edcd6/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
|
||||
github.com/go-kit/kit v0.6.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-stack/stack v1.7.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/renameio v1.0.0 h1:xhp2CnJmgQmpJU4RY8chagahUq5mbPPAbiSQstKpVMA=
|
||||
github.com/google/renameio v1.0.0/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
|
||||
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/miolini/datacounter v0.0.0-20171104152933-fd4e42a1d5e0 h1:clkDYGefEWUCwyCrwYn900sOaVGDpinPJgD0W6ebEjs=
|
||||
github.com/miolini/datacounter v0.0.0-20171104152933-fd4e42a1d5e0/go.mod h1:P6fDJzlxN+cWYR09KbE9/ta+Y6JofX9tAUhJpWkWPaM=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/riobard/go-x25519 v0.0.0-20190716001027-10cc4d8d0b33 h1:dyyWDK0yzlZ8ay89Oe5ZIRtscacUjFyPUFGChrgMXRg=
|
||||
github.com/riobard/go-x25519 v0.0.0-20190716001027-10cc4d8d0b33/go.mod h1:BjmVxzAnkLeoEbqHEerI4eSw6ua+RaIB0S4jMV21RAs=
|
||||
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0=
|
||||
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef h1:RHORRhs540cYZYrzgU2CPUyykkwZM78hGdzocOo9P8A=
|
||||
golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b h1:Lq5JUTFhiybGVf28jB6QRpqd13/JPOaCnET17PVzYJE=
|
||||
golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
honnef.co/go/tools v0.0.1-2020.1.6 h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=
|
||||
honnef.co/go/tools v0.0.1-2020.1.6/go.mod h1:pyyisuGw24ruLjrr1ddx39WE0y9OooInRzEYLhQB2YY=
|
||||
github.com/eyedeekay/i2pkeys v0.33.7 h1:cxqHSkl6b2lHyPJUtIQZBiipYf7NQVYqM1d3ub0MI4k=
|
||||
github.com/eyedeekay/i2pkeys v0.33.7/go.mod h1:W9KCm9lqZ+Ozwl3dwcgnpPXAML97+I8Jiht7o5A8YBM=
|
||||
github.com/eyedeekay/i2pkeys v0.33.8 h1:f3llyruchFqs1QwCacBYbShArKPpMSSOqo/DVZXcfVs=
|
||||
github.com/eyedeekay/i2pkeys v0.33.8/go.mod h1:W9KCm9lqZ+Ozwl3dwcgnpPXAML97+I8Jiht7o5A8YBM=
|
||||
|
@@ -10,6 +10,9 @@ import (
|
||||
"github.com/eyedeekay/sam3"
|
||||
)
|
||||
|
||||
// HEY! If you're looking at this, there's a good chance that `github.com/eyedeekay/onramp`
|
||||
// is a better fit! Check it out.
|
||||
|
||||
func NetListener(name, samaddr, keyspath string) (net.Listener, error) {
|
||||
return I2PListener(name, sam3.SAMDefaultAddr(samaddr), keyspath)
|
||||
}
|
||||
@@ -20,7 +23,9 @@ func NetListener(name, samaddr, keyspath string) (net.Listener, error) {
|
||||
func I2PListener(name, samaddr, keyspath string) (*sam3.StreamListener, error) {
|
||||
log.Printf("Starting and registering I2P service, please wait a couple of minutes...")
|
||||
listener, err := I2PStreamSession(name, sam3.SAMDefaultAddr(samaddr), keyspath)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if keyspath != "" {
|
||||
err = ioutil.WriteFile(keyspath+".i2p.public.txt", []byte(listener.Keys().Addr().Base32()), 0644)
|
||||
if err != nil {
|
||||
|
55
index.html
55
index.html
@@ -7,6 +7,7 @@
|
||||
<meta name="description" content="sam3" />
|
||||
<meta name="keywords" content="master" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="showhider.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="navbar">
|
||||
@@ -30,19 +31,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<h1>
|
||||
<a href="/">
|
||||
README
|
||||
<a href="#readme" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
README
|
||||
</h1>
|
||||
<h2>
|
||||
<a href="#important" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
!!IMPORTANT!!
|
||||
</h2>
|
||||
<p>
|
||||
In the next version, I’ll be moving the
|
||||
In the next version, I'll be moving the
|
||||
<code>
|
||||
i2pkeys
|
||||
</code>
|
||||
directory to it’s own repository
|
||||
directory to it's own repository
|
||||
so I can avoid import cycle headaches. Please migrate to the new
|
||||
<code>
|
||||
i2pkeys
|
||||
@@ -50,9 +55,17 @@
|
||||
repository
|
||||
before upgrading your sam3 dependencies. You can probably do this by running:
|
||||
</p>
|
||||
<pre><code>find . -name '*.go' -exec sed -i 's|github.com/eyedeekay/sam3/i2pkeys|github.com/eyedeekay/i2pkeys|g' {} \;
|
||||
</code></pre>
|
||||
<div>
|
||||
<pre>find . -name '*.go' -exec sed -i 's|github.com/eyedeekay/sam3/i2pkeys|github.com/eyedeekay/i2pkeys|g' {} \;
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
STATUS: This project is maintained. I will respond to issues, pull requests, and feature requests within a few days.
|
||||
</p>
|
||||
<h1>
|
||||
<a href="#readme" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
README
|
||||
</h1>
|
||||
<p>
|
||||
@@ -66,6 +79,9 @@
|
||||
This library is much better than ccondom (that use BOB), much more stable and much easier to maintain.
|
||||
</p>
|
||||
<h2>
|
||||
<a href="#support-todo" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
Support/TODO
|
||||
</h2>
|
||||
<p>
|
||||
@@ -133,6 +149,9 @@
|
||||
</li>
|
||||
</ul>
|
||||
<h2>
|
||||
<a href="#documentation" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
Documentation
|
||||
</h2>
|
||||
<ul>
|
||||
@@ -160,9 +179,13 @@
|
||||
</li>
|
||||
</ul>
|
||||
<h2>
|
||||
<a href="#examples" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
Examples
|
||||
</h2>
|
||||
<pre><code>package main
|
||||
<div>
|
||||
<pre>package main
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam3"
|
||||
@@ -193,17 +216,23 @@ func main() {
|
||||
n, _ := conn.Read(buf)
|
||||
fmt.Println("Server received: " + string(buf[:n]))
|
||||
}
|
||||
</code></pre>
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
The above will write to the terminal:
|
||||
</p>
|
||||
<pre><code>Client: Connecting to zjnvfh4hs3et5vtz35ogwzrws26zvwkcad5uo5esecvg4qpk5b4a.b32.i2p
|
||||
<div>
|
||||
<pre>Client: Connecting to zjnvfh4hs3et5vtz35ogwzrws26zvwkcad5uo5esecvg4qpk5b4a.b32.i2p
|
||||
Server received: Hello world!
|
||||
</code></pre>
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
Error handling was omitted in the above code for readability.
|
||||
</p>
|
||||
<h2>
|
||||
<a href="#testing" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
Testing
|
||||
</h2>
|
||||
<ul>
|
||||
@@ -221,12 +250,18 @@ Server received: Hello world!
|
||||
</li>
|
||||
</ul>
|
||||
<h2>
|
||||
<a href="#license" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
License
|
||||
</h2>
|
||||
<p>
|
||||
Public domain.
|
||||
</p>
|
||||
<h2>
|
||||
<a href="#author" rel="nofollow">
|
||||
<span></span>
|
||||
</a>
|
||||
Author
|
||||
</h2>
|
||||
<ul>
|
||||
|
3
raw.go
3
raw.go
@@ -57,6 +57,9 @@ func (s *SAM) NewRawSession(id string, keys i2pkeys.I2PKeys, options []string, u
|
||||
return nil, err
|
||||
}
|
||||
_, lport, err := net.SplitHostPort(udpconn.LocalAddr().String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn, err := s.newGenericSession("RAW", id, keys, options, []string{"PORT=" + lport})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
27
sam3.go
27
sam3.go
@@ -5,6 +5,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net"
|
||||
@@ -35,7 +36,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
Sig_NONE = ""
|
||||
Sig_NONE = "SIGNATURE_TYPE=EdDSA_SHA512_Ed25519"
|
||||
Sig_DSA_SHA1 = "SIGNATURE_TYPE=DSA_SHA1"
|
||||
Sig_ECDSA_SHA256_P256 = "SIGNATURE_TYPE=ECDSA_SHA256_P256"
|
||||
Sig_ECDSA_SHA384_P384 = "SIGNATURE_TYPE=ECDSA_SHA384_P384"
|
||||
@@ -60,17 +61,17 @@ func NewSAM(address string) (*SAM, error) {
|
||||
// TODO: clean this up
|
||||
conn, err := net.Dial("tcp", address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error dialing to address '%s': %w", address, err)
|
||||
}
|
||||
if _, err := conn.Write(s.Config.HelloBytes()); err != nil {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error writing to address '%s': %w", address, err)
|
||||
}
|
||||
buf := make([]byte, 256)
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error reading onto buffer: %w", err)
|
||||
}
|
||||
if strings.Contains(string(buf[:n]), "HELLO REPLY RESULT=OK") {
|
||||
s.Config.I2PConfig.SetSAMAddress(address)
|
||||
@@ -78,10 +79,9 @@ func NewSAM(address string) (*SAM, error) {
|
||||
//s.Config.I2PConfig.DestinationKeys = nil
|
||||
s.resolver, err = NewSAMResolver(&s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("error creating resolver: %w", err)
|
||||
}
|
||||
return &s, nil
|
||||
//return &SAM{address, conn, nil, nil}, nil
|
||||
} else if string(buf[:n]) == "HELLO REPLY RESULT=NOVERSION\n" {
|
||||
conn.Close()
|
||||
return nil, errors.New("That SAM bridge does not support SAMv3.")
|
||||
@@ -116,7 +116,7 @@ func (sam *SAM) EnsureKeyfile(fname string) (keys i2pkeys.I2PKeys, err error) {
|
||||
sam.Config.I2PConfig.DestinationKeys = keys
|
||||
}
|
||||
} else {
|
||||
// persistant
|
||||
// persistent
|
||||
_, err = os.Stat(fname)
|
||||
if os.IsNotExist(err) {
|
||||
// make the keys
|
||||
@@ -155,12 +155,12 @@ func (sam *SAM) NewKeys(sigType ...string) (i2pkeys.I2PKeys, error) {
|
||||
sigtmp = sigType[0]
|
||||
}
|
||||
if _, err := sam.conn.Write([]byte("DEST GENERATE " + sigtmp + "\n")); err != nil {
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, fmt.Errorf("error with writing in SAM: %w", err)
|
||||
}
|
||||
buf := make([]byte, 8192)
|
||||
n, err := sam.conn.Read(buf)
|
||||
if err != nil {
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, fmt.Errorf("error with reading in SAM: %w", err)
|
||||
}
|
||||
s := bufio.NewScanner(bytes.NewReader(buf[:n]))
|
||||
s.Split(bufio.ScanWords)
|
||||
@@ -209,10 +209,7 @@ func (sam *SAM) newGenericSessionWithSignature(style, id string, keys i2pkeys.I2
|
||||
// This sam3 instance is now a session
|
||||
func (sam *SAM) newGenericSessionWithSignatureAndPorts(style, id, from, to string, keys i2pkeys.I2PKeys, sigType string, options []string, extras []string) (net.Conn, error) {
|
||||
|
||||
optStr := ""
|
||||
for _, opt := range options {
|
||||
optStr += opt + " "
|
||||
}
|
||||
optStr := GenerateOptionString(options)
|
||||
|
||||
conn := sam.conn
|
||||
fp := ""
|
||||
@@ -232,7 +229,7 @@ func (sam *SAM) newGenericSessionWithSignatureAndPorts(style, id, from, to strin
|
||||
n, err := conn.Write(scmsg[m:])
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("writing to connection failed: %w", err)
|
||||
}
|
||||
m += n
|
||||
}
|
||||
@@ -240,7 +237,7 @@ func (sam *SAM) newGenericSessionWithSignatureAndPorts(style, id, from, to strin
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("reading from connection failed: %w", err)
|
||||
}
|
||||
text := string(buf[:n])
|
||||
if strings.HasPrefix(text, session_OK) {
|
||||
|
10
showhider.css
Normal file
10
showhider.css
Normal file
@@ -0,0 +1,10 @@
|
||||
/* edgar showhider CSS file */
|
||||
#show {display:none; }
|
||||
#hide {display:block; }
|
||||
#show:target {display: block; }
|
||||
#hide:target {display: none; }
|
||||
|
||||
#shownav {display:none; }
|
||||
#hidenav {display:block; }
|
||||
#shownav:target {display: block; }
|
||||
#hidenav:target {display: none; }
|
@@ -103,7 +103,7 @@ func (sam *SAM) NewStreamSessionWithSignatureAndPorts(id, from, to string, keys
|
||||
return &StreamSession{sam.Config.I2PConfig.Sam(), id, conn, keys, time.Duration(600 * time.Second), time.Now(), sigType, from, to}, nil
|
||||
}
|
||||
|
||||
// lookup name, convienence function
|
||||
// lookup name, convenience function
|
||||
func (s *StreamSession) Lookup(name string) (i2pkeys.I2PAddr, error) {
|
||||
sam, err := NewSAM(s.samAddr)
|
||||
if err == nil {
|
||||
@@ -161,6 +161,7 @@ func minNonzeroTime(a, b time.Time) time.Time {
|
||||
// - now+Timeout
|
||||
// - d.Deadline
|
||||
// - the context's deadline
|
||||
//
|
||||
// Or zero, if none of Timeout, Deadline, or context's deadline is set.
|
||||
func (s *StreamSession) deadline(ctx context.Context, now time.Time) (earliest time.Time) {
|
||||
if s.Timeout != 0 { // including negative, for historical reasons
|
||||
|
@@ -77,39 +77,43 @@ func (l *StreamListener) AcceptI2P() (*SAMConn, error) {
|
||||
// we connected to sam
|
||||
// send accept() command
|
||||
_, err = io.WriteString(s.conn, "STREAM ACCEPT ID="+l.id+" SILENT=false\n")
|
||||
if err != nil {
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
// read reply
|
||||
rd := bufio.NewReader(s.conn)
|
||||
// read first line
|
||||
line, err := rd.ReadString(10)
|
||||
log.Println(line)
|
||||
if err == nil {
|
||||
if strings.HasPrefix(line, "STREAM STATUS RESULT=OK") {
|
||||
// we gud read destination line
|
||||
destline, err := rd.ReadString(10)
|
||||
if err == nil {
|
||||
dest := ExtractDest(destline)
|
||||
l.session.from = ExtractPairString(destline, "FROM_PORT")
|
||||
l.session.to = ExtractPairString(destline, "TO_PORT")
|
||||
// return wrapped connection
|
||||
dest = strings.Trim(dest, "\n")
|
||||
return &SAMConn{
|
||||
laddr: l.laddr,
|
||||
raddr: i2pkeys.I2PAddr(dest),
|
||||
conn: s.conn,
|
||||
}, nil
|
||||
} else {
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
s.Close()
|
||||
return nil, errors.New("invalid sam line: " + line)
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
log.Println(line)
|
||||
if strings.HasPrefix(line, "STREAM STATUS RESULT=OK") {
|
||||
// we gud read destination line
|
||||
destline, err := rd.ReadString(10)
|
||||
if err == nil {
|
||||
dest := ExtractDest(destline)
|
||||
l.session.from = ExtractPairString(destline, "FROM_PORT")
|
||||
l.session.to = ExtractPairString(destline, "TO_PORT")
|
||||
// return wrapped connection
|
||||
dest = strings.Trim(dest, "\n")
|
||||
return &SAMConn{
|
||||
laddr: l.laddr,
|
||||
raddr: i2pkeys.I2PAddr(dest),
|
||||
conn: s.conn,
|
||||
}, nil
|
||||
} else {
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
s.Close()
|
||||
return nil, errors.New("invalid sam line: " + line)
|
||||
}
|
||||
} else {
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
s.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Examples and suggestions for options when creating sessions.
|
||||
@@ -105,3 +106,11 @@ func SAMDefaultAddr(fallforward string) string {
|
||||
}
|
||||
return fallforward
|
||||
}
|
||||
|
||||
func GenerateOptionString(opts []string) string {
|
||||
optStr := strings.Join(opts, " ")
|
||||
if strings.Contains(optStr, "i2cp.leaseSetEncType") {
|
||||
return optStr
|
||||
}
|
||||
return optStr + " i2cp.leaseSetEncType=4,0"
|
||||
}
|
||||
|
Reference in New Issue
Block a user