… | |
… | |
632 | } |
632 | } |
633 | } |
633 | } |
634 | |
634 | |
635 | connection *vpn::find_router () |
635 | connection *vpn::find_router () |
636 | { |
636 | { |
637 | u32 prio = 0; |
637 | u32 prio = 1; |
638 | connection *router = 0; |
638 | connection *router = 0; |
639 | |
639 | |
640 | for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) |
640 | for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) |
641 | { |
641 | { |
642 | connection *c = *i; |
642 | connection *c = *i; |
643 | |
643 | |
644 | if (c->conf->routerprio > prio |
644 | if (c->conf->routerprio >= prio |
645 | && c->connectmode == conf_node::C_ALWAYS // so we don't drop the connection if in use |
645 | && c->connectmode == conf_node::C_ALWAYS // so we don't drop the connection if in use |
646 | && c->ictx && c->octx |
646 | && c->ictx && c->octx |
647 | && c->conf != THISNODE // redundant, since ictx==octx==0 always on thisnode |
647 | && c->conf != THISNODE // redundant, since ictx==octx==0 always on thisnode |
648 | && (!THISNODE->routerprio |
648 | && (!THISNODE->routerprio |
649 | || c->conf->routerprio <= THISNODE->routerprio)) |
649 | || c->conf->routerprio <= THISNODE->routerprio)) |