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

@ -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)
}