get ready for saving the keys
This commit is contained in:
parent
6260b4fe2b
commit
564bf08803
3 changed files with 34 additions and 8 deletions
23
conn/conn.go
Normal file
23
conn/conn.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package conn
|
||||||
|
|
||||||
|
import (
|
||||||
|
//"os"
|
||||||
|
"github.com/eyedeekay/sam3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Conn struct {
|
||||||
|
*sam3.SAMConn
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Conn) SaveKeys() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConn(conn *sam3.SAMConn, path string) (*Conn, error) {
|
||||||
|
return GenConn(conn, path), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenConn(conn *sam3.SAMConn, path string) *Conn {
|
||||||
|
return &Conn{SAMConn: conn, path: path}
|
||||||
|
}
|
9
main.go
9
main.go
|
@ -3,7 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
//"log"
|
//"log"
|
||||||
"github.com/eyedeekay/eeproxy/socks"
|
"./socks"
|
||||||
|
//"github.com/eyedeekay/eeproxy/socks"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -52,9 +53,9 @@ var (
|
||||||
"Target host(Host of service to forward to i2p)")
|
"Target host(Host of service to forward to i2p)")
|
||||||
targetPort = flag.String("p", "8081",
|
targetPort = flag.String("p", "8081",
|
||||||
"Target port(Port of service to forward to i2p)")
|
"Target port(Port of service to forward to i2p)")
|
||||||
reduceIdle = flag.Bool("r", false,
|
reduceIdle = flag.Bool("r", true,
|
||||||
"Reduce tunnel quantity when idle(true or false)")
|
"Reduce tunnel quantity when idle(true or false)")
|
||||||
closeIdle = flag.Bool("x", false,
|
closeIdle = flag.Bool("x", true,
|
||||||
"Close tunnel idle(true or false)")
|
"Close tunnel idle(true or false)")
|
||||||
targetDir = flag.String("d", "./tunnels/",
|
targetDir = flag.String("d", "./tunnels/",
|
||||||
"Directory to save tunnel configuration file in.")
|
"Directory to save tunnel configuration file in.")
|
||||||
|
@ -136,7 +137,7 @@ func main() {
|
||||||
config.ReduceIdle = config.GetReduceOnIdle(*reduceIdle, true)
|
config.ReduceIdle = config.GetReduceOnIdle(*reduceIdle, true)
|
||||||
config.ReduceIdleTime = config.GetReduceIdleTime(*reduceIdleTime, 600000)
|
config.ReduceIdleTime = config.GetReduceIdleTime(*reduceIdleTime, 600000)
|
||||||
config.ReduceIdleQuantity = config.GetReduceIdleQuantity(*reduceIdleQuantity, 2)
|
config.ReduceIdleQuantity = config.GetReduceIdleQuantity(*reduceIdleQuantity, 2)
|
||||||
config.CloseIdle = config.GetCloseOnIdle(*closeIdle, false)
|
config.CloseIdle = config.GetCloseOnIdle(*closeIdle, true)
|
||||||
config.CloseIdleTime = config.GetCloseIdleTime(*closeIdleTime, 600000)
|
config.CloseIdleTime = config.GetCloseIdleTime(*closeIdleTime, 600000)
|
||||||
config.KeyFilePath = config.GetKeyFile(*encryptKeyFiles, "")
|
config.KeyFilePath = config.GetKeyFile(*encryptKeyFiles, "")
|
||||||
config.ClientDest = config.GetClientDest(*targetDest, "", "")
|
config.ClientDest = config.GetClientDest(*targetDest, "", "")
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"../conn"
|
||||||
"github.com/eyedeekay/eeproxy/resolve"
|
"github.com/eyedeekay/eeproxy/resolve"
|
||||||
"github.com/eyedeekay/go-socks5"
|
"github.com/eyedeekay/go-socks5"
|
||||||
"github.com/eyedeekay/sam3"
|
"github.com/eyedeekay/sam3"
|
||||||
|
@ -17,7 +18,8 @@ type Manager struct {
|
||||||
resolver.Resolver
|
resolver.Resolver
|
||||||
socks5.Config
|
socks5.Config
|
||||||
sam3.StreamSession
|
sam3.StreamSession
|
||||||
conns []*sam3.SAMConn
|
conns []*conn.Conn
|
||||||
|
datapath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Manager) Serve() error {
|
func (m Manager) Serve() error {
|
||||||
|
@ -32,16 +34,16 @@ func (m Manager) DialI2P(ctx context.Context, addr string) (*sam3.SAMConn, error
|
||||||
for i, c := range m.conns {
|
for i, c := range m.conns {
|
||||||
if i2paddr.Base32() == c.RemoteAddr().(*sam3.I2PAddr).Base32() {
|
if i2paddr.Base32() == c.RemoteAddr().(*sam3.I2PAddr).Base32() {
|
||||||
log.Println("Found destination for address:", i2paddr.Base32(), "at position", i)
|
log.Println("Found destination for address:", i2paddr.Base32(), "at position", i)
|
||||||
return c, nil
|
return c.SAMConn, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newconn, err := m.StreamSession.DialI2P(i2paddr)
|
newconn, err := m.StreamSession.DialI2P(i2paddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m.conns = append(m.conns, newconn)
|
m.conns = append(m.conns, conn.GenConn(newconn, m.datapath))
|
||||||
log.Println("Generated destination for address:", i2paddr.Base32(), "at position", len(m.conns)-1)
|
log.Println("Generated destination for address:", i2paddr.Base32(), "at position", len(m.conns)-1)
|
||||||
return m.conns[len(m.conns)-1], nil
|
return m.conns[len(m.conns)-1].SAMConn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue