format with go fmt

This commit is contained in:
Jeff Becker
2016-01-29 07:22:31 -05:00
parent f2c6e01206
commit 1e471e4e00
38 changed files with 694 additions and 729 deletions

View File

@ -10,7 +10,6 @@ import (
// i2p base32 encoding // i2p base32 encoding
var I2PEncoding *b32.Encoding = b32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567") var I2PEncoding *b32.Encoding = b32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567")
// wrapper arround encoding for encoding to string // wrapper arround encoding for encoding to string
func EncodeToString(data []byte) (str string) { func EncodeToString(data []byte) (str string) {
str = I2PEncoding.EncodeToString(data) str = I2PEncoding.EncodeToString(data)

View File

@ -1,5 +1,4 @@
package common package common
// the sha256 of some datastructure // the sha256 of some datastructure
type IdentHash [32]byte type IdentHash [32]byte

View File

@ -1,6 +1,5 @@
package config package config
type BootstrapConfig struct { type BootstrapConfig struct {
LowPeerThreshold int LowPeerThreshold int
} }

View File

@ -2,8 +2,8 @@ package crypto
import ( import (
"crypto/dsa" "crypto/dsa"
"crypto/sha1"
"crypto/rand" "crypto/rand"
"crypto/sha1"
"io" "io"
"math/big" "math/big"
) )
@ -22,7 +22,7 @@ var dsap = new(big.Int).SetBytes([]byte{
var dsaq = new(big.Int).SetBytes([]byte{ var dsaq = new(big.Int).SetBytes([]byte{
0xa5, 0xdf, 0xc2, 0x8f, 0xef, 0x4c, 0xa1, 0xe2, 0x86, 0x74, 0x4c, 0xd8, 0xee, 0xd9, 0xd2, 0x9d, 0xa5, 0xdf, 0xc2, 0x8f, 0xef, 0x4c, 0xa1, 0xe2, 0x86, 0x74, 0x4c, 0xd8, 0xee, 0xd9, 0xd2, 0x9d,
0x68, 0x40, 0x46, 0xb7, 0x68, 0x40, 0x46, 0xb7,
}); })
var dsag = new(big.Int).SetBytes([]byte{ var dsag = new(big.Int).SetBytes([]byte{
0x0c, 0x1f, 0x4d, 0x27, 0xd4, 0x00, 0x93, 0xb4, 0x29, 0xe9, 0x62, 0xd7, 0x22, 0x38, 0x24, 0xe0, 0x0c, 0x1f, 0x4d, 0x27, 0xd4, 0x00, 0x93, 0xb4, 0x29, 0xe9, 0x62, 0xd7, 0x22, 0x38, 0x24, 0xe0,
@ -33,7 +33,7 @@ var dsag = new(big.Int).SetBytes([]byte{
0x6b, 0xd5, 0x40, 0x9c, 0xd2, 0xf4, 0x50, 0x82, 0x11, 0x42, 0xa5, 0xe6, 0xf8, 0xeb, 0x1c, 0x3a, 0x6b, 0xd5, 0x40, 0x9c, 0xd2, 0xf4, 0x50, 0x82, 0x11, 0x42, 0xa5, 0xe6, 0xf8, 0xeb, 0x1c, 0x3a,
0xb5, 0xd0, 0x48, 0x4b, 0x81, 0x29, 0xfc, 0xf1, 0x7b, 0xce, 0x4f, 0x7f, 0x33, 0x32, 0x1c, 0x3c, 0xb5, 0xd0, 0x48, 0x4b, 0x81, 0x29, 0xfc, 0xf1, 0x7b, 0xce, 0x4f, 0x7f, 0x33, 0x32, 0x1c, 0x3c,
0xb3, 0xdb, 0xb1, 0x4a, 0x90, 0x5e, 0x7b, 0x2b, 0x3e, 0x93, 0xbe, 0x47, 0x08, 0xcb, 0xcc, 0x82, 0xb3, 0xdb, 0xb1, 0x4a, 0x90, 0x5e, 0x7b, 0x2b, 0x3e, 0x93, 0xbe, 0x47, 0x08, 0xcb, 0xcc, 0x82,
}); })
var param = dsa.Parameters{ var param = dsa.Parameters{
P: dsap, P: dsap,
@ -72,7 +72,6 @@ func createDSAPrivkey(X *big.Int) *dsa.PrivateKey {
} }
} }
type DSAVerifier struct { type DSAVerifier struct {
k *dsa.PublicKey k *dsa.PublicKey
} }
@ -111,7 +110,6 @@ func (v *DSAVerifier) VerifyHash(h, sig []byte) (err error) {
return return
} }
func (k DSAPublicKey) Len() int { func (k DSAPublicKey) Len() int {
return len(k) return len(k)
} }

View File

@ -6,7 +6,6 @@ import (
"testing" "testing"
) )
func TestDSA(t *testing.T) { func TestDSA(t *testing.T) {
rng := rand.Reader rng := rand.Reader
kp := new(dsa.PrivateKey) kp := new(dsa.PrivateKey)

View File

@ -1,5 +1,4 @@
package crypto package crypto
type Ed25519PublicKey [32]byte type Ed25519PublicKey [32]byte
type Ed25519PrivateKey [32]byte type Ed25519PrivateKey [32]byte

View File

@ -97,7 +97,6 @@ func elgamalDecrypt(priv *elgamal.PrivateKey, data []byte, zeroPadding bool) (de
return return
} }
type ElgamalEncryption struct { type ElgamalEncryption struct {
p, a, b1 *big.Int p, a, b1 *big.Int
} }
@ -184,7 +183,6 @@ func createElgamalEncryption(pub *elgamal.PublicKey, rand io.Reader) (enc *Elgam
return return
} }
type ElgPublicKey [256]byte type ElgPublicKey [256]byte
type ElgPrivateKey [256]byte type ElgPrivateKey [256]byte
@ -198,7 +196,6 @@ func (elg ElgPublicKey) NewEncrypter() (enc Encrypter, err error) {
return return
} }
func (elg ElgPrivateKey) Len() int { func (elg ElgPrivateKey) Len() int {
return len(elg) return len(elg)
} }

View File

@ -8,7 +8,6 @@ import (
"testing" "testing"
) )
func TestElg(t *testing.T) { func TestElg(t *testing.T) {
k := new(elgamal.PrivateKey) k := new(elgamal.PrivateKey)
err := ElgamalGenerate(k, rand.Reader) err := ElgamalGenerate(k, rand.Reader)

View File

@ -6,7 +6,6 @@ import (
"testing" "testing"
) )
// XXX: IMPLEMENT THIS // XXX: IMPLEMENT THIS
func Test_I2PHMAC(t *testing.T) { func Test_I2PHMAC(t *testing.T) {
data := make([]byte, 64) data := make([]byte, 64)

View File

@ -1,6 +1,5 @@
package crypto package crypto
type RSA2048PublicKey [256]byte type RSA2048PublicKey [256]byte
type RSA2048PrivateKey [512]byte type RSA2048PrivateKey [512]byte
@ -9,4 +8,3 @@ type RSA3072PrivateKey [786]byte
type RSA4096PublicKey [512]byte type RSA4096PublicKey [512]byte
type RSA4096PrivateKey [1024]byte type RSA4096PrivateKey [1024]byte

View File

@ -26,7 +26,6 @@ type SigningPublicKey interface {
Len() int Len() int
} }
// type for signing data // type for signing data
type Signer interface { type Signer interface {
// sign data with our private key by calling SignHash after hashing the data we are given // sign data with our private key by calling SignHash after hashing the data we are given
@ -38,7 +37,6 @@ type Signer interface {
SignHash(h []byte) (sig []byte, err error) SignHash(h []byte) (sig []byte, err error)
} }
// key for signing data // key for signing data
type SigningPrivateKey interface { type SigningPrivateKey interface {
// create a new signer to sign data // create a new signer to sign data

View File

@ -1,4 +1,5 @@
package crypto package crypto
import ( import (
"crypto/aes" "crypto/aes"
"crypto/cipher" "crypto/cipher"
@ -8,6 +9,7 @@ type TunnelData [1024]byte
// A symetric key for encrypting tunnel messages // A symetric key for encrypting tunnel messages
type TunnelKey [32]byte type TunnelKey [32]byte
// The initialization vector for a tunnel message // The initialization vector for a tunnel message
type TunnelIV []byte type TunnelIV []byte

View File

@ -1,2 +1 @@
package stdi2p package stdi2p

View File

@ -7,7 +7,6 @@ type Reseed interface {
Reseed(chnl chan *Entry) error Reseed(chnl chan *Entry) error
} }
func GetRandomReseed() Reseed { func GetRandomReseed() Reseed {
// TODO: hardcoded value // TODO: hardcoded value
return HTTPSReseed("https://i2p.rocks:445/") return HTTPSReseed("https://i2p.rocks:445/")

View File

@ -1,8 +1,8 @@
package netdb package netdb
import ( import (
log "github.com/golang/glog"
"github.com/bounce-chat/go-i2p/lib/common" "github.com/bounce-chat/go-i2p/lib/common"
log "github.com/golang/glog"
"io" "io"
"os" "os"
) )
@ -10,7 +10,6 @@ import (
// standard network database implementation // standard network database implementation
type StdNetDB string type StdNetDB string
// get netdb path // get netdb path
func (db StdNetDB) Path() string { func (db StdNetDB) Path() string {
return string(db) return string(db)
@ -43,7 +42,6 @@ func (db StdNetDB) SaveEntry(e *Entry) (err error) {
return return
} }
// reseed if we have less than minRouters known routers // reseed if we have less than minRouters known routers
// returns error if reseed failed // returns error if reseed failed
func (db StdNetDB) Reseed(minRouters int) (err error) { func (db StdNetDB) Reseed(minRouters int) (err error) {

View File

@ -11,7 +11,6 @@ type Router struct {
ndb netdb.StdNetDB ndb netdb.StdNetDB
} }
func CreateRouter() (r *Router, err error) { func CreateRouter() (r *Router, err error) {
cfg := config.Router cfg := config.Router
r = &Router{ r = &Router{

View File

@ -4,4 +4,3 @@ i2p ssu transport implementation
*/ */
package ssu package ssu

View File

@ -1,3 +1 @@
package ssu package ssu

View File

@ -1,7 +1,5 @@
package stdi2p package stdi2p
// Router Identity // Router Identity
type RouterIdentity struct { type RouterIdentity struct {
} }

View File

@ -1,6 +1,4 @@
package stdi2p package stdi2p
type RouterInfo struct { type RouterInfo struct {
} }

View File

@ -1,6 +1,5 @@
package stdi2p package stdi2p
// i2p date time stamp // i2p date time stamp
type Date [8]byte type Date [8]byte

View File

@ -1,7 +1,5 @@
package stdi2p package stdi2p
// an su3 archive // an su3 archive
type SU3 struct { type SU3 struct {
} }

View File

@ -15,12 +15,10 @@ type DelayFactor byte
type DeliveryInstructions []byte type DeliveryInstructions []byte
func (di DeliveryInstructions) DeliveryType() byte { func (di DeliveryInstructions) DeliveryType() byte {
return (di[0] & 0x30) >> 4 return (di[0] & 0x30) >> 4
} }
func (di DeliveryInstructions) IsFragmented() bool { func (di DeliveryInstructions) IsFragmented() bool {
return (di[0] & 0x08) == 0x08 return (di[0] & 0x08) == 0x08
} }

View File

@ -1,8 +1,8 @@
package tunnel package tunnel
import ( import (
"github.com/bounce-chat/go-i2p/lib/crypto"
"encoding/binary" "encoding/binary"
"github.com/bounce-chat/go-i2p/lib/crypto"
) )
type TunnelID uint32 type TunnelID uint32

View File

@ -7,4 +7,3 @@ import (
type Participant struct { type Participant struct {
decryption *crypto.Tunnel decryption *crypto.Tunnel
} }

View File

@ -1,15 +1,12 @@
package main package main
import ( import (
"github.com/bounce-chat/go-i2p/lib/router" "github.com/bounce-chat/go-i2p/lib/router"
log "github.com/golang/glog"
"flag" "flag"
log "github.com/golang/glog"
) )
func main() { func main() {
flag.Parse() flag.Parse()