move SAM into conn

This commit is contained in:
idk 2018-12-26 01:17:49 -05:00
parent fe7c0dcd5b
commit 3c7fc231c8
No known key found for this signature in database
GPG key ID: D75C03B39B5E14E1
2 changed files with 8 additions and 11 deletions

View file

@ -87,10 +87,13 @@ func (m Conn) Cleanup() error {
return nil
}
func NewConn(sam sam3.SAM, addr, path string, opts []string) (*Conn, error) {
func NewConn(samhost, samport, addr, path string, opts []string) (*Conn, error) {
var c Conn
var err error
c.SAM = &sam
c.SAM, err = sam3.NewSAM(samhost + ":" + samport)
if err != nil {
return nil, err
}
c.path = path
t32, err := sam3.NewI2PAddrFromString(addr)
c.name = t32.Base32() + ".i2pkeys"
@ -98,11 +101,11 @@ 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]+RandTunName(), c.I2PKeys, opts)
c.StreamSession, err = c.SAM.NewStreamSession(c.I2PKeys.Addr().Base32()[0:10]+RandTunName(), c.I2PKeys, opts)
if err != nil {
return nil, err
}
i2paddr, err := sam.Lookup(addr)
i2paddr, err := c.SAM.Lookup(addr)
if err != nil {
return nil, err
}