|
|
@ -7,8 +7,9 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
// ClientIdentity represents the identity of a peer.
|
|
|
|
// ClientIdentity represents the identity of a peer.
|
|
|
|
type ClientIdentity interface { |
|
|
|
type ClientIdentity interface { |
|
|
|
String() string // human readable identity
|
|
|
|
String() string // human readable identity
|
|
|
|
Pubkey() []byte // 512-bit public key
|
|
|
|
Pubkey() []byte // 512-bit public key
|
|
|
|
|
|
|
|
PrivKey() []byte // 512-bit private key
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type SimpleClientIdentity struct { |
|
|
|
type SimpleClientIdentity struct { |
|
|
@ -17,10 +18,11 @@ type SimpleClientIdentity struct { |
|
|
|
customIdentifier string |
|
|
|
customIdentifier string |
|
|
|
os string |
|
|
|
os string |
|
|
|
implementation string |
|
|
|
implementation string |
|
|
|
|
|
|
|
privkey []byte |
|
|
|
pubkey []byte |
|
|
|
pubkey []byte |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func NewSimpleClientIdentity(clientIdentifier string, version string, customIdentifier string, pubkey []byte) *SimpleClientIdentity { |
|
|
|
func NewSimpleClientIdentity(clientIdentifier string, version string, customIdentifier string, privkey []byte, pubkey []byte) *SimpleClientIdentity { |
|
|
|
clientIdentity := &SimpleClientIdentity{ |
|
|
|
clientIdentity := &SimpleClientIdentity{ |
|
|
|
clientIdentifier: clientIdentifier, |
|
|
|
clientIdentifier: clientIdentifier, |
|
|
|
version: version, |
|
|
|
version: version, |
|
|
@ -28,6 +30,7 @@ func NewSimpleClientIdentity(clientIdentifier string, version string, customIden |
|
|
|
os: runtime.GOOS, |
|
|
|
os: runtime.GOOS, |
|
|
|
implementation: runtime.Version(), |
|
|
|
implementation: runtime.Version(), |
|
|
|
pubkey: pubkey, |
|
|
|
pubkey: pubkey, |
|
|
|
|
|
|
|
privkey: privkey, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return clientIdentity |
|
|
|
return clientIdentity |
|
|
@ -50,8 +53,12 @@ func (c *SimpleClientIdentity) String() string { |
|
|
|
c.implementation) |
|
|
|
c.implementation) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *SimpleClientIdentity) Privkey() []byte { |
|
|
|
|
|
|
|
return c.privkey |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *SimpleClientIdentity) Pubkey() []byte { |
|
|
|
func (c *SimpleClientIdentity) Pubkey() []byte { |
|
|
|
return []byte(c.pubkey) |
|
|
|
return c.pubkey |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *SimpleClientIdentity) SetCustomIdentifier(customIdentifier string) { |
|
|
|
func (c *SimpleClientIdentity) SetCustomIdentifier(customIdentifier string) { |
|
|
|