mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Add etherTypes to netconf response.
This commit is contained in:
parent
3745377872
commit
8e1b897f0a
2 changed files with 14 additions and 2 deletions
|
@ -121,7 +121,6 @@ int main(int argc,char **argv)
|
||||||
dbCon = new Connection(mysqlDatabase,mysqlHost,mysqlUser,mysqlPassword,(unsigned int)strtol(mysqlPort,(char **)0,10));
|
dbCon = new Connection(mysqlDatabase,mysqlHost,mysqlUser,mysqlPassword,(unsigned int)strtol(mysqlPort,(char **)0,10));
|
||||||
if (dbCon->connected()) {
|
if (dbCon->connected()) {
|
||||||
fprintf(stderr,"connected to mysql server successfully\n");
|
fprintf(stderr,"connected to mysql server successfully\n");
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"unable to connect to database server\n");
|
fprintf(stderr,"unable to connect to database server\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -232,6 +231,18 @@ int main(int argc,char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string etherTypeWhitelist;
|
||||||
|
{
|
||||||
|
Query q = dbCon->query();
|
||||||
|
q << "SELECT DISTINCT etherType FROM NetworkEthertypes WHERE Network_id = " << nwid;
|
||||||
|
StoreQueryResult rs = q.store();
|
||||||
|
for(unsigned long i=0;i<rs.num_rows();++i) {
|
||||||
|
if (etherTypeWhitelist.length() > 0)
|
||||||
|
etherTypeWhitelist.push_back(',');
|
||||||
|
etherTypeWhitelist.append(rs[i]["etherType"].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dictionary netconf;
|
Dictionary netconf;
|
||||||
|
|
||||||
netconf["peer"] = peerIdentity.address().toString();
|
netconf["peer"] = peerIdentity.address().toString();
|
||||||
|
@ -240,6 +251,7 @@ int main(int argc,char **argv)
|
||||||
netconf["isOpen"] = (isOpen ? "1" : "0");
|
netconf["isOpen"] = (isOpen ? "1" : "0");
|
||||||
netconf["name"] = name;
|
netconf["name"] = name;
|
||||||
netconf["desc"] = desc;
|
netconf["desc"] = desc;
|
||||||
|
netconf["etherTypes"] = etherTypeWhitelist;
|
||||||
sprintf(buf,"%llx",(unsigned long long)Utils::now());
|
sprintf(buf,"%llx",(unsigned long long)Utils::now());
|
||||||
netconf["ts"] = buf;
|
netconf["ts"] = buf;
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ Filter::Filter(const char *s)
|
||||||
throw std::invalid_argument("filter string too long");
|
throw std::invalid_argument("filter string too long");
|
||||||
char *saveptr = (char *)0;
|
char *saveptr = (char *)0;
|
||||||
unsigned int fn = 0;
|
unsigned int fn = 0;
|
||||||
for(char *f=Utils::stok(tmp,"-",&saveptr);(f);f=Utils::stok((char *)0,"-",&saveptr)) {
|
for(char *f=Utils::stok(tmp,",",&saveptr);(f);f=Utils::stok((char *)0,",",&saveptr)) {
|
||||||
try {
|
try {
|
||||||
_rules.push_back(Rule(f));
|
_rules.push_back(Rule(f));
|
||||||
++fn;
|
++fn;
|
||||||
|
|
Loading…
Add table
Reference in a new issue