mirror of
https://github.com/urbit/shrub.git
synced 2024-12-29 23:23:52 +03:00
vere: use pier data directly in ames.c
Instead of copying it into the local struct. Arguably the port should still be present in the ames struct, since it's written to. There's a comment for removing it from the _pier_ struct though, which seems like the better change, but out of scope for here.
This commit is contained in:
parent
95d90a362e
commit
b864d30685
@ -35,9 +35,6 @@
|
|||||||
uv_udp_t wax_u; //
|
uv_udp_t wax_u; //
|
||||||
uv_handle_t had_u; //
|
uv_handle_t had_u; //
|
||||||
}; //
|
}; //
|
||||||
c3_d who_d[2]; // identity
|
|
||||||
c3_o fak_o; // fake keys
|
|
||||||
c3_s por_s; // public IPv4 port
|
|
||||||
c3_c* dns_c; // domain XX multiple/fallback
|
c3_c* dns_c; // domain XX multiple/fallback
|
||||||
c3_d dop_d; // drop count
|
c3_d dop_d; // drop count
|
||||||
c3_d fal_d; // crash count
|
c3_d fal_d; // crash count
|
||||||
@ -703,8 +700,8 @@ _ames_recv_cb(uv_udp_t* wax_u,
|
|||||||
|
|
||||||
// if we are not the recipient, attempt to forward statelessly
|
// if we are not the recipient, attempt to forward statelessly
|
||||||
//
|
//
|
||||||
if ( (rec_d[0] != sam_u->who_d[0])
|
if ( (rec_d[0] != sam_u->pir_u->who_d[0])
|
||||||
|| (rec_d[1] != sam_u->who_d[1]) )
|
|| (rec_d[1] != sam_u->pir_u->who_d[1]) )
|
||||||
{
|
{
|
||||||
pas_o = c3n;
|
pas_o = c3n;
|
||||||
//TODO counter?
|
//TODO counter?
|
||||||
@ -757,13 +754,13 @@ _ames_recv_cb(uv_udp_t* wax_u,
|
|||||||
static void
|
static void
|
||||||
_ames_io_start(u3_ames* sam_u)
|
_ames_io_start(u3_ames* sam_u)
|
||||||
{
|
{
|
||||||
c3_s por_s = sam_u->por_s;
|
c3_s por_s = sam_u->pir_u->por_s;
|
||||||
u3_noun who = u3i_chubs(2, sam_u->who_d);
|
u3_noun who = u3i_chubs(2, sam_u->pir_u->who_d);
|
||||||
u3_noun rac = u3do("clan:title", u3k(who));
|
u3_noun rac = u3do("clan:title", u3k(who));
|
||||||
c3_i ret_i;
|
c3_i ret_i;
|
||||||
|
|
||||||
if ( c3__czar == rac ) {
|
if ( c3__czar == rac ) {
|
||||||
c3_y num_y = (c3_y)sam_u->who_d[0];
|
c3_y num_y = (c3_y)sam_u->pir_u->who_d[0];
|
||||||
c3_s zar_s = _ames_czar_port(num_y);
|
c3_s zar_s = _ames_czar_port(num_y);
|
||||||
|
|
||||||
if ( 0 == por_s ) {
|
if ( 0 == por_s ) {
|
||||||
@ -806,14 +803,14 @@ _ames_io_start(u3_ames* sam_u)
|
|||||||
uv_udp_getsockname(&sam_u->wax_u, (struct sockaddr *)&add_u, &add_i);
|
uv_udp_getsockname(&sam_u->wax_u, (struct sockaddr *)&add_u, &add_i);
|
||||||
c3_assert(add_u.sin_port);
|
c3_assert(add_u.sin_port);
|
||||||
|
|
||||||
sam_u->por_s = ntohs(add_u.sin_port);
|
sam_u->pir_u->por_s = ntohs(add_u.sin_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( c3y == u3_Host.ops_u.net ) {
|
if ( c3y == u3_Host.ops_u.net ) {
|
||||||
u3l_log("ames: live on %d\n", sam_u->por_s);
|
u3l_log("ames: live on %d\n", sam_u->pir_u->por_s);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u3l_log("ames: live on %d (localhost only)\n", sam_u->por_s);
|
u3l_log("ames: live on %d (localhost only)\n", sam_u->pir_u->por_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb);
|
uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb);
|
||||||
@ -843,7 +840,7 @@ _ames_ef_turf(u3_ames* sam_u, u3_noun tuf)
|
|||||||
|
|
||||||
u3z(tuf);
|
u3z(tuf);
|
||||||
}
|
}
|
||||||
else if ( (c3n == sam_u->fak_o) && (0 == sam_u->dns_c) ) {
|
else if ( (c3n == sam_u->pir_u->fak_o) && (0 == sam_u->dns_c) ) {
|
||||||
u3l_log("ames: turf: no domains\n");
|
u3l_log("ames: turf: no domains\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1015,11 +1012,7 @@ u3_auto*
|
|||||||
u3_ames_io_init(u3_pier* pir_u)
|
u3_ames_io_init(u3_pier* pir_u)
|
||||||
{
|
{
|
||||||
u3_ames* sam_u = c3_calloc(sizeof(*sam_u));
|
u3_ames* sam_u = c3_calloc(sizeof(*sam_u));
|
||||||
sam_u->pir_u = pir_u; //TODO de-dupe the below using this?
|
sam_u->pir_u = pir_u;
|
||||||
sam_u->who_d[0] = pir_u->who_d[0];
|
|
||||||
sam_u->who_d[1] = pir_u->who_d[1];
|
|
||||||
sam_u->por_s = pir_u->por_s;
|
|
||||||
sam_u->fak_o = pir_u->fak_o;
|
|
||||||
sam_u->dop_d = 0;
|
sam_u->dop_d = 0;
|
||||||
sam_u->see_o = c3y;
|
sam_u->see_o = c3y;
|
||||||
sam_u->fit_o = c3n;
|
sam_u->fit_o = c3n;
|
||||||
@ -1029,7 +1022,7 @@ u3_ames_io_init(u3_pier* pir_u)
|
|||||||
|
|
||||||
// Disable networking for fake ships
|
// Disable networking for fake ships
|
||||||
//
|
//
|
||||||
if ( c3y == sam_u->fak_o ) {
|
if ( c3y == sam_u->pir_u->fak_o ) {
|
||||||
u3_Host.ops_u.net = c3n;
|
u3_Host.ops_u.net = c3n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user