change sam3 to i2pkeys in some places
This commit is contained in:
parent
a17ef742a2
commit
4ad3e7d4a0
8 changed files with 435 additions and 23 deletions
27
conn/conn.go
27
conn/conn.go
|
@ -9,12 +9,13 @@ import (
|
|||
)
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam3"
|
||||
"github.com/go-i2p/sam3"
|
||||
"github.com/go-i2p/i2pkeys"
|
||||
)
|
||||
|
||||
type Conn struct {
|
||||
*sam3.SAM
|
||||
sam3.I2PKeys
|
||||
i2pkeys.I2PKeys
|
||||
*sam3.StreamSession
|
||||
*sam3.SAMConn
|
||||
path string
|
||||
|
@ -36,42 +37,42 @@ func (c Conn) Path() string {
|
|||
return p
|
||||
}
|
||||
|
||||
func (c Conn) SaveKeys() (sam3.I2PKeys, error) {
|
||||
func (c Conn) SaveKeys() (i2pkeys.I2PKeys, error) {
|
||||
var err error
|
||||
c.I2PKeys, err = c.SAM.NewKeys()
|
||||
if err != nil {
|
||||
return sam3.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
}
|
||||
f, err := os.Create(c.Path())
|
||||
if err != nil {
|
||||
return sam3.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
}
|
||||
defer f.Close()
|
||||
filewriter := bufio.NewWriter(f)
|
||||
err = sam3.StoreKeysIncompat(c.I2PKeys, filewriter)
|
||||
err = i2pkeys.StoreKeysIncompat(c.I2PKeys, filewriter)
|
||||
if err != nil {
|
||||
return sam3.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
}
|
||||
filewriter.Flush()
|
||||
return c.I2PKeys, nil
|
||||
}
|
||||
|
||||
func (c Conn) LoadKeys() (sam3.I2PKeys, error) {
|
||||
func (c Conn) LoadKeys() (i2pkeys.I2PKeys, error) {
|
||||
var err error
|
||||
f, err := os.Open(c.Path())
|
||||
if err != nil {
|
||||
return sam3.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
}
|
||||
defer f.Close()
|
||||
filereader := bufio.NewReader(f)
|
||||
c.I2PKeys, err = sam3.LoadKeysIncompat(filereader)
|
||||
c.I2PKeys, err = i2pkeys.LoadKeysIncompat(filereader)
|
||||
if err != nil {
|
||||
return sam3.I2PKeys{}, err
|
||||
return i2pkeys.I2PKeys{}, err
|
||||
}
|
||||
return c.I2PKeys, nil
|
||||
}
|
||||
|
||||
func (c Conn) Keys() (sam3.I2PKeys, error) {
|
||||
func (c Conn) Keys() (i2pkeys.I2PKeys, error) {
|
||||
if c.FindKeys() {
|
||||
return c.LoadKeys()
|
||||
}
|
||||
|
@ -95,7 +96,7 @@ func NewConn(sam sam3.SAM, addr, path string, opts []string) (Conn, error) {
|
|||
var err error
|
||||
c.SAM = &sam
|
||||
c.path = path
|
||||
t32, err := sam3.NewI2PAddrFromString(addr)
|
||||
t32, err := i2pkeys.NewI2PAddrFromString(addr)
|
||||
c.name = t32.Base32() + ".i2pkeys"
|
||||
c.I2PKeys, err = c.Keys()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue