mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Add C output to mkworld.
This commit is contained in:
parent
cae58f43f1
commit
05677f57e2
3 changed files with 19 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -31,6 +31,7 @@ Thumbs.db
|
||||||
/ZeroTierOneInstaller-*
|
/ZeroTierOneInstaller-*
|
||||||
/examples/docker/zerotier-one
|
/examples/docker/zerotier-one
|
||||||
/examples/docker/test-*.env
|
/examples/docker/test-*.env
|
||||||
|
/mkworld
|
||||||
|
|
||||||
# Miscellaneous file types that we don't want to check in
|
# Miscellaneous file types that we don't want to check in
|
||||||
*.log
|
*.log
|
||||||
|
|
17
mkworld.cpp
17
mkworld.cpp
|
@ -144,10 +144,27 @@ int main(int argc,char **argv)
|
||||||
|
|
||||||
Buffer<ZT_WORLD_MAX_SERIALIZED_LENGTH> outtmp;
|
Buffer<ZT_WORLD_MAX_SERIALIZED_LENGTH> outtmp;
|
||||||
nw.serialize(outtmp,false);
|
nw.serialize(outtmp,false);
|
||||||
|
World testw;
|
||||||
|
testw.deserialize(outtmp,0);
|
||||||
|
if (testw != nw) {
|
||||||
|
fprintf(stderr,"FATAL: serialization test failed!"ZT_EOL_S);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
fwrite(outtmp.data(),outtmp.size(),1,stdout);
|
fwrite(outtmp.data(),outtmp.size(),1,stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
fprintf(stderr,"INFO: wrote %u bytes to stdout"ZT_EOL_S,outtmp.size());
|
fprintf(stderr,"INFO: wrote %u bytes to stdout"ZT_EOL_S,outtmp.size());
|
||||||
|
|
||||||
|
fprintf(stderr,ZT_EOL_S);
|
||||||
|
fprintf(stderr,"#define ZT_DEFAULT_WORLD_LENGTH %u"ZT_EOL_S,outtmp.size());
|
||||||
|
fprintf(stderr,"static const unsigned char ZT_DEFAULT_WORLD[ZT_DEFAULT_WORLD_LENGTH] = {");
|
||||||
|
for(unsigned int i=0;i<outtmp.size();++i) {
|
||||||
|
const unsigned char *d = (const unsigned char *)outtmp.data();
|
||||||
|
if (i > 0)
|
||||||
|
fprintf(stderr,",");
|
||||||
|
fprintf(stderr,"0x%.2x",(unsigned int)d[i]);
|
||||||
|
}
|
||||||
|
fprintf(stderr,"};"ZT_EOL_S);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ public:
|
||||||
return (p - startAt);
|
return (p - startAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const World &w) const throw() { return ((_id == w._id)&&(_ts == w._ts)&&(_roots == w._roots)); }
|
inline bool operator==(const World &w) const throw() { return ((_id == w._id)&&(_ts == w._ts)&&(_updateSigningKey == w._updateSigningKey)&&(_signature == w._signature)&&(_roots == w._roots)); }
|
||||||
inline bool operator!=(const World &w) const throw() { return (!(*this == w)); }
|
inline bool operator!=(const World &w) const throw() { return (!(*this == w)); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Reference in a new issue