mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Add a function for comparing the orport on an extendinfo.
This commit is contained in:
parent
8f362b7bce
commit
81d312f12c
@ -63,10 +63,10 @@
|
||||
#include "trunnel/channelpadding_negotiation.h"
|
||||
#include "trunnel/netinfo.h"
|
||||
#include "core/or/channelpadding.h"
|
||||
#include "core/or/extendinfo.h"
|
||||
|
||||
#include "core/or/cell_st.h"
|
||||
#include "core/or/cell_queue_st.h"
|
||||
#include "core/or/extend_info_st.h"
|
||||
#include "core/or/or_connection_st.h"
|
||||
#include "core/or/or_handshake_certs_st.h"
|
||||
#include "core/or/or_handshake_state_st.h"
|
||||
@ -702,9 +702,9 @@ channel_tls_matches_extend_info_method(channel_t *chan,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (tor_addr_eq(&(extend_info->addr),
|
||||
&(TO_CONN(tlschan->conn)->addr)) &&
|
||||
(extend_info->port == TO_CONN(tlschan->conn)->port));
|
||||
return extend_info_has_orport(extend_info,
|
||||
&TO_CONN(tlschan->conn)->addr,
|
||||
TO_CONN(tlschan->conn)->port);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,8 +203,8 @@ circuit_is_acceptable(const origin_circuit_t *origin_circ,
|
||||
const int family = tor_addr_parse(&addr,
|
||||
conn->socks_request->address);
|
||||
if (family < 0 ||
|
||||
!tor_addr_eq(&build_state->chosen_exit->addr, &addr) ||
|
||||
build_state->chosen_exit->port != conn->socks_request->port)
|
||||
!extend_info_has_orport(build_state->chosen_exit, &addr,
|
||||
conn->socks_request->port))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "core/or/circuitpadding.h"
|
||||
#include "core/or/connection_edge.h"
|
||||
#include "core/or/connection_or.h"
|
||||
#include "core/or/extendinfo.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "core/or/reasons.h"
|
||||
#include "core/or/relay.h"
|
||||
@ -1444,8 +1445,8 @@ connection_ap_fail_onehop(const char *failed_digest,
|
||||
continue;
|
||||
}
|
||||
if (tor_addr_parse(&addr, entry_conn->socks_request->address)<0 ||
|
||||
!tor_addr_eq(&build_state->chosen_exit->addr, &addr) ||
|
||||
build_state->chosen_exit->port != entry_conn->socks_request->port)
|
||||
!extend_info_has_orport(build_state->chosen_exit, &addr,
|
||||
entry_conn->socks_request->port))
|
||||
continue;
|
||||
}
|
||||
log_info(LD_APP, "Closing one-hop stream to '%s/%s' because the OR conn "
|
||||
|
@ -207,3 +207,16 @@ extend_info_addr_is_allowed(const tor_addr_t *addr)
|
||||
disallow:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if @a addr : @a port is a listed ORPort in @a ei.
|
||||
**/
|
||||
bool
|
||||
extend_info_has_orport(const extend_info_t *ei,
|
||||
const tor_addr_t *addr, uint16_t port)
|
||||
{
|
||||
IF_BUG_ONCE(ei == NULL)
|
||||
return false;
|
||||
|
||||
return tor_addr_eq(&ei->addr, addr) && ei->port == port;
|
||||
}
|
||||
|
@ -27,5 +27,7 @@ int extend_info_addr_is_allowed(const tor_addr_t *addr);
|
||||
int extend_info_supports_tap(const extend_info_t* ei);
|
||||
int extend_info_supports_ntor(const extend_info_t* ei);
|
||||
int extend_info_has_preferred_onion_key(const extend_info_t* ei);
|
||||
bool extend_info_has_orport(const extend_info_t *ei,
|
||||
const tor_addr_t *addr, uint16_t port);
|
||||
|
||||
#endif /* !defined(TOR_CORE_OR_EXTENDINFO_H) */
|
||||
|
Loading…
Reference in New Issue
Block a user