implement encoding Marshal/Unmarshal
This commit is contained in:
@@ -61,12 +61,15 @@ func su3Action(c *cli.Context) {
|
||||
seeds, err := reseeder.Seeds(reseed.Peer("127.0.0.1"))
|
||||
if nil != err {
|
||||
log.Fatalln(err)
|
||||
return
|
||||
}
|
||||
|
||||
// create an SU3 from the seed
|
||||
su3File, err := reseeder.CreateSu3(seeds)
|
||||
|
||||
//write the file to disk
|
||||
ioutil.WriteFile("i2pseeds.su3", su3File.Bytes(), 0777)
|
||||
data, err := su3File.MarshalBinary()
|
||||
if nil != err {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
ioutil.WriteFile("i2pseeds.su3", data, 0777)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/MDrollette/go-i2p/reseed"
|
||||
"github.com/MDrollette/go-i2p/su3"
|
||||
@@ -20,14 +20,13 @@ func NewSu3VerifyCommand() cli.Command {
|
||||
}
|
||||
|
||||
func su3VerifyAction(c *cli.Context) {
|
||||
file, err := os.Open(c.Args().Get(0))
|
||||
if err != nil {
|
||||
su3File := su3.Su3File{}
|
||||
|
||||
data, err := ioutil.ReadFile(c.Args().Get(0))
|
||||
if nil != err {
|
||||
panic(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
su3File, err := su3.Parse(file)
|
||||
if err != nil {
|
||||
if err := su3File.UnmarshalBinary(data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
@@ -89,11 +90,14 @@ func validate(responses chan *http.Response) {
|
||||
continue
|
||||
}
|
||||
|
||||
su3File, err := su3.Parse(resp.Body)
|
||||
if err != nil {
|
||||
su3File := su3.Su3File{}
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if nil != err {
|
||||
fmt.Println("Invalid: Unable to parse SU3 file:", err)
|
||||
}
|
||||
if err := su3File.UnmarshalBinary(data); err != nil {
|
||||
fmt.Println("Invalid: Unable to parse SU3 file:", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
||||
cert, err := ks.ReseederCertificate(su3File.SignerId)
|
||||
if nil != err {
|
||||
|
||||
Reference in New Issue
Block a user