diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-07-06 16:11:11 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-07-06 16:11:11 -0700 |
| commit | d2415dee00914ab3fd7016758f4184d46bb407a5 (patch) | |
| tree | 3e314c3464b1ddc86423cd1081cf65183e1a0fa4 /node/Identity.cpp | |
| parent | 53728b79b45417bc8f36464e13121229858f6ca5 (diff) | |
| download | infinitytier-d2415dee00914ab3fd7016758f4184d46bb407a5.tar.gz infinitytier-d2415dee00914ab3fd7016758f4184d46bb407a5.zip | |
Cleanup.
Diffstat (limited to 'node/Identity.cpp')
| -rw-r--r-- | node/Identity.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/node/Identity.cpp b/node/Identity.cpp index ba77aa47..3b00b4c0 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -136,19 +136,23 @@ bool Identity::locallyValidate() const (digest[63] == addrb[4])); } -std::string Identity::toString(bool includePrivate) const +char *Identity::toString(bool includePrivate,char buf[ZT_IDENTITY_STRING_BUFFER_LENGTH]) const { - std::string r; - - r.append(_address.toString()); - r.append(":0:"); // 0 == ZT_OBJECT_TYPE_IDENTITY - r.append(Utils::hex(_publicKey.data,(unsigned int)_publicKey.size())); + char *p = buf; + Utils::hex10(_address.toInt(),p); + p += 10; + *(p++) = ':'; + *(p++) = '0'; + *(p++) = ':'; + Utils::hex(_publicKey.data,ZT_C25519_PUBLIC_KEY_LEN,p); + p += ZT_C25519_PUBLIC_KEY_LEN * 2; if ((_privateKey)&&(includePrivate)) { - r.push_back(':'); - r.append(Utils::hex(_privateKey->data,(unsigned int)_privateKey->size())); + *(p++) = ':'; + Utils::hex(_privateKey->data,ZT_C25519_PRIVATE_KEY_LEN,p); + p += ZT_C25519_PRIVATE_KEY_LEN * 2; } - - return r; + *(p++) = (char)0; + return buf; } bool Identity::fromString(const char *str) @@ -157,7 +161,7 @@ bool Identity::fromString(const char *str) return false; char *saveptr = (char *)0; - char tmp[1024]; + char tmp[ZT_IDENTITY_STRING_BUFFER_LENGTH]; if (!Utils::scopy(tmp,sizeof(tmp),str)) return false; |
