|
@@ -597,6 +597,33 @@ connected_cell_format_payload(uint8_t *payload_out,
|
|
return connected_payload_len;
|
|
return connected_payload_len;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+send_ha_proxy_header(const edge_connection_t *edge_conn,
|
|
|
|
+ connection_t *conn)
|
|
|
|
+{
|
|
|
|
+ char buf[512];
|
|
|
|
+ char dst_ipv6[39] = "::1";
|
|
|
|
+
|
|
|
|
+ char src_ipv6_prefix[34] = "fc00:dead:beef:4dad:";
|
|
|
|
+
|
|
|
|
+ uint16_t dst_port = 443;
|
|
|
|
+ uint16_t src_port = 0;
|
|
|
|
+ uint32_t gid = 0;
|
|
|
|
+
|
|
|
|
+ if (edge_conn->on_circuit != NULL) {
|
|
|
|
+ gid = TO_ORIGIN_CIRCUIT(edge_conn->on_circuit)->global_identifier;
|
|
|
|
+ src_port = gid & 0x0000ffff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ gid = (gid == 0) ? 1 : gid;
|
|
|
|
+ src_port = (src_port == 0) ? 1 : src_port;
|
|
|
|
+
|
|
|
|
+ tor_snprintf(buf, sizeof(buf), "PROXY TCP6 %s:%x %s %d %d\r\n",
|
|
|
|
+ src_ipv6_prefix, gid, dst_ipv6, src_port, dst_port);
|
|
|
|
+ connection_buf_add(buf, strlen(buf), conn);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
* data, deliver 'CONNECTED' relay cells as appropriate, and check
|
|
* data, deliver 'CONNECTED' relay cells as appropriate, and check
|
|
* any pending data that may have been received. */
|
|
* any pending data that may have been received. */
|
|
@@ -618,28 +645,13 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
|
|
|
|
|
|
conn->state = EXIT_CONN_STATE_OPEN;
|
|
conn->state = EXIT_CONN_STATE_OPEN;
|
|
|
|
|
|
-
|
|
+
|
|
- char buf[512];
|
|
+ * protocol header */
|
|
- char dst_ipv6[39] = "::1";
|
|
+ if (edge_conn->hs_ident &&
|
|
-
|
|
+ hs_service_exports_circuit_id(&edge_conn->hs_ident->identity_pk)) {
|
|
- char src_ipv6_prefix[34] = "fc00:dead:beef:4dad:";
|
|
+ send_ha_proxy_header(edge_conn, conn);
|
|
-
|
|
|
|
- uint16_t dst_port = 443;
|
|
|
|
- uint16_t src_port = 0;
|
|
|
|
- uint32_t gid = 0;
|
|
|
|
-
|
|
|
|
- if (edge_conn->on_circuit != NULL) {
|
|
|
|
- gid = TO_ORIGIN_CIRCUIT(edge_conn->on_circuit)->global_identifier;
|
|
|
|
- src_port = gid & 0x0000ffff;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- gid = (gid == 0) ? 1 : gid;
|
|
|
|
- src_port = (src_port == 0) ? 1 : src_port;
|
|
|
|
-
|
|
|
|
- tor_snprintf(buf, sizeof(buf), "PROXY TCP6 %s:%x %s %d %d\r\n",
|
|
|
|
- src_ipv6_prefix, gid, dst_ipv6, src_port, dst_port);
|
|
|
|
- connection_buf_add(buf, strlen(buf), conn);
|
|
|
|
-
|
|
|
|
connection_watch_events(conn, READ_EVENT);
|
|
connection_watch_events(conn, READ_EVENT);
|
|
if (connection_get_outbuf_len(conn))
|
|
if (connection_get_outbuf_len(conn))
|
|
* cells */
|
|
* cells */
|