update some dialer stuff
This commit is contained in:
parent
89fc9966c2
commit
1d0ec2a110
3 changed files with 13 additions and 1 deletions
1
Makefile
1
Makefile
|
@ -23,6 +23,7 @@ clean:
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
go get -u github.com/eyedeekay/eeproxy
|
go get -u github.com/eyedeekay/eeproxy
|
||||||
|
go get -u github.com/eyedeekay/go-socks5
|
||||||
|
|
||||||
test:
|
test:
|
||||||
mkdir -p testdir && cd testdir && \
|
mkdir -p testdir && cd testdir && \
|
||||||
|
|
12
conn/conn.go
12
conn/conn.go
|
@ -2,6 +2,7 @@ package conn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -97,7 +98,7 @@ func NewConn(sam *sam3.SAM, addr, path string, opts []string) (*Conn, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -111,3 +112,12 @@ func NewConn(sam *sam3.SAM, addr, path string, opts []string) (*Conn, error) {
|
||||||
}
|
}
|
||||||
return &c, nil
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -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) {
|
func (m Manager) Dial(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
|
log.Println("Dialing:", network, addr)
|
||||||
return m.DialI2P(ctx, addr)
|
return m.DialI2P(ctx, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue