update some dialer stuff

This commit is contained in:
idk 2018-12-25 20:12:10 -05:00
parent 89fc9966c2
commit 1d0ec2a110
No known key found for this signature in database
GPG key ID: D75C03B39B5E14E1
3 changed files with 13 additions and 1 deletions

View file

@ -23,6 +23,7 @@ clean:
deps:
go get -u github.com/eyedeekay/eeproxy
go get -u github.com/eyedeekay/go-socks5
test:
mkdir -p testdir && cd testdir && \

View file

@ -2,6 +2,7 @@ package conn
import (
"bufio"
"math/rand"
"os"
"path/filepath"
)
@ -97,7 +98,7 @@ func NewConn(sam *sam3.SAM, addr, path string, opts []string) (*Conn, error) {
if err != nil {
return nil, err
}
c.StreamSession, err = sam.NewStreamSession(c.I2PKeys.Addr().Base32()[0:10], c.I2PKeys, opts)
c.StreamSession, err = sam.NewStreamSession(c.I2PKeys.Addr().Base32()[0:10]+RandTunName(), c.I2PKeys, opts)
if err != nil {
return nil, err
}
@ -111,3 +112,12 @@ func NewConn(sam *sam3.SAM, addr, path string, opts []string) (*Conn, error) {
}
return &c, nil
}
// RandTunName generates a random tunnel names to avoid collisions
func RandTunName() string {
b := make([]byte, 12)
for i := range b {
b[i] = "abcdefghijklmnopqrstuvwxyz"[rand.Intn(len("abcdefghijklmnopqrstuvwxyz"))]
}
return string(b)
}

View file

@ -59,6 +59,7 @@ func (m Manager) DialI2P(ctx context.Context, addr string) (*sam3.SAMConn, error
}
func (m Manager) Dial(ctx context.Context, network, addr string) (net.Conn, error) {
log.Println("Dialing:", network, addr)
return m.DialI2P(ctx, addr)
}