Overview
Comment: | fixes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
987a1aac0368eb1ba1468de2f03194f9 |
User & Date: | lexi on 2022-11-01 20:05:09 |
Other Links: | manifest | tags |
Context
2022-12-26
| ||
13:31 | add termcolors, update parvan and compose check-in: 54874eb3eb user: lexi tags: trunk | |
2022-11-01
| ||
20:05 | fixes check-in: 987a1aac03 user: lexi tags: trunk | |
19:10 | fully functional?? check-in: 700efc70e2 user: lexi tags: trunk | |
Changes
Modified wgsync/src/wgsync.c from [804d360053] to [3eda0dfc74].
248 248 found = p; 249 249 break; 250 250 } 251 251 ++j;}} 252 252 253 253 if (found) { 254 254 /* compare and update IPs if necessary */ 255 - bool goodIPs [ips -> sz]; _zero(goodIPs); 255 + 256 + size_t wgIPc = 0; 257 + { wg_allowedip* a; wg_for_each_allowedip(found, a) ++wgIPc; }; 258 + bool goodIPs [wgIPc]; _zero(goodIPs); 256 259 /* extant IPs that are not marked good by the 257 260 * end of the following loop must be deleted 258 261 * from memory */ 259 262 size_t goodIPc = 0; 260 263 for (size_t j = 0; j < ips -> sz; ++j) { 261 264 char inetstr[256]; 262 265 wg_allowedip aip = inet_to_allowedip(ips -> elts[j].data); ................................................................................ 269 272 wg_for_each_allowedip(found, wgip) { 270 273 if (compare_allowedip(&aip, wgip)) { 271 274 ++goodIPc; goodIPs[l] = true; 272 275 foundIP = true; 273 276 } 274 277 ++l;} 275 278 276 - if(!foundIP) { 279 + if(foundIP == false) { 277 280 /* this IP hasn't been loaded into the 278 281 * kernel yet; upload it now */ 279 282 _infof("inserting IP PG%zu %s", j, inetstr); 280 - // is this necessary? FIXME 281 - /* found -> flags |= WGPEER_REPLACE_ALLOWEDIPS; */ 283 + found -> flags |= WGPEER_REPLACE_ALLOWEDIPS; 282 284 wg_allowedip* nip = wgd_peer_new_allowedip(found); 283 285 memcpy(nip, &aip, sizeof aip); 284 286 dirty = true; 285 287 } 286 288 } 287 289 288 - if(goodIPc < ips -> sz) { 290 + if(goodIPc < wgIPc) { 289 291 size_t l = 0; 290 292 wg_allowedip* wgip; 291 293 wg_for_each_allowedip(found, wgip) { 292 294 char inetstr[256]; 293 295 dumpAllowedIP(inetstr, wgip); 294 296 _dbgf("IP WG%zu :: %s", l, inetstr); 295 297 if(l<goodIPc && !goodIPs[l]) { ................................................................................ 442 444 if(geteuid() == 0) { 443 445 char* suid = getenv("SUDO_UID"); 444 446 char* susr = getenv("SUDO_USER"); 445 447 if(suid) seteuid(atoi(suid)); 446 448 if(susr) setenv("USER",getenv("SUDO_USER"), 1); 447 449 } 448 450 449 - PGconn* db = PQconnectdb("dbname=domain"); 451 + char* connstr = getenv("wgsync_conn"); 452 + if(connstr == null) _fatal("no connection string supplied"); 453 + PGconn* db = PQconnectdb(connstr); 450 454 if(PQstatus(db) != CONNECTION_OK) 451 455 _fatal(PQerrorMessage(db)); 452 456 453 457 PGresult* q_get_hosts = PQprepare(db, "get_hosts", 454 458 "select h.ref, array_remove(array_agg(wgv4::inet)" 455 459 "|| array_agg(wgv6::inet), null)" 456 460 "from ns, hostref h "